Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minoki/lunarml
The Standard ML compiler that produces Lua/JavaScript
https://github.com/minoki/lunarml
lua standard-ml transpiler
Last synced: 4 days ago
JSON representation
The Standard ML compiler that produces Lua/JavaScript
- Host: GitHub
- URL: https://github.com/minoki/lunarml
- Owner: minoki
- License: mit
- Created: 2018-08-03T17:41:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-06T10:38:46.000Z (about 1 month ago)
- Last Synced: 2025-01-29T01:56:11.220Z (9 days ago)
- Topics: lua, standard-ml, transpiler
- Language: Standard ML
- Homepage:
- Size: 6.36 MB
- Stars: 365
- Watchers: 10
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# LunarML
The Standard ML compiler that produces Lua/JavaScript.
The documentation is available at .
## Trying pre-built binaries
Docker image is available.
```
$ docker pull ghcr.io/minoki/lunarml:latest
$ docker run --rm --platform linux/amd64 -v "$(pwd)":/work -w /work ghcr.io/minoki/lunarml:latest lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!
```In case you do not want to use Docker, there are precompiled scripts available in the tarball.
You can use `install-precompiled-lua` target to install `lunarml.lua` which can be run with Lua 5.3/5.4 and LuaFileSystem.```
$ make install-precompiled-lua PREFIX=/opt/lunarml
$ export PATH=/opt/lunarml/bin:$PATH
$ lunarml compile example/hello.sml
```You can use `install-precompiled-node` target to install `lunarml.mjs` to be run with Node.js.
```
$ make install-precompiled-node PREFIX=/opt/lunarml
$ export PATH=/opt/lunarml/bin:$PATH
$ lunarml compile example/hello.sml
```Warning: Script-compiled LunarML is slow. Use native binary for serious use.
## Building and Installing
You need a recent version of MLton to build the executable, and Lua 5.3+ or recent Node.js to run the compiled script.
```sh-session
$ make
$ make test-lua
$ make test-lua-continuations
$ make test-luajit
$ make test-nodejs
$ make test-nodejs-cps
$ bin/lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!
```You can install the built binary with `make install`:
```
$ make install PREFIX=/opt/lunarml
$ export PATH="/opt/lunarml/bin:$PATH"
$ lunarml compile example/hello.sml
```Alternatively, you can use Docker to build and run LunarML.
```sh-session
$ docker build --platform linux/amd64 -f package/docker/Dockerfile -t lunarml:0.2.1 .
$ docker run --rm -v "$(pwd)":/work -w /work --platform linux/amd64 lunarml:0.2.1 lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!
```## Usage
```
lunarml compile [options] input.(sml|mlb)
```Subcommands:
* `compile`: Compile a program.
* `help`: Show help.
* `version`: Show version information.Targets:
* Lua
* `--lua` (default): Targets Lua 5.3+.
* `--lua-continuations`: Targets Lua 5.3+. Supports one-shot delimited continuations. Also, supports deeply nested `handle`.
* `--luajit`: Targets LuaJIT.
* JavaScript (ES2020+)
* `--nodejs`: Produces a JavaScript program for Node.js. The default extension is `.mjs`.
* `--nodejs-cps`: Produces a JavaScript program for Node.js (CPS mode; supports delimited continuations). The default extension is `.mjs`.Output type:
* `--exe` (default): Produces Lua/JavaScript program.
* `--lib`: Produces a Lua/JavaScript module.## Features
* Full SML '97 language, including signatures and functors
* Note that some features conform to Successor ML rather than SML '97.
* Successor ML features
* Other language extensions
* A subset of SML Basis Library
* ML Basis system for multi-file project
* Interface to Lua
* Interface to JavaScript
* Delimited continuations
* Other libraries