Skip to content

A small compiler written for a subset of the C language, targeting the MIPS ISA. The compiler is written in Java, and focuses on the lexing, parsing, semantic analysis and code generation phases. Included in this repository is also an LLVM pass written in C++, which performs liveness analysis and dead code elimination.

Notifications You must be signed in to change notification settings

kimbethstonehouse/compiler-project

Repository files navigation

Compiler

Results

This coursework attained a mark of 86% (A2) for the Compiling Techniques course. The scoreboard runs a series of hidden test programs on this compiler about twice a day. View my results here.

About

The aim of this assignment was to write a compiler for a subset of the C language, targeting the MIPS ISA. The compiler is written in Java, and focuses on the lexing, parsing, semantic analysis and code generation phases. It also involved writing an LLVM pass in C++ to perform liveness analysis and dead code elimination.

Building the project

In order to build the project you must have Ant installed. Your local copy of the repository contains an Ant build file (build.xml). If you are using an IDE, then you can import the build file. Otherwise, you can build the project from the commandline by typing:

$ ant build

This command outputs your compiler in a directory called bin within the project structure. Thereafter, you can run your compiler from the commandline by typing:

$ java -cp bin Main

The parameter cp instructs the Java Runtime to include the local directory bin when it looks for class files.

You can find a series of tests in the tests folder. To run the lexer on one of them, you can type:

$ java -cp bin Main -lexer tests/fibonacci.c dummy.out

You can clean the bin directory by typing:

$ ant clean

This command effectively deletes the bin directory.

About

A small compiler written for a subset of the C language, targeting the MIPS ISA. The compiler is written in Java, and focuses on the lexing, parsing, semantic analysis and code generation phases. Included in this repository is also an LLVM pass written in C++, which performs liveness analysis and dead code elimination.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published