Question: Please help with the following questions. the lecture notes are provided: 3- Trace the recursive descent parser code that we discussed during the lecture with

Please help with the following questions. the lecture notes are provided:

Please help with the following questions. the lecture notes are provided: 3-

Trace the recursive descent parser code that we discussed during the lecture

with the following input. total * (14+sum) Consider the following EBNF description

of simple arithmetic expressions: + {(+ / -) } {(* | /)

3- Trace the recursive descent parser code that we discussed during the lecture with the following input. total * (14+sum) Consider the following EBNF description of simple arithmetic expressions: + {(+ / -) } {(* | /) } id | int_constant | ( ) /* expr Parses strings in the language generated by the rule: -> { (+ / -) } */ void expr () { printf ("Enter "); /* Parse the first term */ term(); == SUB_OP) { /* As long as the next token is + or -, get the next token and parse the next term */ while (nextToken == ADD_OP || nextToken lex () ; term(); } printf ("Exit "); } /* End of function expr */ /* term Parses strings in the language generated by the rule: -> { (* | 1) ) */ void term () { printf ("Enter "); /* Parse the first factor */ factor(); /* As long as the next token is * or 7, get the next token and parse the next factor */ while (nextToken == MULT_OP || tToken == DIV_OP) { lex(); factor (); } printf ("Exit "); } /* End of function term */ /* factor Parses strings in the language generated by the rule: -> id | int_constant | ( "); /* Determine which RHS */ if (nextToken == IDENT || nextToken == INT_LIT) /* Get the next token */ lex(); * If the RHS is ( ), call lex to pass over the left parenthesis, call expr, and check for the right parenthesis */ else if (nextToken == LEFT_PAREN) { lex(); expr(); if (nextToken == RIGHT PAREN) lex(); else error(); } /* End of if (nextToken == */ /* It was not an id, an integer literal, or a left parenthesis */ else error(); } /* End of else */ } printf ("Exit ") ;; /* End of function factor */

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!