Full Moon
Full Moon is a lossless parser for Lua, supporting Lua 5.1, 5.2, 5.3, 5.4, and Luau. Unlike traditional parsers, Full Moon preserves every detail of your source code including comments, whitespace, and style choices.What Makes Full Moon “Lossless”?
With Full Moon, you can:- Parse Lua code into an Abstract Syntax Tree (AST)
- Modify the AST programmatically
- Convert it back to valid Lua code exactly as it was written
Why Use Full Moon?
Static Analysis
Build tools like linters and code quality checkers similar to Luacheck or rust-clippy
Code Formatting
Create automatic code formatters that respect the original structure, similar to rustfmt or Prettier
Code Refactoring
Perform mass code transformations and refactoring operations similar to jscodeshift
Language Tooling
Build LSP servers, type checkers, and other language tools for Lua development
Key Features
Multi-Version Support
Multi-Version Support
Full Moon supports multiple Lua versions through feature flags:
- Lua 5.1 (default)
- Lua 5.2
- Lua 5.3
- Lua 5.4
- Luau (Roblox’s Lua dialect)
- LuaJIT
- CfxLua (FiveM’s Lua runtime)
Complete AST Access
Complete AST Access
Access every part of your code through a comprehensive AST API:
- Statements and expressions
- Token references with position information
- Trivia (whitespace and comments)
- Function calls, assignments, and control flow
Visitor Pattern
Visitor Pattern
Traverse and transform ASTs using the powerful visitor pattern:
Visitortrait for read-only traversalVisitorMuttrait for mutable transformations- Automatic traversal of all child nodes
Error Recovery
Error Recovery
Full Moon provides robust error handling:
- Detailed error messages with position information
- Partial AST generation for error recovery
- Both strict and fallible parsing modes
Quick Example
Here’s a taste of what Full Moon can do:Next Steps
Installation
Add Full Moon to your Rust project
Quick Start
Parse your first Lua file in minutes