Esper Compiler

Source Code

An assignment in the second year of University for the Compilers module was to create a compiler which is capable of division by zero. An easy way to complete this assignment would be to create a simple calculator. I chose to use this assignment to create my own (basic) programming language. The programming language I created is titled Esper and takes influence from LISP in that it adopts the prefix notation. The target language it produces is C and when compiled the C code compiles into a valid program in which division by zero can be handled.


This compiler (as well as the report I wrote) resulted in a grade of 100% for the coursework, since I had implemented all of the features (albeit basic) of a compiler: Lexical Analysis, Parse Tree Generation, Optimisation and Code Generation. I used the Compiler Generator ANTLR, to help build the lexical analsyer and the parser for the compiler. The parser provided by ANTLR only provided very basic functionality so I had to spend a lot of time getting it to have the functionality I required. The source code for the project is available on my GitHub account here.