Question
Please help me with this homework problems, thanks. Consider the list of tokens: T1 = { abc, abcd1e } T2 = { abd } ID
Please help me with this homework problems, thanks.
Consider the list of tokens: T1 = { "abc", "abcd1e" } T2 = { "abd" } ID = [a-z]+[a-z0-9] NUM = 0 | [1-9][0-9]
and assume that space is a separator and that it is otherwise ignored. This questions asks you to parse an input using the tokens above. For example, if the input is abcd22abc 123 00abc abd then the following sequence of calls
t1 = lexer.GetToken(); t2 = lexer.GetToken(); t3 = lexer.peek(1); t4 = lexer.peek(3); t5 = lexer.peek(5); will produce
t1 = { ID, "abcd22abc" } t2 = { NUM, "123" } t3 = { NUM, "0" } t4 = { T1, "abc" } t5 = EOF
Now, consider the input abcd1e 982 451 abd abcd1e1 0123 abd0 What are the values of t1-t10 after the sequence of calls
t1 = lexer.GetToken(); t2 = lexer.GetToken(); t3 = lexer.peek(1); t4 = lexer.peek(2); t5 = lexer.GetToken(); t6 = lexer.peek(2); t7 = lexer.peek(3); t8 = lexer.peek(4); t9 = lexer.GetToken(); t10 = lexer.peek(5);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started