Implementing a Tiger Compiler

Or more aptly: ML from 0 to 60 in one semester. The semester long compiler project in the Compilers and Interpreters course was arguably the largest, most structured, and diverse programming experience I have had. The course was taught by Richard LeBlanc based on the course as taught by Olin Shivers. The textbook which defined the Tiger language we were compiling was Andrew Appel’s Modern Compiler Implementation in ML.

The project was done in groups of two and we built out the compiler at the grueling pace of about one module every two weeks. We started with the lexer and parser which we built using ML-Lex and ML-Yacc respectively. We then proceeded to do type checking, translation to intermediate representation, instruction selection (MIPS), and data-flow analysis among other things. In the week before our finals, we managed to cap it all off with a serviceable register allocator.

At the end of the semester, it was an extremely satisfying experience to see our Tiger factorial code be compiled into working MIPS instructions and to watch it run. Looking back, it seems to be something of a miracle that we started from scratch and were able to put together such a system in an unfamiliar language in one semester.