Write some Software
$10-30 USD
Paid on delivery
You will write a recursive descent parser that analyzes 1 of the following 3 statements (meaning you do not need to write all three statements in your program parser, but ONE of them only):
● assignment_statement
● if_statement
● while_statement
The parser validates that an input program (containing only assignments, if statement and while loop) is structured correctly according to the language grammar. The parser reads the tokenized representation of a program, generates a simplified symbol table entries on the fly for each symbol defined in the program, and validates it against the associated grammar.
To simplify your coding efforts, You may only allow two values for the <expr> -- true and false; you may only allow <assign_statement> to take integer value only; You may define a single <statement> other than compound <statements> inside <if_statement> or <while_statement>.
Requirements:
1. Grammar
BNF definition of assignment_statement, if_else_statement, and while_statement
EBNF definition of assignment_statement, if_else_statement, and while_statement
2. Programming
Please pick your favorite programming language, OO or procedural, to code the parser program.
● Lexical analysis:
1) Lexical analysis of the input program
2) Generates a simplified symbol table
c. Syntax analysis
1) Create recursive descent parser (a function for each non-terminal symbol) to validate the input program
2) Generate meaningful messages to inform users of syntactic errors if any
d. Test driver
Please create a test program to run against your parser to see if the parser recognize a user input program.
Also, can you allow nested statements in the grammar definition and parser validation?
Project ID: #10608544