Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Toy compiler for OCaml Meetup
OCaml
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Makefile
OCamlMakefile
README
compiler.ml
compiler.mli
dsl.ml
dsl.mli
license.txt
main.ml

README

Here's toy language for 32-bit float computations in OCaml.

For example, if you want to compute the n'th harmonic number, you could encode this as:
    let harmonic : compiled_fn = 
      compile { 
        name ="harmonic";
        inputs = ["n"];
        body = Sum("i", Num 1.0, Var "n", Div(Num 1.0, Var "i"));
      }

Your function gets compiled to native code using LLVM. You can then call 'harmonic' like this:
    run harmonic [10.0] 

Don't use this compiler in a space vehicle.  

Do use it to learn about LLVM. 

Cheers, 
Alex
Something went wrong with that request. Please try again.