A fast lexer and parser for Luau, written in pure Luau.
Lexer.tokenize(source: string): ({Token}, {string})
Returns an array of tokens (and any error messages)
Parser.parse(tokens: {Token}): (ASTNode?, {string})
Returns the AST root node (and any error messages)
Parser.format_node(node: ASTNode, indent: number): string
Formats an AST node for debugging
Input:
local x = 1 + 2 * 3AST:
[1:1->1:19] Program
[1:1->1:19] LocalDecl
[1:7->1:7] Identifier: "x"
[1:11->1:19] BinaryExpr: "+"
[1:11->1:11] NumberLiteral: "1"
[1:15->1:19] BinaryExpr: "*"
[1:15->1:15] NumberLiteral: "2"
[1:19->1:19] NumberLiteral: "3"
Contributions welcome!
MIT License
- Luau - Official Luau language
example.luau- Complex test case demonstrating parser capabilities
Made with ❤️ | Last updated 13/12/2025