The PyLit Compiler:

This compiler takes a highly stripped-down subset of Python (including
arithmetic, if-else, for, and while statements,
and user-defined functions) and compiles it into LLVM IR. It was coded in OCaml.

It needs the OCaml llvm library, which is most easily installed through opam.

Install LLVM and its development libraries, the m4 macro preprocessor,
and opam, then use opam to install llvm.

The version of the OCaml llvm library must match the version of the LLVM
system installed on your system.

The stock C compiler compiles functions.o.  testall.sh runs the PyLit
executable on each testcase (.pyl file) to produce a .ll file, invokes
"llc" (the LLVM compiler) to produce a .s (assembly) file, then
invokes "cc" (the stock C compiler) to assemble the .s file, link in
functions.o, and generate an executable.  See testall.sh for details.
----------
If you get errors about llvm.analysis not being found, it's probably
because opam enviroment information is missing.  Either run

eval $(opam config env)

or run ocamlbuild like this:

opam config exec -- ocamlbuild <args>

------------------------------
Installation under Ubuntu 16.04

LLVM 3.8 is the default under 16.04. Install the matching version of
the OCaml LLVM bindings:

sudo apt install ocaml llvm llvm-runtime m4 opam
opam init
opam install llvm.3.8
eval `opam config env`

make
./testall.sh

------------------------------
To run and test:

$ make
ocamlbuild -use-ocamlfind -pkgs llvm,llvm.analysis -cflags -w,+a-4 PyLit.native
Finished, 22 targets (0 cached) in 00:00:01.
cc    -c -o functions.o functions.c
$ ./testall.sh
test-arith1...OK
test-arith2...OK
test-arith3...OK
test-fib...OK
...
fail-while1...OK
fail-while2...OK
