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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!