See Questions at the bottom.Due: 11:59 PM, Mar 1 Submit Project: parser Source File: gee.py.txt Grammar File: grammar.txt
Test Files: t0.gee.txt t1.gee.txt t2.gee.txt max.gee.txt fact.gee.txt test.gee.txt Output: max-out.txt fact-out.txt test-out.txt
The Gee programming language is:
The purpose of the project is to parse the input according to the grammar and produce a printed representation of the abstract syntax tree. Sample data and output are given above.
Your task is to construct the remaining recursive descent routines to complete the parser for the Gee implementation grammar. You are free to modify the grammar provided you do not change the syntax of Gee.
Specially, you must:
The output of the parser is a printed representation of
the abstract syntax tree. The abstract syntax is defined by
a collection of classes.
Each class in the abstract syntax must have an appropriate
constructor and a __str__
function for displaying the
abstract syntax.
Statements should be printed one per line; this can be accomplshed
by appending a "\n" to the string returned by __str__
.
Expressions (including assignment) should print in Polish prefix
with a space separating each element from the next.
A Gee program file must end with an end of line. To check, either execute : cat
filename or in your editor, make sure you can move the cursor to the line below the last line of text.
print ( ... )
. Expression
or Statement
.
test.gee
print an else
3 times when only 2 of the Ifs have an else
?Block
. For me it simplifies
the next assignment.