Question: I want to complete a simple code generator, follow the grammar rules in the diagram, and implement it using Flex and Bison. 1. Problem In



I want to complete a simple code generator, follow the grammar rules in the diagram, and implement it using Flex and Bison.
1. Problem In this assignment you are requested to use the tool Bison to write an LALR(1) parser for the simple language Lotus. The grammar for Lotus is given as follows: program Identifier () function_body function_body { variable_declarations statements } variable_declarations empty variable_declarations variable_declaration variable_declaration int Identifier ; statements empty statements statement statement assignment_statement compound_statement Tif_statement while_statement exit_statement read_statement write_statement assignment_statement > Identifier = arith_expression ; compound_statement { statements } if_statement > if (bool_expression ) statement if ( bool_expression ) statement else statement while_statement while (bool_expression ) statement exit_statement exit ; read_statement read Identifier ; write_statement write arith_expression; bool_expression bool_term bool_expression || bool_term bool_term bool_factor | bool_term && bool_factor bool_factor bool_primary ! bool_primary bool_primary arith_expression == arith_expression | arith_expression != arith_expression | arith_expression > arith_expression | arith_expression >= arith_expression | arith_expression
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
