A modular compiler for MiniJava

Patrik Reppien

AbstractThe purpose of this project has been to provide a motivating and exciting basis for learning about compilers, by enhancing an existing basis. The project consisted of two parts.
The goal of the rst part was to analyse an existing MiniJava-compiler used for teaching purposes and use this analysis to provide a layer of persistence between each internal module of the compiler. Enhancing the compiler to be externally modular in this way makes the compiler more suited for educational purposes, as students would be able to implement a module and have the two missing modules handed out as binary files, resulting in a functional compiler. The challenge in this part of the project has been to provide a layer of persistence which does not require changes within the classes to be persisted, by requiring data to be exposed or annotations on fields. It was decided to implement a custom serializer and a matching deserializer from scratch for maintaining the layer of persistence. This proved to be difficult and many special cases had to be resolved including loss of references, private field, and circular references. The serializer and deserializer ended up being fully functional, and the layer of persistence was implemented successfully. This was successfully tested by using the original compiler to compile a number of test files, which were then compared with the result of compiling the same test files with the enhanced compiler.
The second part of the project concerned implementing a module for the enhanced compiler which was able to generate executable byte code for the new Lego Mindstorms EV3 robot. Documentation for the assembler language was found along with a working assembler which was successfully used to turn a hello world assembler program into a le running on the EV3. The new goal of the EV3 module now became to compile MiniJava into this assembler language, which would then be able to be assembled and executed on the EV3. This assembler language proved to be very dierent from the assembler language compiled to in the rst part of the project. A memory managing system was implemented in the new module along with an Application Programming Interface, allowing the MiniJava language to interact with the special features of the EV3 such as the display. Most existing features of the original back end was also implemented in the new module.
TypeBachelor thesis [Academic thesis]
Year2014
PublisherTechnical University of Denmark, Department of Applied Mathematics and Computer Science
AddressMatematiktorvet, Building 303B, DK-2800 Kgs. Lyngby, Denmark, compute@compute.dtu.dk
SeriesB.Sc.-2014
NoteDTU supervisor: Christian Probst, cwpr@dtu.dk, DTU Compute
Electronic version(s)[pdf]
Publication linkhttp://www.imm.dtu.dk/English.aspx
BibTeX data [bibtex]
IMM Group(s)Computer Science & Engineering