Skip to content
self-hosted compiler for a subset of OCaml
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Change: Dont use open to specify dependency properly in mlml May 20, 2019
dev Fix: Dev: Fix self-hosting script May 23, 2019
mlml Change: Codegen: Replace fun _ -> () with ignore May 24, 2019
stdlib
test
.dockerignore Add: Add missing dockerignore Apr 13, 2019
.gitignore Add: Add gitignore Apr 4, 2019
.ocamlformat Change: Format code with ocamlformat Apr 5, 2019
.travis.yml Fix: Make init.sh executable and execute to set $0 as expected May 2, 2019
Dockerfile Fix: Fix dockerfile build Apr 15, 2019
LICENSE
README.md Fix: Fix some words in README Jun 12, 2019
dune-project

README.md

mlml

Build Status Coverage Status Docker Cloud Automated build Docker Cloud Build Status MicroBadger Image

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

roadmap

  • basic arithmetic
  • variables
  • if-then-else
  • functions
    • recursion
    • mutual recursion
    • closure
    • currying
  • tuples
  • variants
  • records
  • pattern matching
  • structual comparison
  • primitive types
    • string
    • list
    • bytes
    • array
  • formatted output with Printf
  • modules
    • definition
    • aliases
    • open
    • dune-like bundler
  • self-hosting!
  • exceptions
  • type checker & type inference

self hosting

mlml is self-hosted. i.e. mlml can compile itself.

./dev/exec.sh ./dev/self_host.sh

To obtain build artifacts, pass a path to local directory as below. You will see compiled binaries under ./self_host.

mkdir self_host
./dev/exec.sh ./dev/self_host.sh ./self_host

limitations

  • external definitions are only available for functions
  • all modules and paths are statically-resolved
  • all custom oeprators are left-associative
  • function keyword does not make an expression

development

If you have docker installed in your system, simply run

./dev/start.sh

to start the development.

You can run tests manually by running the following command:

./dev/exec.sh dune runtest

thanks

The code and algorithm in parser and lexer is strongly inspired by ushitora-anqou/aqaml

You can’t perform that action at this time.