A small Lua-like interpreter written in Rust.
- Arithmetic, variables, assignments, and control flow
if/elseif/elseblockswhileandrepeat ... untilloopsforloops- Functions and built-in helpers such as
print,tonumber,tostring,abs,floor, andsqrt - Tables and indexing
breakinside loops
The current Rust interpreter already covers the core syntax and runtime for small Lua-like programs, but to become comparable to the reference implementation in src/linit.c and the surrounding Lua 5.5.0 C sources, the next milestones are:
- Full standard-library parity with the base, package, coroutine, debug, io, os, string, table, and utf8 libraries
- Proper Lua semantics for multiple returns, varargs (
...), closures with upvalues, and lexical scoping - Metatables and metamethods such as
__index,__newindex,__add, and__call - More faithful table behavior, including generic table operations and better handling of key/value semantics
- Robust error reporting, stack traces, debug hooks, and garbage collection support
- Compatibility with larger real-world Lua programs, including module loading and
require
These are the main areas where the Rust version still differs from the original C implementation.
Run a script file:
cargo run -- path/to/script.luaRun inline code:
cargo run -- -e "return 2 + 3"Start the REPL:
cargo run -- --replRun the test suite:
cargo testThis project is licensed under the MIT License - see the LICENSE file for details.
This repository contains the official, unmodified source code of the Lua programming language within the lua5 directory for reference purposes.
- Lua License: MIT License
- Copyright: © 1994–2026 Lua.org, PUC-Rio.
- The original Lua license text and copyright notices have been preserved entirely within that directory. You can view the full license terms in
/lua5/LICENSE.