Assignment 2: Java Type Checker

This assignment is the first part of a multi part project to write an optimizing compiler for Minijava. We start with the LL(k) grammar for minijava and follow simplification and optimization phases, similar to what is seen in a standard optimizing compiler. In this assignment, we will implement a type checker for the minijava compiler.

Use JTB and JavaCC and write in Java one or more visitors which do two steps of semantic analysis (type checking and identify undeclared symbols) on a MiniJava program. Your main file should be called, and if contains a program to be type checked, then

java P2 <

should print one of the following: "Program type checked successfully", "Type error", or "Symbol not found". The last error message should be printed if you find a symbol (variable / field / method) is not found in the current scope. Note, your program must take input from standard input and write to standard output (so that we can use redirection).

A sample can be found here.

Grading policy
Your homework will be graded for a total of 100 marks.
[ under development ]