CSC 444 / HCI 590
Compiler Construction
Prof. Dr. Doug Lea
SUNY Oswego (OSU), Fall Semester 2008
Course Homepage
Assignments
- Assignment 1: A Recursive Descent Parser
for some simple logic formulae.
description || src, bin, & docs || Grammar hacks || Documentation
Project: A compiler for the MatrixMiniJ language
The purpose of the class project is to give students an experience-based learning ability to explore and overcome the problems in the field of Compiler Construction. The focus of the project is to develop a parser of a programming language that is an extension of the MiniJava Project. MiniJava is a slimmed-down subset of Java and hence, since the language offers only very fundamental features, allows compiler builders to focus on the principles.
The extension that is subject of my project is MatrixMiniJ. I extended MiniJava with support for 2-dimensional matrices. This poses interesting problems with regard to syntax ambiguity, as it is slightly more complex than implementing 2-dimensional arrays. MatrixMiniJava hence is a extension of Java that allows constructs like
int[[]] matrix = new int[[42, 19]];
Phase 1 - A Parser for MatrixMiniJ.
Using SableCC, the goal of phase 1 was to conceive an extension of the MiniJava grammar, write the appropriate grammar and generate a parser that is able to parse well-formed programs. Also, phase 1 features a hack of the generated SableCC output to allow dynamic error recovery that allows to constructively continue parsing in error mode when the parser has encountered an error (i.e. the program isn't well-formed).
MatrixMiniJ Grammar / SableCC Specification File || src, bin, & docs || Test Programs || Documentation
Phase 2 - A Type Checker for MatrixMiniJ.
Now that we have a parser for MatrixMiniJ, the next step is to apply a type checker on the Abstract Syntax Tree generated by the parser. To write this type checker was the goal of phase 2 of this project. This type checker features error reporting for 25 different problems that may occur by putting out more or less similar error messages and reports when an error has occured during type checking.
src, bin, & docs || Test Programs || Documentation
Phase 3 - An Assembler for MatrixMiniJ.
This final stage of the project entailed building the actual byte code, so that MiniJava or MatrixMiniJava programs can be executed in the Java Virtual Machine. This was done, but implementing an assembler, that merely takes the internal representation of the source program and convert it into an internal representation of assembly directives, which can be written to a *.j file and hence be assembled by the Jasmin Java Assembler.
src, bin, & docs || Test Programs || Documentation