#lua #interpreter #compiler #syntax-error

bin+lib luallaby

Work in progress A pure-Rust Lua interpreter/compiler

4 releases

0.1.0 Feb 15, 2024
0.1.0-alpha4 Nov 12, 2023
0.1.0-alpha.3 Feb 1, 2022
0.1.0-alpha.1 Sep 20, 2021
0.0.1 Aug 16, 2021

#495 in Programming languages

MIT license

1MB
29K SLoC

Rust 15K SLoC // 0.0% comments Lua 13K SLoC // 0.1% comments C 2K SLoC // 0.1% comments

luallaby

Crates.io docs.rs Crates.io

This project is a work in progress. Please do not use this (yet) if you need a reasonably fast Lua interpreter.

A Lua compiler and interpreter fully written in Rust. This project aims to provide a fully compliant Lua implementation including interoperability between Lua and Rust.

Things to do and implement

A list of features to be implemented, in somewhat particular order:

  • Full language syntax support
  • Proper error handling with trace+context (not panicking on every problem)
  • Rust-Lua interoperability
  • Standard libraries
    • Basic library
    • Coroutine library
    • Package library
    • String manipulation
    • Basic UTF-8 support
    • Table manipulation
    • Mathematical functions
    • Input and output
    • Operating system facilities
    • Debug facilities
  • Garbage collector
  • Passing the Lua test suite
  • Benchmarks vs other compilers
    • Reasonable performance
  • REPL

Testing

This crate has its own test suite that mainly contains basic unit tests or sanity checks to verify if all parts of the language and standard library are in at least a semi-working condition. These sanity checks can be run with:

cargo test

A copy of the Lua test suite has also been included in this repository. These tests can be run by running them as regular Lua files cargo run -- <file>.lua, the test is considered passed if the output ends with "OK" and the interpreter has returned without error.

The Lua test suite has also been included in the cargo test suite, but has been marked as ignored. To include the Lua test suite with the sanity checks run:

cargo test -- --include-ignored

Usage

TODO:

License

luallaby is distributed under the terms of the MIT license.

See the LICENSE file for more information.

Dependencies

~6–14MB
~177K SLoC