The Lua programming language, implemented in Rust.
The Lua programming language, implemented in Rust.
The code is primarily grouped into three modules:
compiler
deals with parsing lua code and converting it into bytecode.
lexer
converts Lua source code into tokens.parser
converts those tokens into bytecode.exp_desc
and token
are type definitions.vm
is the largest module. It deals with actually evaluating lua code, and
the Rust API.
vm
itself holds the core functionality of the interpreter.frame
deals with evaluating bytecode.lua_val
defines the type for values in the VM.object
deals with garbage collection.table
implements Lua tables.lua_std
is where any functions in the lua standard library are implemented.error
defines the Error
type used throughout the crate.instr
defines the VM's instruction set.lib
and main
are the basic entrypoints for the library/interpreter.The goals, in rough order of priority, are:
and
/or
expressions with proper short-circuitingif
/else
/elseif
while
and repeat ... until
loopsfor
loopsbreak
and continue
next
functionfor
loopsluac
executableLike 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_PARSER
LUA_DEBUG_VM
LUA_DEBUG_GC