#lua #glr #parser

lua_ir

ir generation for lua_semantics crate

1 unstable release

new 0.1.0 Sep 18, 2024

#1972 in Parser implementations

Download history 100/week @ 2024-09-12

100 downloads per month

MIT/Apache

205KB
5K SLoC

lua_rust

lua syntax parser in Rust

project structure

  • tokenizer: tokenizing lua code string.
  • parser: parsing tokenized lua code into AST.
  • semantics: semantic analysis of generated AST. It generates a Enhanced 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 for lua numeric type
  • diag: enable to_diag() function for ParseError

how to run

$ cargo run <source_file.lua>

will print the pretty-formatted Debug output of the AST ( "{:#?}" )

Dependencies

~2–9MB
~76K SLoC