Question
Write two functions, ifblock logic_expr as part of a recursive descent parser in a language of your choosing. --> if( ){ } [else { }]
Write two functions,
- ifblock
- logic_expr
as part of a recursive descent parser in a language of your choosing.
--> if( ){ } [else { }] --> == | !=
For other non terminal symbols, 'stmts' and 'value' you are allowed to assume the existence of pre-written functions by the same names.
To get the next token from the input stream you can call 'lex()' which returns a code, as listed in the codes for the terminal symbols. Implement the 'ifblock' by requesting token codes by calling 'lex()' and to evaluate and match those with the required tokens according to the language grammar.
To evaluate the logical expression of the 'if' you need to step into a function 'logic_expr', which you need to write, for evaluating a logical expression as defined in the grammar, and you may assume that the non-terminal 'value' does already exist.
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