Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ehwan/lua_rust
lua syntax parser & interpreter in Rust
https://github.com/ehwan/lua_rust
compiler glr-parsing lalr1 lua rust
Last synced: 6 days ago
JSON representation
lua syntax parser & interpreter in Rust
- Host: GitHub
- URL: https://github.com/ehwan/lua_rust
- Owner: ehwan
- License: apache-2.0
- Created: 2024-09-04T00:46:42.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-26T15:44:54.000Z (4 months ago)
- Last Synced: 2025-02-08T01:00:01.167Z (13 days ago)
- Topics: compiler, glr-parsing, lalr1, lua, rust
- Language: Rust
- Homepage:
- Size: 388 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# lua_rust
[](https://crates.io/crates/lua_ir)
[](https://docs.rs/lua_ir)lua syntax parser & runtime interpreter in Rust
- LALR(1), GLR parser
- syntax referenced from [lua 5.4 reference manual](https://www.lua.org/manual/5.4/manual.html)
- ***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`](https://crates.io/crates/lua_ir) crate to your `Cargo.toml`
```toml
[dependencies]
lua_ir = "..."
``````rust
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
```
or
```
$ cargo run
```
will start lua REPL. Note that this executable is not `cargo publish`ed.