Project #4: Type Checker, Part 1

Submit: Turn in your entire Project4 directory (JavaCC grammar, abstract syntax tree classes, associated helper classes, and Makefile using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work may be completed in teams of two students. Be certain to include all team members' names in the file. Include a comment block at the very top of each file that contains the following:

/**
 * COSC 4400 - Project #
 * Explain briefly the functionality of the program.
 * @authors [your names]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email addresses]
 */

The Checker

Implement the first phase of a Type Checker for our dialect of the MiniJava programming language, as detailed below.

Getting Started

Begin by making a copy of your existing work from Project3 to Project4: cp -R Project3 Project4

The professor has provided a set of classes from the textbook for the Types package. Change to your Project4 directory and untar them: tar xvzf ~brylow/cosc4400/Projects/Types.tgz.

You will need to modify your Makefile to account for the new Types and Semant packages.

For those of you distrustful of your Project3 MiniJava parser, we are providing an alternative or "fall back" implementation path. You may use the JavaCC grammar at ~brylow/cosc4400/Projects/ReadAbsyn.jj to bypass the parsing phase of the project, and read abstract syntax trees in directly from the reference implementation mjparser. If TA-Bot senses the presence of a ReadAbsyn.jj parser in your submitted directory, it will attempt to test your typechecker with pre-parsed input, rather than actual MiniJava programs.

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 as 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]

[Revised 2026 Oct 01 12:59 DWB]