Compilers and Interpreters: Assignment 6
October 31, 2008
Make an ANTLR grammar for Mini-Triangle, as described in pages 8-9
of our textbook. As opposed to Assignment 5, you need to build an AST tree
similar to the AST built in the Triangle parser (pages 109-110 of our
textbook). This is done by building two grammars, one that parses the input
and creates an AST tree. The other parses the AST tree and perform the
necessary actions. For this assignments, the necessary actions are to
output the level where a variable was declared each time a variable is
used in an expression. The levels are defined as in figure 5.3, page 145
of our textbook.
Due Wednesday, November 12, before the start of class. Include "CS4352,
assignment 6" on the subject line.
E-mail to the instructor (email@example.com)
and to the teaching assistant (firstname.lastname@example.org):
- the grammars.
- a sample Mini-Triangle program (perhaps the one from assignment 5)
that causes the parser to execute all rules of the grammars.
- the output AST, as printed as printed by the "toStringTree" method
- the level of each variable as encountered in expressions.