The Lua programming language, implemented in Rust.
The code is primarily grouped into three modules:
compilerdeals with parsing lua code and converting it into bytecode.lexerconverts Lua source code into tokens.parserconverts those tokens into bytecode.exp_descandtokenare type definitions.
vmis the largest module. It deals with actually evaluating lua code, and the Rust API.vmitself holds the core functionality of the interpreter.framedeals with evaluating bytecode.lua_valdefines the type for values in the VM.objectdeals with garbage collection.tableimplements Lua tables.
lua_stdis where any functions in the lua standard library are implemented.- Other modules:
errordefines theErrortype used throughout the crate.instrdefines the VM's instruction set.libandmainare the basic entrypoints for the library/interpreter.
The goals, in rough order of priority, are:
- Basic comparisons and equality
-
and/orexpressions with proper short-circuiting - Basic strings
-
if/else/elseif -
whileandrepeat ... untilloops - Local variables with proper scoping
- Numeric
forloops - Multiple assignment
- Single-line comments
- Function calls
- Function definition
- Tables
- Garbage Collection
- Full table literals
- Error when line starts with left paren and parses as function call
- Multiple return values
-
breakandcontinue - Interned strings
- Unparenthesized function calls
- Better error messages
- Closures
- Lua's
nextfunction - Generic
forloops - Metatables
- Separate array part of tables for integer keys
- Lua's standard library
- A Rust API to parallel Lua's C API
- Coroutines
- Multi-line comments
- Use actual bytecode with variable-length instructions
- Separate
luacexecutable
Like the real Lua, this project currently has zero dependencies.
Just run cargo run in the root to launch the interpreter.
There are a few environment options which enable debug features.
These are all disabled by default.
To enable an option, just set it in the environment before compiling
(e.g. export LUA_DEBUG_VM=1; cargo build).
For details on a debug option, look in the corresponding module.
The options are:
LUA_DEBUG_PARSERLUA_DEBUG_VMLUA_DEBUG_GC