Install the main package
Loretta is distributed via NuGet asLoretta.CodeAnalysis.Lua. This package contains the core parsing, analysis, and transformation APIs you need to work with Lua code.
The version number shown is the current stable release. Check NuGet for the latest version.
Experimental package (optional)
For access to experimental features like the constant folder and minifier, install the experimental package:System requirements
Loretta supports the following .NET platforms:- .NET 8.0 or later
- .NET Standard 2.0 (compatible with .NET Framework 4.6.1+, .NET Core 2.0+, Mono, Xamarin, and Unity)
Verify installation
After installing the package, verify it’s working by adding this code to your project:Package contents
Loretta.CodeAnalysis.Lua
The main package includes:- Lexer - Tokenizes Lua source code
- Parser - Builds syntax trees from tokens
- Syntax tree APIs - Navigate and inspect parsed code
- Syntax factory - Generate Lua code programmatically
- Rewriter APIs - Transform syntax trees
- Diagnostics - Error and warning reporting
- Parse options - Configure Lua version and dialect support
Loretta.CodeAnalysis.Lua- Core types and entry pointsLoretta.CodeAnalysis.Lua.Syntax- Syntax node typesLoretta.CodeAnalysis.Text- Source text handling
Loretta.CodeAnalysis.Lua.Experimental
The experimental package adds:- Constant folder - Evaluate and fold constant expressions
- Minifier - Remove unnecessary whitespace and comments
- Additional transformations - Experimental code transformation utilities
Target framework selection
Loretta multi-targets .NET 8.0 and .NET Standard 2.0:- For modern .NET projects (.NET 6+): You automatically get the .NET 8.0 version with improved performance and reduced allocations
- For .NET Framework or older .NET Core: You automatically get the .NET Standard 2.0 version with broader compatibility
Next steps
Quickstart
Parse your first Lua code in under 5 minutes
Introduction
Learn what Loretta can do