### Project Setup with Antlr4BuildTasks Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Integrates Antlr4BuildTasks and Antlr4.Runtime.Standard into a C# project via NuGet. It configures .g4 grammar files for automatic processing during the build, ensuring parser and lexer code generation. ```xml Exe net6.0 ``` -------------------------------- ### Build ANTLR .NET Projects from Command Line (Bash) Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Provides common command-line interface (CLI) commands for building .NET projects that utilize ANTLR grammars. These commands cover basic build, cleaning, release builds, verbose output, and targeting specific projects or frameworks. ```bash # Basic build (Windows/Linux/macOS) dotnet build # Clean and rebuild dotnet clean dotnet build # Build in Release configuration dotnet build -c Release # Build with verbose output to see ANTLR tool execution dotnet build -v detailed # Build specific project dotnet build MyProject.csproj # Restore packages and build dotnet restore dotnet build --no-restore # Build and run dotnet run # Publish application (ANTLR-generated files included automatically) dotnet publish -c Release -o ./publish # Build with specific target framework (multi-targeting projects) dotnet build -f net6.0 ``` -------------------------------- ### Add Antlr4BuildTasks and Antlr4.Runtime.Standard to Project Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Readme.md This XML snippet demonstrates how to add the Antlr4BuildTasks and Antlr4.Runtime.Standard NuGet packages to a C# project file (.csproj). This integration enables the build system to automatically process Antlr4 grammars. 'PrivateAssets=all' and 'IncludeAssets=build' ensure the build tasks are available during compilation but not published with the application. ```xml ``` -------------------------------- ### Custom Java Executable Configuration for ANTLR Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Specifies how the ANTLR tool should locate or download a Java executable. Supports using the system's PATH, auto-downloading a JRE, or specifying a direct path to a java executable. Includes options for custom download directories and fallback configurations. ```xml PATH DOWNLOAD USERPROFILE/.jre/ C:/Program Files/Java/jdk-11/bin/java.exe PATH;C:/Java/bin/java.exe;DOWNLOAD DOWNLOAD C:/BuildTools/Java/ ``` -------------------------------- ### Upgrade PackageReference from Antlr4.CodeGenerator to Antlr4BuildTasks Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Readme.md Replace legacy Antlr4.CodeGenerator NuGet package with Antlr4BuildTasks and update Antlr4.Runtime to Antlr4.Runtime.Standard. This migration path modernizes the build system and runtime dependencies for ANTLR4 C# projects. ```xml all runtime; build; native; contentfiles; analyzers; buildtransitive ``` ```xml ``` -------------------------------- ### ANTLR Grammar File Configuration Options Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Configures ANTLR grammar files with various options such as custom namespaces, listener/visitor generation, debugging output, and error handling. Supports specifying library paths and file encoding for the ANTLR tool. ```xml MyApp.Parsers MyCompany.Parsers true true true true \.\grammars;\.\common UTF-8 language=CSharp;tokenVocab=CommonLexer ``` -------------------------------- ### Configure ANTLR Tool JAR Custom Location Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Sets custom directories for downloading the ANTLR tool JAR and specifies exact JAR file paths or probe paths for discovery. USERPROFILE is a special variable that expands to the user's home directory. ```xml USERPROFILE/.m2/ C:/BuildTools/Antlr/ C:/Tools/antlr-4.13.1-complete.jar D:/CustomPath/ ``` -------------------------------- ### Configure RunAntlrTool MSBuild Task with Properties (MSBuild) Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Demonstrates the direct usage of the RunAntlrTool MSBuild task, showcasing various properties available for customizing ANTLR code generation. This allows for advanced build configurations beyond the default settings. ```xml ``` -------------------------------- ### Configure Antlr4 ItemGroup with Grammar Parameters in MSBuild Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Readme.md Define ANTLR grammar file processing parameters within the .csproj file using ItemGroup element. Supports configuration of listener/visitor generation, ATN diagrams, namespace packaging, and error handling. Parameters are passed directly to the ANTLR tool during build process. ```xml false false true foo true ``` -------------------------------- ### Control ANTLR Listener and Visitor Pattern Generation Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Manages the generation of listener and visitor classes for ANTLR parse trees. This allows fine-grained control over the output for different traversal strategies, including generating both, only one, or neither. ```xml true true true false false true false false ``` -------------------------------- ### Update Project File for Antlr4BuildTasks (MSBuild) Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Compares the old Antlr4.CodeGenerator MSBuild item group with the new Antlr4BuildTasks configuration. It highlights the change from Antlr4.Runtime to Antlr4.Runtime.Standard and the addition of the Antlr4BuildTasks NuGet package. ```xml all runtime; build; native; contentfiles; analyzers; buildtransitive true false true false ``` -------------------------------- ### Configure Antlr4 Grammar Files for Build Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Readme.md This XML snippet shows how to specify Antlr4 grammar files (.g4) for processing by the Antlr4BuildTasks. You can either change the 'Build Action' property of the .g4 file in Visual Studio to 'ANTLR 4 grammar', or you can declare them in the .csproj file using the `` element. This allows the build system to identify and compile these grammar files. ```xml ``` -------------------------------- ### Configure ANTLR Multi-Target Grammar with Shared Tokens Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Enables the configuration of lexer and parser grammars that share token definitions using the LibPath property. This is useful for modularizing grammar definitions and ensuring consistent token recognition across different parts of the grammar. ```xml MyApp.Grammar false false MyApp.Grammar $(IntermediateOutputPath) true true language=CSharp;tokenVocab=MyLexer .\common;.\generated;$(IntermediateOutputPath) ``` -------------------------------- ### C# Type Aliases for 32-bit and 64-bit Architectures Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Antlr4BuildTasks/SharpCompress/Compressors/Rar/UnpackV2017/notes.txt Conditional compilation directives in C# define aliases for integer types based on whether the target architecture is 32-bit or 64-bit. This allows for consistent handling of native integer types across different platforms, mapping to `System.Int32` or `System.Int64` as appropriate. ```csharp #if !Rar2017_64bit using nint = System.Int32; using nuint = System.UInt32; using size_t = System.UInt32; #else using nint = System.Int64; using nuint = System.UInt64; using size_t = System.UInt64; #endif using int64 = System.Int64; ``` -------------------------------- ### Configure ANTLR Error Handling and Logging Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Sets up error handling and logging options for the ANTLR tool. This includes treating warnings as errors, enabling verbose logging, and configuring long error messages for improved diagnostics during the build process. ```xml true true true true true false ``` -------------------------------- ### Migrate from Antlr4.CodeGenerator to Antlr4BuildTasks ItemGroup Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Readme.md Update Antlr4 ItemGroup configuration from Update attribute to Include attribute pattern when migrating to Antlr4BuildTasks. This represents the structural change in how grammar files are referenced in modern build task versions. ```xml etc etc etc ``` ```xml ``` -------------------------------- ### Enabling Very Large Objects in .NET Runtime Source: https://github.com/kaby76/antlr4buildtasks/blob/master/Antlr4BuildTasks/SharpCompress/Compressors/Rar/UnpackV2017/notes.txt By default, .NET arrays are limited to a maximum size that can be indexed by `System.Int32.MaxValue`. To support arrays larger than 2GB on x64 systems, the .NET runtime must be configured to allow very large objects. This is achieved by enabling the `gcAllowVeryLargeObjects` element in the application's configuration file. ```xml ``` -------------------------------- ### Configure ANTLR Custom Output Directory Source: https://context7.com/kaby76/antlr4buildtasks/llms.txt Specifies custom output directories for ANTLR-generated files, separate from the default intermediate output path. This enables organization of generated code, such as lexers and parsers, into distinct subdirectories. ```xml $(ProjectDir)Generated\Parsers\ $(ProjectDir)Generated\Lexers\ $(ProjectDir)Generated\Parsers\ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.