11 releases (breaking)

0.9.1 Oct 26, 2024
0.8.0 Oct 24, 2024

#338 in Programming languages

Download history 462/week @ 2024-09-04 112/week @ 2024-09-11 35/week @ 2024-09-18 35/week @ 2024-09-25 116/week @ 2024-10-02 197/week @ 2024-10-09 157/week @ 2024-10-16 405/week @ 2024-10-23 29/week @ 2024-10-30 15/week @ 2024-11-06

616 downloads per month
Used in 2 crates

MIT/Apache

435KB
11K SLoC

lua_rust

crates.io docs.rs

lua syntax parser & runtime interpreter in Rust

  • LALR(1), GLR parser
  • syntax referenced from lua 5.4 reference manual
  • Greatly in progress
    • grammar fully implemented
    • std library barely implemented

Cargo Features

  • 32bit: use 32bit integer and float for lua numeric type

How to use

As Library

add lua_ir crate to your Cargo.toml

[dependencies]
lua_ir = "..."
let mut env = lua_ir::LuaEnv::new();

env.eval_chunk( b"var_hello = 'Hello'" )?;
env.eval_chunk( b"var_world = 'World'" )?;
env.eval_chunk( b"print( var_hello .. ', ' .. var_world .. '!' )" )?;
// Hello, World!

let hello_value = env.get_global( "var_hello" )?;
let world_value = env.get_global( "var_world" )?;
env.set_global( "var_hello", 10.into() )?;

As REPL interpreter

clone this repository and simply run

$ cargo run <source_file.lua>

or

$ cargo run

will start lua REPL. Note that this executable is not cargo published.

Dependencies

~1.8–8.5MB
~68K SLoC