Loom.Parser.Lua 2.0.0

dotnet add package Loom.Parser.Lua --version 2.0.0
                    
NuGet\Install-Package Loom.Parser.Lua -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Loom.Parser.Lua" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Loom.Parser.Lua" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Loom.Parser.Lua" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Loom.Parser.Lua --version 2.0.0
                    
#r "nuget: Loom.Parser.Lua, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Loom.Parser.Lua@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Loom.Parser.Lua&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Loom.Parser.Lua&version=2.0.0
                    
Install as a Cake Tool

This parser was written due to my belief that existing, modern day Lua parsers are way too boilerplate to interact with.

Loom Parser

Loom parser is a robust recursive-descent / precedence Lua parser designed to make transforming of AST easy.
The end goal is a parser with AST you can easily interact with.

This parser is experimental, do not take the output for granted just yet.

Usage

Example

using Loom.Lua.Parser.ASTGenerator;
using Loom.Lua.Parser.ASTGenerator.AST.Statements;
using Loom.Lua.Parser.Lexer;
using Loom.Lua.Parser.Lexer.Objects;
using Loom.Lua.Parser.Preprocessor;
using Loom.Lua.Parser.PrettyPrint;

// ...

string script = File.ReadAllText("Tests\\Sample.lua");

LexicalAnalyser codeLexer = new LexicalAnalyser(script);
LexTokenList lexTokens = codeLexer.Analyze();

Preprocessor preProcessor = new Preprocessor(lexTokens);
lexTokens = preProcessor.Process();

ASTGenerator astGenerator = new ASTGenerator(lexTokens);
StatementList statements = astGenerator.ParseStatements();

PrettyPrinter prettyPrinter = new PrettyPrinter(PrettyPrinterSettings.Minify);
Console.WriteLine(prettyPrinter.Print(statements));

Supported syntax

  • Statements

    • Locals
      • Functions
      • Variables
    • Assignments
      • Multiple assignments
    • Function declarations
    • If .. then
    • While .. do
    • Return
    • For .. do
    • Repeat .. until
    • Do
    • Break
    • Continue
    • Calls
  • Expressions

    • Ternary (if true then "hello" else "goodbye")
    • Grouped
    • Negative (E.g -10)
    • Length (E.g #table)
    • Not (E.g not true)
    • Nil
    • Function declaration (e.g function(...) print(...) end)
    • Identifier (E.g print)
    • Vararg (E.g ...)
    • Constant (E.g 123, "hello")
    • Array and records (E.g {["this"] = "hi"})
    • Call (E.g math.pow(5, 5))
    • Index (E.g table[1])
    • Relational (E.g 4 > 3)
    • Arithmetic (E.g 2 + 2)
    • Logical (E.g and, or, not)
    • Concat (E.g "Hello " .. "world")
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 31 3/16/2026
1.0.0 37 3/14/2026

Changed the namespace Loom to Loom.Lua, reverted to old parsing method - now complete and stable for Lua 5.1.