wip min-ocaml'ish language in C
  • C 63.4%
  • CMake 15.4%
  • Yacc 14%
  • Ragel 5.2%
  • Ruby 2%
Find a file
2017-11-05 11:48:28 +11:00
cmake initial commit 2017-11-05 11:48:28 +11:00
deps initial commit 2017-11-05 11:48:28 +11:00
src initial commit 2017-11-05 11:48:28 +11:00
tools/tree-viz initial commit 2017-11-05 11:48:28 +11:00
.gitignore initial commit 2017-11-05 11:48:28 +11:00
CMakeLists.txt initial commit 2017-11-05 11:48:28 +11:00
lexer.rl initial commit 2017-11-05 11:48:28 +11:00
parser.y initial commit 2017-11-05 11:48:28 +11:00
README.md initial commit 2017-11-05 11:48:28 +11:00
tree.png initial commit 2017-11-05 11:48:28 +11:00

mly

An WIP compiler for a minimal subset of OCaml, written in C. Based heavily on the awesome gocaml.

Uses Ragel for lexing, Lemon for parsing, BDW-GC for garbage collection

So far it is able to parse and type check the following code

let rec fizzbuzz max =
    let rec fb num =
        if num % 15 = 0 then println_str "fizzbuzz" else
        if num % 3  = 0 then println_str "fizz" else
        if num % 5  = 0 then println_str "buzz" else
        println_int num
    in
    let rec go n =
        if n = max then () else
        (fb n; go (n + 1))
    in
    go 1
in
let maxi = 100 in
fizzbuzz maxi

and generate

tree.png

Building

mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER=clang .. 
make