Farkle.Tools.MSBuild 7.0.1

dotnet add package Farkle.Tools.MSBuild --version 7.0.1
                    
NuGet\Install-Package Farkle.Tools.MSBuild -Version 7.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="Farkle.Tools.MSBuild" Version="7.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Farkle.Tools.MSBuild" Version="7.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Farkle.Tools.MSBuild">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Farkle.Tools.MSBuild --version 7.0.1
                    
#r "nuget: Farkle.Tools.MSBuild, 7.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 Farkle.Tools.MSBuild@7.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=Farkle.Tools.MSBuild&version=7.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Farkle.Tools.MSBuild&version=7.0.1
                    
Install as a Cake Tool

Farkle.Tools.MSBuild

This package provides integration with MSBuild for the Farkle parser library.

Precompiling grammars

The main feature of this integration is the ability to precompile grammars at build time. This offers multiple benefits, including better startup performance and compile-time grammar validation.

C#

using Farkle;
using Farkle.Builder;

var parser = GetParser();
var result = parser.Parse("1 + 2"); // Whitespace is ignored by default.
Console.WriteLine(result); // 3

[PrecompilerInput]
static IGrammarBuilder<int> GetGrammar()
{
    var number = Terminals.Int32("Number");
    return Nonterminal.Create("Addition",
        number.Extended().Append("+").Extend(number).Finish((left, right) => left + right)
    );
}

[PrecompilerOutput]
static CharParser<int> GetParser() => CharParser.MustPrecompile<int>();

F#

open Farkle
open Farkle.Builder

[<PrecompilerInput>]
let getGrammar() =
    let number = Terminals.Int32("Number")
    "Addition" ||= [
        !@ number .>> "+" .>>. number => (fun left right -> left + right)
    ]

[<PrecompilerOutput>]
let getParser() = CharParser.mustPrecompile<int>

let parser = getParser()
let result = CharParser.parseString parser "1 + 2" // Whitespace is ignored by default.
printfn "%O" result // 3

Generating HTML documentation

You can generate HTML documentation for your precompiled grammars by enabling the FarkleGenerateHtml property in your project:

<PropertyGroup>
  <FarkleGenerateHtml>true</FarkleGenerateHtml>
</PropertyGroup>

Documentation

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.1 147 7/9/2026
7.0.0 124 6/28/2026
7.0.0-preview.3 71 5/18/2026
7.0.0-preview.2 486 10/30/2025
7.0.0-preview.1 489 9/6/2025
6.5.2 27,925 11/10/2024
6.5.1 27,867 1/25/2023
6.5.0 589 9/8/2022
6.4.0 709 3/11/2022
6.3.2 606 10/31/2021
6.3.1 558 10/18/2021
6.3.0 636 10/3/2021
6.2.0 599 5/16/2021
6.1.0 573 3/4/2021
6.0.0 612 2/22/2021
6.0.0-alpha.3 424 11/25/2020
6.0.0-alpha.2 491 8/22/2020
6.0.0-alpha.1 504 4/13/2020
5.4.1 909 3/23/2020
5.4.0 768 3/20/2020
Loading failed

You can see information about the latest releases on https://github.com/teo-tsirpanis/Farkle/releases