Skip to main content

Installing Full Moon

Full Moon is available as a Rust crate on crates.io. This guide will walk you through adding it to your project and configuring the feature flags for your target Lua version.

Basic Installation

1

Add Full Moon to Cargo.toml

Add the following line to your Cargo.toml under [dependencies]:
Cargo.toml
[dependencies]
full_moon = "2.1.1"
This installs Full Moon with the default features (Lua 5.1 support with serde serialization).
2

Import in your code

Import Full Moon in your Rust source file:
use full_moon::parse;
3

Parse Lua code

You’re ready to parse Lua code:
let ast = parse("local x = 1")?;

Feature Flags

Full Moon supports multiple Lua versions through Cargo feature flags. By default, only Lua 5.1 is supported.

Available Features

serde

Default: EnabledEnables serialization and deserialization support for AST nodes using serde.
full_moon = { version = "2.1.1", default-features = false }

lua52

Enables Lua 5.2 syntax support including:
  • goto statements
  • Labels
  • ::label:: syntax
full_moon = { version = "2.1.1", features = ["lua52"] }

lua53

Enables Lua 5.3 syntax support (includes lua52 features).
full_moon = { version = "2.1.1", features = ["lua53"] }

lua54

Enables Lua 5.4 syntax support including:
  • To-be-closed variables (<const>, <close>)
  • Attributes
Includes lua53 and lua52 features.
full_moon = { version = "2.1.1", features = ["lua54"] }

luau

Enables Luau (Roblox Lua) syntax support including:
  • Type annotations
  • Compound assignments (+=, -=, etc.)
  • Interpolated strings
  • Generics and type packs
full_moon = { version = "2.1.1", features = ["luau"] }

luajit

Enables LuaJIT-specific syntax support.
full_moon = { version = "2.1.1", features = ["luajit"] }

cfxlua

Enables CfxLua (FiveM) syntax support (includes lua54 features).
full_moon = { version = "2.1.1", features = ["cfxlua"] }

Combining Features

You can enable multiple features simultaneously:
[dependencies]
full_moon = { version = "2.1.1", features = ["lua52", "lua54"] }
When you enable a higher Lua version feature (e.g., lua54), it automatically includes all lower versions (lua53, lua52). You only need to specify the highest version you need.

Version Selection at Runtime

When multiple Lua versions are enabled, Full Moon automatically selects the most complete version. You can also manually specify the version:
use full_moon::{parse_fallible, LuaVersion};

// Manually specify Lua 5.2
let ast_result = parse_fallible(code, LuaVersion::lua52());

// Use the newest available version
let ast_result = parse_fallible(code, LuaVersion::new());

Verifying Installation

Create a simple test to verify Full Moon is working:
src/main.rs
use full_moon::parse;

fn main() {
    match parse("local x = 1 + 2") {
        Ok(ast) => println!("Successfully parsed: {}", ast),
        Err(errors) => eprintln!("Parse errors: {:?}", errors),
    }
}
Run your project:
cargo run
You should see:
Successfully parsed: local x = 1 + 2

Next Steps

Quick Start Guide

Learn how to parse Lua code and traverse the AST

Build docs developers (and LLMs) love