12 releases (6 breaking)

0.7.0 Dec 12, 2024
0.6.1 Dec 3, 2024
0.5.0 Nov 12, 2024
0.4.0 Nov 5, 2024
0.1.1 Oct 23, 2024

#943 in Parser implementations

Download history 198/week @ 2024-10-18 397/week @ 2024-10-25 172/week @ 2024-11-01 132/week @ 2024-11-08 42/week @ 2024-11-15 101/week @ 2024-11-22 343/week @ 2024-11-29 152/week @ 2024-12-06 48/week @ 2024-12-13

648 downloads per month

MIT license

550KB
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–19MB
~293K SLoC