A Lua 5.3 parser that generates a Metalua-compatible AST using LPegLabel for improved error messages.
lua-parser is a Lua 5.3 parser that converts Lua source code into an Abstract Syntax Tree (AST) using the LPegLabel parsing library. It solves the problem of needing a reliable, error-aware parser for building Lua language tools, linters, or code analyzers by providing detailed syntax error messages and a structured AST output.
Lua developers and tool builders who need to programmatically analyze, transform, or validate Lua 5.3 code, such as those creating IDEs, static analyzers, or code formatters.
Developers choose lua-parser for its integration with LPegLabel, which offers superior error reporting over traditional parsers, and its Metalua-compatible AST format, which ensures compatibility with a range of existing Lua ecosystem tools.
A Lua 5.3 parser written with LPegLabel
Uses LPegLabel to generate specific syntax error messages with file context and expected tokens, as shown in the README example with 'expected 'end' to close the for loop'.
Produces an AST in a format similar to Metalua, facilitating integration with existing Lua analysis and transformation tools in the ecosystem.
Includes a module to convert AST back to a readable string representation or print it directly, useful for debugging and code generation workflows.
Relies on LPegLabel for parsing without bloated dependencies, making it suitable for embedding in larger toolchains while maintaining reliability.
Specifically supports only Lua 5.3, so it cannot parse code from older versions like 5.1/5.2 or newer ones like 5.4 without modifications.
Requires LPegLabel >=1.6.0, which adds an external library dependency that must be installed and maintained separately.
The Metalua-compatible AST may not align with all Lua tooling, potentially requiring additional conversion layers for integration with some systems.
The use of LPegLabel for detailed error reporting introduces parsing overhead compared to minimal, faster parsers that prioritize speed over diagnostics.
A tool for linting and static analysis of Lua code.
An Optional Type System for Lua
The metalua programming language
Lua source code minifier.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.