--- id: luaparser version: "4.1.0" license: MIT license_treatment: permissive maintenance: active --- # luaparser — A lua parser in Python License: permissive · Maintenance: active · Downloads: 112.2K/mo ## What it is and what it does Luaparser is a Python library that reads Lua source code and builds an abstract syntax tree (AST), letting you programmatically inspect and manipulate Lua code structure. It ships both as a library for Python code and as a command-line tool. The parser supports Lua 5.3 and 5.4 grammar versions and can output AST data as JSON, XML, or pretty-printed text. You can walk the entire AST to find specific node types, use a visitor pattern to process nodes, or construct AST objects directly in Python and regenerate Lua source code from them (though that feature is marked experimental). The library depends on antlr4-python3-runtime for parsing and multimethod for method dispatch. Use it for: - Analyze Lua code structure in a static analysis or linting tool. - Extract function definitions, variable names, or call patterns from Lua scripts. - Transform or refactor Lua code by manipulating its AST and regenerating source. - Build development tools that need to understand Lua syntax without executing it. - Convert Lua code to other formats or intermediate representations via AST inspection. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses Lua source code into an abstract syntax tree (AST) and provides tools to traverse, analyze, and regenerate Lua code from the AST. Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a clear problem for anyone needing to parse or analyze Lua code in Python. No known vulnerabilities. The only caveat is that code regeneration is experimental, so rely on that feature cautiously. ## Install pip install luaparser uv add luaparser poetry add luaparser ## Installing luaparser Before you install: Low friction installation with a pure Python wheel and only two runtime dependencies (antlr4-python3-runtime and multimethod). Actively maintained with a recent release. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects. Quickstart: pip install luaparser from luaparser import ast src = "local x = 42" tree = ast.parse(src) print(ast.to_pretty_str(tree)) Verify before relying: - Whether the parser handles all Lua 5.3 and 5.4 grammar features completely or if there are known gaps. - Performance characteristics when parsing large Lua files or complex nested structures. - Stability of the experimental Lua code regeneration feature (ast.to_lua_source). ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 112.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags lua parser python, lua ast builder, parse lua code, lua syntax analysis, lua code to ast, lua ast visitor, lua grammar parser, parser, ast, lua [View on SkillFed](https://skillfed.io/packages/luaparser) · [View on PyPI](https://pypi.org/project/luaparser/)