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
                    
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="War3Net.CodeAnalysis.Jass" Version="6.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="War3Net.CodeAnalysis.Jass" Version="6.0.1" />
                    
Directory.Packages.props
<PackageReference Include="War3Net.CodeAnalysis.Jass" />
                    
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 War3Net.CodeAnalysis.Jass --version 6.0.1
                    
#r "nuget: War3Net.CodeAnalysis.Jass, 6.0.1"
                    
#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 War3Net.CodeAnalysis.Jass@6.0.1
                    
#: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=War3Net.CodeAnalysis.Jass&version=6.0.1
                    
Install as a Cake Addin
#tool nuget:?package=War3Net.CodeAnalysis.Jass&version=6.0.1
                    
Install as a Cake Tool

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 trees
  • War3Net.CodeAnalysis.Jass.JassRenamer - Rename function and variable identifiers with scope tracking
  • War3Net.CodeAnalysis.Jass.JassSyntaxFacts - Character and identifier validation utilities
  • War3Net.CodeAnalysis.Jass.JassLiteral - Create literal value expressions (int, real, string, FourCC)
  • War3Net.CodeAnalysis.Jass.JassExpression - Helper methods for creating compound expressions
  • War3Net.CodeAnalysis.Jass.Syntax.JassCompilationUnitSyntax - Root syntax node containing all declarations
  • War3Net.CodeAnalysis.Jass.Syntax.JassFunctionDeclarationSyntax - Function declaration syntax node
  • War3Net.CodeAnalysis.Jass.Syntax.JassGlobalsDeclarationSyntax - Global variable block syntax node
  • War3Net.CodeAnalysis.Jass.Syntax.JassSyntaxNode - Abstract base class for all syntax nodes

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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