Overview
Loretta supports multiple Lua versions and dialects throughLuaSyntaxOptions. Each preset configures the parser to accept syntax features specific to that Lua version or dialect.
Available Presets
Loretta provides the following built-in presets:- Lua51 - Lua 5.1
- Lua52 - Lua 5.2
- Lua53 - Lua 5.3
- Lua54 - Lua 5.4
- LuaJIT20 - LuaJIT 2.0
- LuaJIT21 - LuaJIT 2.1-beta3
- GMod - Garry’s Mod Lua (GLua)
- Luau - Luau (Roblox Lua)
- FiveM - FiveM Lua
- All - Accepts all syntax features (without integer parsing)
- AllWithIntegers - Accepts all syntax features with integer parsing
Using Presets
Preset Details
Lua 5.1
Baseline Lua version with minimal features:- Basic Lua 5.1 syntax
- Shebang support (
#!/usr/bin/env lua) - Invalid escape sequences accepted (Lua 5.1 bug compatibility)
- Goto statements
- Hexadecimal escapes in strings
- Empty statements
- Bitwise operators
- And many modern features
Lua 5.2
Builds on Lua 5.1:- Goto statements and labels
- Empty statements (bare semicolons)
- Hexadecimal escapes in strings (
\x00) - Hexadecimal float literals
- Whitespace escape (
\z) - Nesting of long strings
Lua 5.3
Builds on Lua 5.2:- Bitwise operators (
&,|,~,<<,>>,~) - Integer division (
//) - Unicode escapes (
\u{XXXX}) - Integer literals (64-bit)
Lua 5.4
Builds on Lua 5.3:- Variable attributes (
<const>,<close>)
LuaJIT 2.0
LuaJIT-specific features:- Based on Lua 5.1 with select Lua 5.2 features
- Goto statements (from Lua 5.2)
- Hexadecimal escapes and floats
- LuaJIT identifier rules (accepts characters >= 0xF7)
- Number suffixes (
LL,ULL,i) - Nesting of long strings
LuaJIT 2.1
Builds on LuaJIT 2.0:- Binary number literals (
0b1010) - Unicode escapes
GMod (Garry’s Mod)
Based on LuaJIT 2.0 with additional features:- C-style comments (
//and/* */) - C-style boolean operators (
&&,||,!,!=) - Continue statement (keyword style)
Luau (Roblox)
Roblox’s Luau dialect:- Type annotations
- Compound assignments (
+=,-=, etc.) - If expressions
- Continue statement (contextual keyword)
- Interpolated strings with backticks
- Underscores in number literals
- Binary number literals
- Floor division
FiveM
Builds on Lua 5.3:- Backtick strings for hash literals (for GTA V natives)
Feature Comparison Table
| Feature | 5.1 | 5.2 | 5.3 | 5.4 | JIT20 | JIT21 | GMod | Luau | FiveM |
|---|---|---|---|---|---|---|---|---|---|
| Goto | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
| Empty statements | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
| Hex escapes | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Hex floats | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
| Bitwise operators | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
| Unicode escapes | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ |
| Floor division | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ |
| Variable attributes | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Binary literals | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ✅ | ❌ |
| C comments | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
| C boolean ops | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
| Continue | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
| Type annotations | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Compound assignment | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
| If expressions | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Interpolated strings | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Hash strings | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
Customizing Syntax Options
You can customize any preset using the.With() method:
Common Customizations
Enable Specific Features
Accept Multiple Dialects
Create Strict Subset
Integer Format Options
Some Lua versions parse integer literals differently:When to Use Which Preset
Use Lua51 when:
- Targeting standard Lua 5.1
- Maximum compatibility with old scripts
- Not using any modern features
Use Lua52/53/54 when:
- Targeting specific official Lua versions
- Need standard Lua features from those versions
- Writing portable Lua code
Use LuaJIT20/21 when:
- Using LuaJIT runtime
- Need LuaJIT-specific features
- Performance is critical
Use GMod when:
- Developing Garry’s Mod addons
- Need C-style comments and operators
- Using continue statements
Use Luau when:
- Developing for Roblox
- Using type annotations
- Need Luau-specific features like if expressions
Use FiveM when:
- Developing FiveM resources
- Using GTA V native hashes
Use All/AllWithIntegers when:
- Building a general-purpose Lua tool
- Need to parse any Lua dialect
- Not concerned about strict version compliance
Complete Example
See Also
- Parsing - Using parse options when parsing
- Syntax Trees - Understanding the parsed result