Question: 1. Using the grammar below: -> -> | e -> -> | e -> ( ) | identifier | unsigned integer -> + | -

 1. Using the grammar below: -> -> | e -> ->

| e -> () | identifier | unsigned integer -> + |

- -> */ And the pseudo-code outline of recursive descent parser for

1. Using the grammar below: -> -> | e -> -> | e -> () | identifier | unsigned integer -> + | - -> */ And the pseudo-code outline of recursive descent parser for the above grammar: procedure expr () term(); term tail(); procedure term tail() case (next token ()) /* switch case on the next token */ of '+' or '-': add op(); term(); term tail(); otherwise: /* skip: epsilon case */ procedure term () factor(); factor tail(); procedure factor tail() case (next token()) of '*' or 'l': mult op(); factor(); factor tail(); otherwise: /* skip */ procedure factor() case (next token()). of '(': match('('); expr(); match(')'); of '-': factor(); of identifier: match (identifier); /* add to the parse tree */ of number: match (number); otherwise: error; procedure add op () case (next token ()) of '+': match('+'); of '-': match('-'); otherwise: error; procedure mult op () case (next token()) of '*': match('*'); of '/' : match('/'); otherwise: error; (a) What is the language represented by the above grammar? What types of expressions are supported? (b) Describe the flow of execution of the recursive descent parser, and briefly explain the related subroutines (procedures) as shown in the above pseudo code. (d) Give an example of expression that would generate an error by this parser. Explain briefly. (c) Show the trace (the stack of all called methods) and parse tree of the recursive descent parsing for the example expression: 1+2*3 1. Using the grammar below: -> -> | e -> -> | e -> () | identifier | unsigned integer -> + | - -> */ And the pseudo-code outline of recursive descent parser for the above grammar: procedure expr () term(); term tail(); procedure term tail() case (next token ()) /* switch case on the next token */ of '+' or '-': add op(); term(); term tail(); otherwise: /* skip: epsilon case */ procedure term () factor(); factor tail(); procedure factor tail() case (next token()) of '*' or 'l': mult op(); factor(); factor tail(); otherwise: /* skip */ procedure factor() case (next token()). of '(': match('('); expr(); match(')'); of '-': factor(); of identifier: match (identifier); /* add to the parse tree */ of number: match (number); otherwise: error; procedure add op () case (next token ()) of '+': match('+'); of '-': match('-'); otherwise: error; procedure mult op () case (next token()) of '*': match('*'); of '/' : match('/'); otherwise: error; (a) What is the language represented by the above grammar? What types of expressions are supported? (b) Describe the flow of execution of the recursive descent parser, and briefly explain the related subroutines (procedures) as shown in the above pseudo code. (d) Give an example of expression that would generate an error by this parser. Explain briefly. (c) Show the trace (the stack of all called methods) and parse tree of the recursive descent parsing for the example expression: 1+2*3

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!