Toy Compiler in Haskell

 GitHub eXPL Docs


This is a toy compiler for ExpL(Experimental Language) done as part of the Compiler Laboratory course I took in college.

The compiler was written in Haskell using the Alex lexer and Happy parser.

It compiles the source language ExpL(spec here and here) to the low-level XSM (eXperimental String Machine) machine code (ABI here) which runs on ExpOS (Experimental Operating System) a simulator for which can be found here.

Personal Notes

This was my first delve into functional programming. It was a really different way of looking at problems and implementing a compiler in a purely functional language like Haskell was quite fun.

There were quite a few hiccups along the way for sure. I found it quite hard to wrap my head around the State Monad and struggled quite a bit in the late stage implementations of the parser. Was relatively smooth once I had that understanding though. (special mention to my college senior Farseen for the suggestion and subsequent help)

* Pictured above is my cat Cookie being my rubber duck throughout the implementation of this. (also a throwback to my dual monitor setup days)