1 unstable release
0.1.0 | Sep 8, 2024 |
---|
#1448 in Parser implementations
188 downloads per month
Used in lua_parser
76KB
2K
SLoC
lua_rust
lua syntax parser in Rust
- Greatly in progress
- LALR(1), GLR parser
- syntax referenced from lua 5.4 reference manual
project structure
tokenizer
: tokenizing lua code stringparser
: parsing tokenized lua code into ASTexec
: executable version of theparser
Cargo Features
32bit
: use 32bit integer and float forlua numeric
typediag
: enableto_diag()
function forParseError
how to run
$ cargo run <source_file.lua>
will print the pretty-formatted Debug
output of the AST ( "{:#?}"
)
lib.rs
:
let source = " <source code here> ";
let tokenizer = Tokenizer::new(source);
// tokenizer itself is a lazy iterator.
for token in tokenizer {
match token {
Ok(token) => {
// do something with token
}
Err(e) => {
print!("Tokenize Error: {}", e);
}
}
}
Dependencies
~0–6.5MB
~37K SLoC