This is an implementation of IMP compiler in Haskell programming language. It uses LLVM as compiler backend. Megaparsec is used for parsing.
The programming language is specified in this document http://gcmuganda.faculty.noctrl.edu/classes/Spring12/306/Imp.pdf.
This work is inspired by Hakell LLVM Tutorial by Stephen Diehl.
It is recommended to use stack to build the program:
% stack build
After this IMP programs can be compiled by running:
% stack exec -- impc test/examples/hello.imp
% ./hello
Hello World!
This runs cc
. To specify a different compiler, use --cc
command line option
or CC
environment variable.
The language has several extensions compared to the original specification. All of the extensions are taken from Ada:
-
String literals can have embedded quotation marks by repeating them twice.
-
If expressions can have additional
elsif
parts. -
Function and procedure arguments can have
in
,out
, andin out
modes.