War3Net.CodeAnalysis.Jass
6.0.1
dotnet add package War3Net.CodeAnalysis.Jass --version 6.0.1
NuGet\Install-Package War3Net.CodeAnalysis.Jass -Version 6.0.1
<PackageReference Include="War3Net.CodeAnalysis.Jass" Version="6.0.1" />
<PackageVersion Include="War3Net.CodeAnalysis.Jass" Version="6.0.1" />
<PackageReference Include="War3Net.CodeAnalysis.Jass" />
paket add War3Net.CodeAnalysis.Jass --version 6.0.1
#r "nuget: War3Net.CodeAnalysis.Jass, 6.0.1"
#:package War3Net.CodeAnalysis.Jass@6.0.1
#addin nuget:?package=War3Net.CodeAnalysis.Jass&version=6.0.1
#tool nuget:?package=War3Net.CodeAnalysis.Jass&version=6.0.1
War3Net.CodeAnalysis.Jass
About
War3Net.CodeAnalysis.Jass is a .NET library for parsing, analyzing, and generating JASS (Just Another Scripting Syntax) source code. JASS is the scripting language used in Warcraft III for game logic and triggers. It is part of the War3Net modding library.
Key features
- Parse JASS source code into a complete immutable syntax tree
- Generate JASS source code from syntax nodes with formatting control
- Syntax tree traversal and analysis with child/descendant node enumeration
- Code transformation via the syntax rewriter pattern
- Rename identifiers across a compilation unit with scope awareness
- Normalize and pretty-print JASS code with configurable indentation
- Support for all JASS language constructs including FourCC literals
- Fluent builder API for constructing syntax trees programmatically
How to Use
Parse JASS source code
using War3Net.CodeAnalysis.Jass;
using War3Net.CodeAnalysis.Jass.Syntax;
// Parse a complete JASS file
string jassCode = @"
function HelloWorld takes nothing returns nothing
call BJDebugMsg(""Hello, World!"")
endfunction
";
JassCompilationUnitSyntax compilationUnit = JassSyntaxFactory.ParseCompilationUnit(jassCode);
// Iterate over declarations
foreach (var declaration in compilationUnit.Declarations)
{
if (declaration is JassFunctionDeclarationSyntax function)
{
string functionName = function.FunctionDeclarator.IdentifierName.Name;
Console.WriteLine($"Found function: {functionName}");
}
}
Parse with error handling
using War3Net.CodeAnalysis.Jass;
string expression = "x + y * 2";
if (JassSyntaxFactory.TryParseExpression(expression, out var result))
{
Console.WriteLine("Parsed successfully!");
}
else
{
Console.WriteLine("Parse failed.");
}
Generate JASS source code
using System.IO;
using War3Net.CodeAnalysis.Jass;
using War3Net.CodeAnalysis.Jass.Syntax;
// Parse and regenerate code
var unit = JassSyntaxFactory.ParseCompilationUnit(jassCode);
// Write to a TextWriter
using var writer = new StringWriter();
unit.WriteTo(writer);
string output = writer.ToString();
Generate JASS code with IndentedTextWriter
using System.IO;
using War3Net.CodeAnalysis;
using War3Net.CodeAnalysis.Jass.Extensions;
// Create a writer for generating formatted JASS code
using var stringWriter = new StringWriter();
using var writer = new IndentedTextWriter(stringWriter);
// Write a function with local variables and control flow
writer.WriteFunction("InitTrigger");
writer.WriteLocal("trigger", "t", "CreateTrigger()");
writer.WriteLocal("integer", "i");
writer.WriteCall("TriggerRegisterTimerEvent", "t", "1.0", "true");
writer.WriteSet("i", "0");
writer.WriteLoop();
writer.WriteExitWhen("i >= 10");
writer.WriteCall("BJDebugMsg", "I2S(i)");
writer.WriteSet("i", "i + 1");
writer.WriteEndLoop();
writer.WriteIf("i == 10");
writer.WriteCall("BJDebugMsg", "\"Done!\"");
writer.WriteElse();
writer.WriteCall("BJDebugMsg", "\"Error\"");
writer.WriteEndIf();
writer.EndFunction();
string jassCode = stringWriter.ToString();
// Output:
// function InitTrigger takes nothing returns nothing
// local trigger t = CreateTrigger()
// local integer i
// call TriggerRegisterTimerEvent( t, 1.0, true )
// set i = 0
// loop
// exitwhen i >= 10
// call BJDebugMsg( I2S(i) )
// set i = i + 1
// endloop
// if i == 10 then
// call BJDebugMsg( "Done!" )
// else
// call BJDebugMsg( "Error" )
// endif
// endfunction
Build expressions programmatically
using War3Net.CodeAnalysis.Jass;
// Create literal expressions
var intLiteral = JassLiteral.Int(42);
var realLiteral = JassLiteral.Real(3.14f);
var stringLiteral = JassLiteral.String("Hello");
var fourccLiteral = JassLiteral.FourCC("hpea"); // Warcraft 3 unit rawcode
// Create compound expressions
var andExpr = JassExpression.And("conditionA", "conditionB");
var notExpr = JassExpression.Not("isEnabled");
Rename identifiers
using War3Net.CodeAnalysis.Jass;
var functionRenames = new Dictionary<string, string>
{
{ "OldFunctionName", "NewFunctionName" }
};
var globalRenames = new Dictionary<string, string>
{
{ "udg_OldVariable", "udg_NewVariable" }
};
var renamer = new JassRenamer(functionRenames, globalRenames);
var renamedUnit = renamer.Rename(compilationUnit);
Main Types
The main types provided by this library are:
War3Net.CodeAnalysis.Jass.JassSyntaxFactory- Parse JASS source strings into syntax treesWar3Net.CodeAnalysis.Jass.JassRenamer- Rename function and variable identifiers with scope trackingWar3Net.CodeAnalysis.Jass.JassSyntaxFacts- Character and identifier validation utilitiesWar3Net.CodeAnalysis.Jass.JassLiteral- Create literal value expressions (int, real, string, FourCC)War3Net.CodeAnalysis.Jass.JassExpression- Helper methods for creating compound expressionsWar3Net.CodeAnalysis.Jass.Syntax.JassCompilationUnitSyntax- Root syntax node containing all declarationsWar3Net.CodeAnalysis.Jass.Syntax.JassFunctionDeclarationSyntax- Function declaration syntax nodeWar3Net.CodeAnalysis.Jass.Syntax.JassGlobalsDeclarationSyntax- Global variable block syntax nodeWar3Net.CodeAnalysis.Jass.Syntax.JassSyntaxNode- Abstract base class for all syntax nodes
Related Packages
- War3Net.Build - Generate JASS map scripts and compile maps
- War3Net.CodeAnalysis.Transpilers - Transpile JASS to C# or Lua
- War3Net.Build.Core - Parsers and serializers for war3map files
Feedback and contributing
War3Net.CodeAnalysis.Jass is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Disclaimer
This README was generated with the assistance of AI and may contain inaccuracies. Please verify the information and consult the source code for authoritative details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net5.0
- War3Net.CodeAnalysis (>= 6.0.1)
- War3Net.Common (>= 6.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on War3Net.CodeAnalysis.Jass:
| Package | Downloads |
|---|---|
|
War3Net.Build.Core
Parsers and serializers for war3map files. |
|
|
War3Net.CodeAnalysis.Transpilers
Transpile JASS to C# or Lua. |
|
|
War3Net.CodeAnalysis.Decompilers
Regenerate war3map files from a Warcraft III map script. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.1 | 0 | 2/1/2026 |
| 6.0.0 | 210 | 1/25/2026 |
| 5.8.0 | 889 | 9/6/2025 |
| 5.6.1 | 7,619 | 1/7/2023 |
| 5.6.0 | 1,161 | 12/20/2022 |
| 5.5.5 | 3,065 | 11/13/2022 |
| 5.5.3 | 1,410 | 10/29/2022 |
| 5.5.2 | 1,271 | 10/25/2022 |
| 5.5.0 | 2,335 | 8/20/2022 |
| 5.4.5 | 1,627 | 5/27/2022 |
| 5.4.1 | 3,512 | 2/13/2022 |
| 5.4.0 | 1,628 | 2/13/2022 |
| 5.3.1 | 681 | 1/19/2022 |
| 5.3.0 | 1,495 | 1/16/2022 |
| 5.2.2 | 3,329 | 2/16/2021 |
| 5.2.1 | 1,211 | 2/14/2021 |
| 5.2.0 | 799 | 1/24/2021 |
| 5.1.0 | 995 | 12/22/2020 |
| 5.0.0 | 816 | 12/14/2020 |
| 2.1.0 | 898 | 11/12/2020 |
| 2.0.1 | 839 | 11/11/2020 |
| 2.0.0 | 849 | 10/27/2020 |
| 1.2.2 | 1,039 | 9/14/2020 |
| 1.2.1 | 2,567 | 6/1/2020 |
| 1.2.0 | 3,750 | 1/10/2020 |
| 1.1.0 | 1,105 | 1/3/2020 |
| 1.0.3 | 1,343 | 11/20/2019 |
| 1.0.2 | 776 | 10/8/2019 |
| 1.0.1 | 2,061 | 10/6/2019 |
| 1.0.0 | 819 | 9/30/2019 |