Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

Repository files navigation

A C# (G)Lua lexer, parser, code analysis, transformation and code generation toolkit. For getting started, see thetutorial.

DiscordLoretta.CodeAnalysis.LuaLoretta.CodeAnalysis.LuaGitHub Workflow Status

This is (another) rewrite from scratch based on Roslyn andThe Complete Syntax of Lua with a few extensions:

  1. Operators introduced in Garry's Mod Lua (glua):
    • && forand;
    • || foror;
    • != for~=;
    • ! fornot;
  2. Comment types introduced in Garry's Mod Lua (glua):
    • C style single line comment:// ...;
    • C style multi line comment:/* */;
  3. Characters accepted as part of identifiers by LuaJIT (emojis, non-rendering characters,or basically any byte above127/0x7F);
  4. 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.
  5. FiveM's hash string syntax;
  6. Continue support. The following options are available:
    • No continue at all;
    • Luau'scontinue which is a contextual keyword;
    • Garry's Mod'scontinue 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).

Installing Loretta v0.2

We have two NuGet packages:

PackageStableLatest
MainLoretta.CodeAnalysis.LuaLoretta.CodeAnalysis.Lua
ExperimentalLoretta.CodeAnalysis.Lua.ExperimentalLoretta.CodeAnalysis.Lua.Experimental

Using Loretta v0.2

The best source for getting started is thetutorial.

Parsing text

  1. (Optional) Pick aLuaSyntaxOptions preset and then create aLuaParseOptions from it. If no preset is picked,LuaSyntaxOptions.All is used by default;
  2. (Optional) Create aSourceText from your code (using one of theSourceText.From overloads);
  3. CallLuaSyntaxTree.ParseText with yourSourceText/string, (optional)LuaParseOptions, (optional)path and (optional)CancellationToken;
  4. Do whatever you want with the returnedLuaSyntaxTree.

[8]ページ先頭

©2009-2025 Movatter.jp