Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coord-e/mlml
self-hosted compiler for a subset of OCaml
https://github.com/coord-e/mlml
compiler ocaml self-hosted
Last synced: 9 days ago
JSON representation
self-hosted compiler for a subset of OCaml
- Host: GitHub
- URL: https://github.com/coord-e/mlml
- Owner: coord-e
- License: mit
- Created: 2019-04-04T07:24:20.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2019-06-12T13:36:31.000Z (over 5 years ago)
- Last Synced: 2024-10-12T05:10:22.116Z (25 days ago)
- Topics: compiler, ocaml, self-hosted
- Language: OCaml
- Homepage:
- Size: 723 KB
- Stars: 50
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mlml
[![Build Status](https://travis-ci.com/coord-e/mlml.svg?branch=develop)](https://travis-ci.com/coord-e/mlml)
[![Coverage Status](https://coveralls.io/repos/github/coord-e/mlml/badge.svg)](https://coveralls.io/github/coord-e/mlml)
![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/coorde/mlml.svg)
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/coorde/mlml.svg)
[![MicroBadger Image](https://images.microbadger.com/badges/image/coorde/mlml.svg)](https://microbadger.com/images/coorde/mlml)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](https://coordination.hatenablog.com/entry/2019/05/23/212720)
## roadmap
- [x] basic arithmetic
- [x] variables
- [x] if-then-else
- [x] functions
- [x] recursion
- [x] mutual recursion
- [x] closure
- [x] currying
- [x] tuples
- [x] variants
- [x] records
- [x] pattern matching
- [x] structual comparison
- [x] primitive types
- [x] string
- [x] list
- [x] bytes
- [x] array
- [x] formatted output with `Printf`
- [x] modules
- [x] definition
- [x] aliases
- [x] `open`
- [x] dune-like bundler
- [x] **self-hosting!**
- [ ] exceptions
- [ ] type checker & type inference## self hosting
mlml is self-hosted. i.e. mlml can compile itself.
```shell
./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`.
```shell
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
```shell
./dev/start.sh
```to start the development.
You can run tests manually by running the following command:
```shell
./dev/exec.sh dune runtest
```## thanks
The code and algorithm in parser and lexer is strongly inspired by [ushitora-anqou/aqaml](https://github.com/ushitora-anqou/aqaml)