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
Get step-by-step solutions from verified subject matter experts
