19 releases (8 breaking)

new 0.9.5 Feb 19, 2025
0.9.0 Jan 15, 2025
0.7.0 Dec 12, 2024
0.5.0 Nov 12, 2024

#775 in Parser implementations

Download history 254/week @ 2024-10-29 144/week @ 2024-11-05 137/week @ 2024-11-12 106/week @ 2024-11-19 180/week @ 2024-11-26 208/week @ 2024-12-03 160/week @ 2024-12-10 5/week @ 2024-12-17 130/week @ 2025-01-07 117/week @ 2025-01-14 7/week @ 2025-01-21 67/week @ 2025-01-28 301/week @ 2025-02-04 460/week @ 2025-02-11

840 downloads per month
Used in 4 crates

MIT license

575KB
15K 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

~9–20MB
~306K SLoC