2 unstable releases
new 0.2.0 | Sep 18, 2024 |
---|---|
0.1.0 | Sep 16, 2024 |
#1381 in Parser implementations
137 downloads per month
375KB
10K
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 string.parser
: parsing tokenized lua code into AST.semantics
: semantic analysis of generated AST. It generates aEnhanced AST
which contains more information than the original AST.- stack offset of local variables
- scope checking for
return
,break
,goto
,label
, ... - split function definition into separated Chunks
lua_ir
: generate IRs from enhanced AST, and run on virtual machine.
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
:
// type of `lua_parser::Block`
let block = lua_parser::parse_str( ... )?;
// semantic analysis, and generate enhanced AST for later use.
let enhanced_ast = lua_semantics::process(block)?;
Dependencies
~1–8MB
~53K SLoC