This assignment is the second part of a multi part project to write an optimizing compiler for Minijava.
We start with typechecked Minijava programs and generate
programs in MiniIR format. Akin to a standard optimizing compiler,
in this assignment, we will implement a module that translates
programs in a high level language (Minijava) to programs in
intermediate form (MiniIR).
The MiniIR grammar can be found both in javaCC and html format. A sample Main.java can be found here. A set of sample minijava testcases can be found here. A set of sample translation for these testcases can be found here. To check that a program is in MiniIR form, you could tie the MiniIR.jj and Main.java to build a parser. To ensure that your MiniIR program is semantically equivalent to the Minijava program, you can use the MiniIR interpreter (download) to compare the output of Simplify (say it is stored in P.miniIR) with the input program P.java [ To invoke the interpreter use: java -jar pgi.jar < P.miniIR ].
Use JTB and JavaCC and write in Java one or more visitors which
translate MiniJava programs to MiniIR form.
Your main file should be called Simplify.java,
if P.java contains a program to be simplified then
java Simplify < P.java > P.miniIR
should create P.miniIR in MiniIR form and is semantically equivalent to
P.java.
Note, your program must take input from standard input and write to standard output.
Grading policy
Your homework will be graded for a total of 100 marks. Of these 50 marks will be for the
public testcases, 10 marks for the contributed
testcases and 40 marks for the instructors testcases.
Students can get upto 10 bonus points by contributing good testcases. Details can be found
here.