Rua is a Lua interpreter and virtual machine written in Rust. It implements the language pipeline from tokenizing and parsing Lua source code to compiling and executing custom bytecode. The runtime includes Lua features such as closures, tables, metatables, coroutines, garbage collection, and standard libraries.
The project is organized as a Cargo workspace with the following crates:
lua_parser: Tokenizes Lua source, builds a concrete syntax tree, and refines it into the project AST.rabbit_ast: Defines the abstract syntax tree used by the compiler.rabbit_code: Defines bytecode instructions, compiled functions, and shared source-code metadata.rabbit_compiler: Resolves identifiers and jumps, then compiles the AST into bytecode.rabbit_vm: Executes bytecode and implements runtime values, tables, functions, coroutines, garbage collection, and built-in libraries.rabbit_proc_macro_impl: Implements code generation for Rust functions and methods exposed to the VM.rabbit_proc_macro: Exposes the native-function procedural macros.rabbit_cli: Provides file execution and an interactive REPL.
The Lua regression tests live under rabbit_vm/tests/sources/.
.luafiles are reference scripts that are run with the systemluainterpreter and then executed by Rua..ruafiles are Rua-native test sources used to validate Rua-specific syntax and runtime behavior.
For example: rabbit_vm/tests/sources/closure_lookup.lua
cargo test run_{file_name_without_ext} -- --exact
For example, if the test file name is closure_lookup.lua, then run:
cargo test run_closure_lookup -- --exact
Click the badge above to open Rua in GitHub Codespaces. Once the environment is ready, you can launch the interactive REPL:
cargo run --release --bin rabbit_cliThis will compile the project and start the Rua REPL where you can execute Lua code interactively.