Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rlua

A small Lua-like interpreter written in Rust.

Features

  • Arithmetic, variables, assignments, and control flow
  • if/elseif/else blocks
  • while and repeat ... until loops
  • for loops
  • Functions and built-in helpers such as print, tonumber, tostring, abs, floor, and sqrt
  • Tables and indexing
  • break inside loops

Roadmap to approach the original C Lua implementation

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.

Usage

Run a script file:

cargo run -- path/to/script.lua

Run inline code:

cargo run -- -e "return 2 + 3"

Start the REPL:

cargo run -- --repl

Development

Run the test suite:

cargo test

License and Attribution

This project is licensed under the MIT License - see the LICENSE file for details.

Third-Party Code

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.

About

A Rust implementation of a Lua-like interpreter, with a tokenizer, parser, AST, compiler, VM, REPL, and CLI. It supports core Lua-style syntax and features such as loops, conditionals, functions, tables, indexing, and break, while serving as a learning project and a stepping stone toward broader Lua compatibility.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages