From Java to MIPS in Five Four Nifty Steps

UCLA CS 132 Project

Jens Palsberg

The Hundred Hour Wood




MiniJava grammar minijava.jj specification [javac+java] programs Factorial.java
Vapor grammar parser+AST specification interpreter programs Factorial.vapor
Vapor-M grammar parser+AST specification interpreter programs Factorial.vaporm
MIPS specification interpreter programs Factorial.s

The compiler project consists of Homeworks 2-5. Solutions to Homeworks 2-5 can be combined into a MiniJava-to-MIPS compiler.

Homework 2: Type checking of MiniJava

Use JTB and JavaCC and write in Java one or more visitors that type check a MiniJava program.

Your main file should be called Typecheck.java, and if P.java contains a program to be type checked, then:

java Typecheck < P.java

should print either "Program type checked successfully" or "Type error".

Make sure you follow the submission guidelines.

Homework 3: MiniJava → Vapor

Use JTB and JavaCC and write in Java one or more visitors that compile a MiniJava program to Vapor.

Your main file should be called J2V.java, and if P.java contains a syntactically correct MiniJava program, then

java J2V < P.java > P.vapor

creates a Vapor program P.vapor with the same behavior as P.java.

Make sure you follow the submission guidelines.

Homework 4: Vapor → Vapor-M

Use the provided parser and AST classes and write one or more visitors that compile a Vapor program to Vapor-M.

Your main file should be called V2VM.java, and if P.vapor contains a syntactically correct Vapor program, then

java V2VM < P.vapor > P.vaporm

creates a Vapor-M program P.vaporm with the same behavior as P.vapor.

Make sure you follow the submission guidelines.

Homework 5: Vapor-M → MIPS

Use the provided parser and AST classes and write one or more visitors that compile a Vapor-M program to MIPS.

Your main file should be called VM2M.java, and if P.vaporm contains a syntactically correct Vapor-M program, then

java VM2M < P.vaporm > P.s

creates a MIPS program P.s with the same behavior as P.vaporm.

Make sure you follow the submission guidelines.