24 releases (9 breaking)

new 0.10.4 Apr 18, 2025
0.10.2 Mar 21, 2025
0.7.0 Dec 12, 2024
0.5.0 Nov 12, 2024

#410 in Parser implementations

Download history 130/week @ 2025-01-07 117/week @ 2025-01-14 7/week @ 2025-01-21 67/week @ 2025-01-28 298/week @ 2025-02-04 232/week @ 2025-02-11 245/week @ 2025-02-18 181/week @ 2025-02-25 176/week @ 2025-03-04 66/week @ 2025-03-11 178/week @ 2025-03-18 51/week @ 2025-03-25 188/week @ 2025-04-01 78/week @ 2025-04-08 203/week @ 2025-04-15

545 downloads per month
Used in 4 crates

MIT license

600KB
16K SLoC

EmmyLua-Parser

EmmyLua-Parser is a parser for Lua5.1, Lua5.2, Lua5.3, Lua5.4, and LuaJIT and also supports EmmyLua/LuaCats annotations. Its purpose is to generate AST and CST from the parsed code for further analysis.

Internationalization (i18n) Support

This crate supports multiple languages, defaulting to English (en-US). Users can optionally initialize i18n to set a different language.

Features

  • Lossless syntax tree generation
  • Easy-to-use API based on the rowan library
  • Support for Lua5.1, Lua5.2, Lua5.3, Lua5.4 and LuaJIT
  • Support for EmmyLua/LuaCats annotations
  • Ability to parse code with syntax errors

Usage

let code = r#"
    local a = 1
    local b = 2
    print(a + b)
"#;
let tree = LuaParser::parse(code, ParserConfig::default());

let chunk = tree.get_chunk_node();
for node in chunk.descendants::<LuaAst>() {
    println!("{:?}", node);
}

Dependencies

~7–16MB
~212K SLoC