Loom.Parser.Lua
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Loom.Parser.Lua --version 1.0.0
NuGet\Install-Package Loom.Parser.Lua -Version 1.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="1.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="1.0.0" />
<PackageReference Include="Loom.Parser.Lua" />
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 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Loom.Parser.Lua, 1.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@1.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=1.0.0
#tool nuget:?package=Loom.Parser.Lua&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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.Parser.ASTGenerator;
using Loom.Parser.ASTGenerator.AST.Statements;
using Loom.Parser.Lexer;
using Loom.Parser.Lexer.Objects;
using Loom.Parser.Preprocessor;
using Loom.Parser.PrettyPrint;
// ...
string script = File.ReadAllText("Tests\\Sample.lua");
LexicalAnalyser codeLexer = new LexicalAnalyser(script);
LexTokenList lexTokens = codeLexer.Analyze();
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
- Locals
Expressions
- Ternary (if true then "hello" else "goodbye")
- Grouped
- Negative (E.g -10)
- Length (E.g #table)
- Nil
- Function declaration (e.g function(...) print(...) end)
- Identifier (E.g print)
- Vararg (E.g ...)
- Constant (E.g 123, "hello")
- Array (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 | Versions 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.
-
net10.0
- Tools.GeneralTK (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release