#lua #compiler #mruby #bytecodes

bin+lib lunar-lang

Lunar is a compiler that generate mruby bytecodes from Lua script

1 unstable release

new 0.1.1 May 10, 2025
0.1.0 May 10, 2025

#1 in #mruby

27 downloads per month

BSD-3-Clause

34KB
849 lines

Lunar: Lua is Not A Ruby! lunar-lang at crates.io lunar-lang at docs.rs

Lunar is a compiler intended to allow Lua scripts to be executed in Ruby.

It converts Lua scripts into mruby code and executes them on the mruby VM.

Install

Install the lunar-lang crate published on crates.io. Please note that the crate named lunar is unrelated.

$ cargo install lunar-lang

Usage

$ lunar -h
Lunar: A Lua-to-mruby compiler

Usage: lunar [COMMAND]

Commands:
  compile  Compile a Lua source file to an mruby binary
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

How to Compile Lua Script

$ bat example/hello.lua
bat examples/hello.lua
───────┬──────────────────────────────────────────────────────
        File: examples/hello.lua
───────┼──────────────────────────────────────────────────────
   1   │ for i = 1, 5 do
   2   │     print "hello, world\n"
   3   │ end
───────┴──────────────────────────────────────────────────────

$ lunar compile example/hello.lua
$ mruby example/hello.mrb
hello, world
hello, world
hello, world
hello, world
hello, world

Important Notes

Only very basic Lua features are supported. There is no guarantee that all Lua syntax and features will be supported in the future.

For now, it's just a toy program :)

License

Please see LICENSE.

Dependencies

~2MB
~32K SLoC