Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Lua
  3. lua-parser

lua-parser

MITLuav1.0.4

A Lua 5.3 parser that generates a Metalua-compatible AST using LPegLabel for improved error messages.

GitHubGitHub
209 stars32 forks0 contributors

What is lua-parser?

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.

Target Audience

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.

Value Proposition

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.

Overview

A Lua 5.3 parser written with LPegLabel

Use Cases

Best For

  • Building Lua linters or static analysis tools
  • Creating custom code formatters for Lua 5.3
  • Developing IDE plugins with syntax error highlighting
  • Implementing source code transformation utilities
  • Integrating Lua parsing into larger language toolchains
  • Educational tools for teaching Lua syntax and AST structure

Not Ideal For

  • Projects targeting Lua versions other than 5.3, such as Lua 5.1/5.2 or Lua 5.4
  • Applications where parsing speed is critical and detailed error messages are unnecessary overhead
  • Teams seeking a parser with zero external dependencies for simplified deployment
  • Tools that require a custom AST format incompatible with Metalua's representation

Pros & Cons

Pros

Enhanced Error Reporting

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'.

Metalua-Compatible AST

Produces an AST in a format similar to Metalua, facilitating integration with existing Lua analysis and transformation tools in the ecosystem.

Built-in Pretty Printer

Includes a module to convert AST back to a readable string representation or print it directly, useful for debugging and code generation workflows.

Lightweight and Focused

Relies on LPegLabel for parsing without bloated dependencies, making it suitable for embedding in larger toolchains while maintaining reliability.

Cons

Lua Version Lock-in

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.

External Dependency Burden

Requires LPegLabel >=1.6.0, which adds an external library dependency that must be installed and maintained separately.

Niche AST Format

The Metalua-compatible AST may not align with all Lua tooling, potentially requiring additional conversion layers for integration with some systems.

Performance Trade-offs

The use of LPegLabel for detailed error reporting introduces parsing overhead compared to minimal, faster parsers that prioritize speed over diagnostics.

Frequently Asked Questions

Quick Stats

Stars209
Forks32
Contributors0
Open Issues2
Last commit4 months ago
CreatedSince 2014

Tags

#language-tooling#lua#ast#syntax-analysis#parser

Built With

L
Lua

Included in

Lua4.5k
Auto-fetched 1 day ago

Related Projects

luacheckluacheck

A tool for linting and static analysis of Lua code.

Stars2,035
Forks334
Last commit3 years ago
Typed LuaTyped Lua

An Optional Type System for Lua

Stars587
Forks48
Last commit6 years ago
MetaluaMetalua

The metalua programming language

Stars369
Forks63
Last commit2 years ago
LuaMinifyLuaMinify

Lua source code minifier.

Stars271
Forks51
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub