Spring 2019 (Thu Jan 10 - Thu Apr 25)
The top -level pacakage is miniArith contaning the Recognizer mainclass that parses input entered from the keyboard and judges whether it consitutes a valid arithmetic expression. The parse procedures corresponding to nonterminals in the grammar are traced to illustrate how the input was parsed.
The subpackage miniArith.SyntacticAnalyzer contains the Scanner, Parser, Token classes and the TokenKind enumeration.
You can use this example as a starting point for your miniJava compiler, if you wish.
The scanner and parser are in the SyntacticAnalysis subpackage and use AST classes provided in the AbstractSyntaxTrees subpackage to construct the AST during parsing.
Two traversals of the AST are implemented as visitors in the TraverseAST subpackage: DisplayAST constructs an explicitly parenthesized text representation of the AST and EvalAST evaluates an AST.
The top level package is miniArith with main class Evaluator. It uses the scanner and parser to parse an arithmetic expression entered as input from the keyboard and to construct an AST. The two visitors are used to display the AST in linear form and to compute its value.