21 releases (9 breaking)

new 0.10.1 Mar 7, 2025
0.9.5 Feb 19, 2025
0.7.0 Dec 12, 2024
0.5.0 Nov 12, 2024

#731 in Parser implementations

Download history 106/week @ 2024-11-18 90/week @ 2024-11-25 300/week @ 2024-12-02 160/week @ 2024-12-09 7/week @ 2024-12-16 123/week @ 2025-01-06 119/week @ 2025-01-13 12/week @ 2025-01-20 305/week @ 2025-02-03 284/week @ 2025-02-10 243/week @ 2025-02-17 171/week @ 2025-02-24 171/week @ 2025-03-03

881 downloads per month
Used in 4 crates

MIT license

580KB
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

~8–17MB
~219K SLoC