Skip to content
seungha-kimPublic

About

Experimental Lua interpreter written in Rust

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Rua

Open in GitHub Codespaces

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.

Tests

The Lua regression tests live under rabbit_vm/tests/sources/.

  • .lua files are reference scripts that are run with the system lua interpreter and then executed by Rua.
  • .rua files are Rua-native test sources used to validate Rua-specific syntax and runtime behavior.

For example: rabbit_vm/tests/sources/closure_lookup.lua

How to test a specific Lua file

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

Quick Start with Codespaces

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_cli

This will compile the project and start the Rua REPL where you can execute Lua code interactively.

About

Experimental Lua interpreter written in Rust

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages