CS 3310 - Language Translators

Assignment 4: Simplified Intermediate Code Generation.

This assignment is the third part of a multi part project to write an optimizing compiler for Minijava. In this assignment, we start with programs in (miniIR)format and translate them to (microIR).

Use JTB and JavaCC and write in Java one or more visitors which translate MiniIR programs to MicroIR form. Your main file should be called P4.java, if P.miniIR contains a program to be simplified then

java P4 < P.miniIR > P.microIR

should create P.microIR in MicroIR form and is semantically equivalent to P.miniIR. Note, your program must take input from standard input and write to standard output (so that we can use redirection).

To check that a program is in microIR form, you could tie the microIR.jj and Main.java to build a parser. To ensure that your MicroIR program is semantically equivalent to the MiniIR program, you can use the interpreter of MicroIR (which is same as that of MiniIR) (download) to compare the output of P.miniIR with the output of the microIR program generated by your translator; say the generated microIR code is stored in P.microIR, then to invoke the interpreter use: java -jar pgi.jar < P.microIR ]. A sample Main.java can be found here.

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