University of New Brunswick, Faculty of Computer Science

CS4905 Introduction to Compiler Construction

TypeCheckVisitor example for MiniJava grammar

The code for this example is saved as a UNIX tar (tape archive) file. Download the .tar file to a UNIX machine, then untar the files in a subdirectory you create using the following command:
tar xvf name.tar
where "name" is replaced with the name of the tar file you wish to untar. For example, to untar the "visitor.tar" file, you would type
tar xvf visitor.tar

visitor.tar contains the Visitor.java interface definition, the DepthFirstVisitor.java implementation of the Visitor interface, the TypeCheckVisitor.java implementation and the SymbolTable.java implementation. A visit method is defined for each abstract syntax class defined for the MiniJava grammar, with appropriate type checking (and error messages) for each class.

Note that the abstract syntax tree classes and MiniJava grammar input for JavaCC are the same as for the PrettyPrintVisitor example located here.