Question: Consider the following input for the parser of the expression grammar that I covered in class: 1 2 3 4 5 6 7 8 9

Consider the following input for the parser of the expression grammar that I covered in class:
123456789101112131415
LPAREN LPA REN NUM
1 PL US NUM
2 RPA REN M ULT LPA REN NUM
3 PLUS NU
4 M
RPA REN RPA REN PL US NUM
5
As we have seen, the parsing functions call each other recursively starting with parse_input()(refer to the first set of notes for the actual code of the parsing functions).
1. Which token is consumed first by the second call to parse_F()(specify the number of the token. The numbers are highlighted in yellow in the first row of the table above) NUM 1
2. The token RPAREN at 13 is consumed by which call to parse_F()
3. What is the total number of calls to parse_F() when this input is parsed?
4. What is the total number of calls to parse_E() when this input is parsed?
5. How many calls to lexer.peek(1) in the various parsing functions return EOF while parsing this input?

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!