#lua #glr #ast #parser

lua_semantics

semantic analysis and enhanced AST converter for lua_parser crate

9 releases (breaking)

0.8.0 Oct 25, 2024
0.7.0 Oct 24, 2024
0.6.0 Oct 24, 2024
0.5.0 Oct 21, 2024
0.1.0 Sep 16, 2024

#2263 in Parser implementations

Download history 142/week @ 2024-09-10 211/week @ 2024-09-17 28/week @ 2024-09-24 125/week @ 2024-10-01 281/week @ 2024-10-08 195/week @ 2024-10-15 399/week @ 2024-10-22 19/week @ 2024-10-29 19/week @ 2024-11-05

766 downloads per month
Used in lua_ir

MIT/Apache

410KB
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() )?;

Simply running

$ cargo run <source_file.lua>

or

$ cargo run

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

Dependencies

~1.9–9MB
~71K SLoC