Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.38 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.38 KB

IMP Compiler Implemented in Haskell

Build Status

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.

Building

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.

Extensions

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, and in out modes.