lua_parser

Crates.iolua_parser
lib.rslua_parser
version0.9.1
sourcesrc
created_at2024-09-08 05:06:27.560563
updated_at2024-10-26 15:43:24.923541
descriptionsyntax parser for lua language
homepage
repositoryhttps://github.com/ehwan/lua_rust
max_upload_size
id1367771
size348,726
Taehwan Kim (ehwan)

documentation

README

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.

Commit count: 79

cargo fmt