COSC 170 Compiler Construction
Spring 2009
Project #4: Type Checker
Implement a Type Checker for our dialect of the MiniJava programming
language, as detailed below.
Project 4 may be completed in teams of three.
Due: Friday, March 20, 11:59PM CST.
Submit entire Project4 directory via turnin
command on Morbius.
Directions
Read Chapter 5 of Appel.
Implement a semantic analysis (type checking) pass for our
dialect of MiniJava.
Run the reference implementation of the type checker on Morbius
with the command: ~brylow/cosc170/Projects/checker
program.java.ast, where the input file is an abstract syntax tree
dump from Project 3. Or, run the checker with parameter "-"
to pipe input in directly from a running parser.
Create your checker in a package called "Semant" with a main
program in class "Main". My grading protocol will assume that your
project can be compiled and run with the following command line:
cd Project4; make; java Semant.Main
inputfile.java.ast.
Build a decent set of MiniJava testcases. Several exist in the
book, and on the web. Having a good set of test inputs will be
critical to your success in later phases of the project. The majority
of project points will be assigned by running diff to compare your
output against mine.
Debug until done.
Specification
You will need to represent two type environments -- one for the set of
class descriptors, and a second scoped symbol table to be used during
checking of the expressions and statements in the program. Implement
this is a class
Table in a
package
Symbol. The
Table class will need
methods
put,
get,
beginScope,
and
endScope, as discussed in class and in the textbook.
A complete list of errors that the reference implementation produces
can be found
here. Please match them as
exactly as possible.
Implement the classes of the
Types package as outlined in
class. (Types API can be found
here.)
Back
[Rev 1.03 2009 Feb 27 14:27 DWB]