Skip to content
A simple programming language targeting LLVM
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Document the constant type May 9, 2018
examples Fix issues parsing indented grammar, tests are green again! Aug 25, 2017
exe Auto format code with stylish Haskell (make pretty) Jun 18, 2018
llvm-examples Fix the sample C code May 9, 2018
runtime Fix Makefile target name and dependencies Aug 21, 2017
src Switch default backend to pretty printer Oct 13, 2018
test Compare LLVM IR by approximate equality Oct 15, 2018
.dir-locals.el Add some emacs config for intero to work with test files Oct 15, 2018
.dockerignore Add examples to container; it is indeed validated in a test :) May 12, 2018
.gitignore Ignore few more generated files Jul 8, 2017
.gitmodules Get rid of the pretty printer Jul 4, 2017
.hindent.yaml Cleanup with hindent Jun 5, 2017
.stylish-haskell.yaml Apply stylish haskell across project Jun 22, 2017
.travis.yml Cache docker builds on travis with push/pull from docker hub May 12, 2018
.watsonrc Limit tags to FIX and TODO Jul 22, 2017
Dockerfile Significantly improve the Dockerfile caching Oct 15, 2018
LICENSE Boilerplate setup May 29, 2017
Makefile Ignore warnings `overriding the module target triple with x86_64-pc-l… Jun 18, 2018
Olifant.cabal Switch default backend to pretty printer Oct 13, 2018
README.md Minor doc improvements and emojis 😀 Oct 15, 2018
Setup.hs Boilerplate setup May 29, 2017
stack.yaml Move the dependency from packages to extra-deps Oct 15, 2018

README.md

Olifant Build Status Docker Repository on Quay

A simple functional language targeting LLVM, WIP

Project is setup with stack

$ git pull https://github.com/jaseemabid/Olifant && cd Olifant
$ stack setup && stack build

See the blog post Lessons learned building a toy compiler for a detailed introduction to the project.

The test coverage isn't great, but has a bunch of good code samples. They run pretty fast 🏎 too.

$ stack test

The README maybe sparse, but there is a lot of inline documentation 📜 in the code; which can be read with Haddock.

$ stack haddock --no-haddock-deps --open

Olifant programs can be compiled to native binaries and executed in one step ⚡.

$ stack exec olifant <<< 'sum 4 5'
$ 9

This is NOT an interpreter, a machine native binary is produced and executed in one step 🎩.

$ file /tmp/cmd.exe
$ /tmp/cmd.exe: Mach-O 64-bit executable x86_64

There are some samples programs in the examples directory - these are real programs used by the test runner so if the tests are , these are guaranteed to work.

The intermediary forms can be exported with additional flags. For example, the output of the parser can be viewed with -p.

$ stack exec olifant -- -p <<< 'sum 4 5'
[ App (Ref
       {rname = "sum", ri = 0, rty = TInt :> (TInt :> TInt), rscope = Extern})
      [Lit (Number 4), Lit (Number 5)]
]

Similarly, Core is exported with -c and the intermediary LLVM IR is exported with -l.

The compiler accepts programs from stdin or takes a file as argument.

$ olifant -l examples/vars.ol
$ file vars.ll
vars.ll: ASCII text

Docker images are automatically built by quay.io as well as by Travis CI as part of automated testing. If you have trouble building the dependencies/libraries locally, try the container.

$ make container
$ docker run -it olifant/olifant

I would LOVE any code contributions. There is a milestone to track priority bugs and features if you are looking for some inspiration.

You can’t perform that action at this time.