luaparser is a Python library for parsing Lua code into an Abstract Syntax Tree (AST). It provides a programmatic interface to analyze, manipulate, and generate Lua code. The current version is 4.0.0, and it maintains an active, though irregular, release cadence addressing bugs and adding features.
pip install luaparserVerified import paths — ran on the pinned version, not inferred.
Parses a simple Lua script string and prints its Abstract Syntax Tree (AST) representation to the console.
Ensure all Lua source files are saved with UTF-8 encoding. If not possible, pre-read the file with its correct encoding and pass the string to `parse()`.
Access the `raw` attribute of `String` nodes for the unescaped string value. Example: `string_node.raw`.
Review Lua code for strict grammar compliance. The `ParseError` message should indicate the location of the offending token.
Update AST traversal logic to check the type of `Index.idx`. If it's a `Name` node, access `Index.idx.id` for the index name. If it's a `String` node (for older versions or specific cases), use `Index.idx.raw` (for 4.0.0+) or `Index.idx.value` (for 3.x).
After parsing, call `print(ast.show())` to see the AST representation.
No dependency data recorded yet.