mlml is a self-hosted toy compiler for a tiny subset of OCaml.
a detailed description can be found in my blog post (in Japanese): 自作OCamlコンパイラでセルフホストした - molecular coordinates
- basic arithmetic
- mutual recursion
- pattern matching
- structual comparison
- primitive types
- formatted output with
- dune-like bundler
- type checker & type inference
mlml is self-hosted. i.e. mlml can compile itself.
To obtain build artifacts, pass a path to local directory as below. You will see compiled binaries under
mkdir self_host ./dev/exec.sh ./dev/self_host.sh ./self_host
externaldefinitions are only available for functions
- all modules and paths are statically-resolved
- all custom oeprators are left-associative
functionkeyword does not make an expression
If you have docker installed in your system, simply run
to start the development.
You can run tests manually by running the following command:
./dev/exec.sh dune runtest
The code and algorithm in parser and lexer is strongly inspired by ushitora-anqou/aqaml