- Notifications
You must be signed in to change notification settings - Fork12
A C# Lua, GLua and Luau parser, code analysis, transformation and generation library.
License
NotificationsYou must be signed in to change notification settings
LorettaDevs/Loretta
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A C# (G)Lua lexer, parser, code analysis, transformation and code generation toolkit. For getting started, see thetutorial.
This is (another) rewrite from scratch based on Roslyn andThe Complete Syntax of Lua with a few extensions:
- Operators introduced in Garry's Mod Lua (glua):
&&
forand
;||
foror
;!=
for~=
;!
fornot
;
- Comment types introduced in Garry's Mod Lua (glua):
- C style single line comment:
// ...
; - C style multi line comment:
/* */
;
- C style single line comment:
- Characters accepted as part of identifiers by LuaJIT (emojis, non-rendering characters,or basically any byte above
127
/0x7F
); - Luau (Roblox Lua) syntax:
- Compound assignment:
+=
,-=
,*=
,/=
,^=
,%=
,..=
; - If expressions:
if a then b else c
andif a then b elseif c then d else e
; - Typed lua syntax.
- Compound assignment:
- FiveM's hash string syntax;
- Continue support. The following options are available:
- No continue at all;
- Luau's
continue
which is a contextual keyword; - Garry's Mod's
continue
which is a full fledged keyword.
TL;DR: This supports Lua 5.1, Lua 5.2, Lua 5.3, Lua 5.4, LuaJIT 2.0, LuaJIT 2.1, FiveM, GLua and Luau (Roblox Lua).
We have two NuGet packages:
Package | Stable | Latest |
---|---|---|
Main | ||
Experimental |
The best source for getting started is thetutorial.
- (Optional) Pick a
LuaSyntaxOptions
preset and then create aLuaParseOptions
from it. If no preset is picked,LuaSyntaxOptions.All
is used by default; - (Optional) Create a
SourceText
from your code (using one of theSourceText.From
overloads); - Call
LuaSyntaxTree.ParseText
with yourSourceText
/string
, (optional)LuaParseOptions
, (optional)path
and (optional)CancellationToken
; - Do whatever you want with the returned
LuaSyntaxTree
.
About
A C# Lua, GLua and Luau parser, code analysis, transformation and generation library.