![]() |
VOOZH | about |
dotnet add package XParsec --version 1.0.0
NuGet\Install-Package XParsec -Version 1.0.0
<PackageReference Include="XParsec" Version="1.0.0" />
<PackageVersion Include="XParsec" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="XParsec" />Project file
paket add XParsec --version 1.0.0
#r "nuget: XParsec, 1.0.0"
#:package XParsec@1.0.0
#addin nuget:?package=XParsec&version=1.0.0Install as a Cake Addin
#tool nuget:?package=XParsec&version=1.0.0Install as a Cake Tool
<div align="center"> <h1 align="center"> <img alt="XParsec logo" src="docs/images/logo.svg" title="Logo" align="center"/> XParsec </h1> </div> <br/>
👁 Documentation
👁 NuGet Version
XParsec is a parser combinator library for F#, with several important differences from FParsec:
With XParsec all common contiguous collections string 'T array ResizeArray<'T> ImmutableArray<'T> and ReadOnlyMemory<'T> can be parsed with essentially the same code.
F# is a great .NET language, and with the Fable compiler, a powerful JavaScript language too. XParsec's pure F# implementation provides a robust, easy to use parsing library for Fable target languages.
XParsec uses newer F# & .NET features like [<InlineIfLambda>], Span<'T>, and struct unions to compete with imperative parsing libraries while remaining terse and easy to reason about. Parsing a single large JSON file takes roughly half the time of FParsec with ~1/6 the allocations.
| Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
|---|---|---|---|---|---|---|---|
| XParsecJson | 30.61 ms | 0.196 ms | 0.164 ms | 718.7500 | 625.0000 | - | 35.61 MB |
| FParsecJson | 61.09 ms | 0.267 ms | 0.208 ms | 4555.5556 | 777.7778 | 222.2222 | 208.37 MB |
<|>, choice, and choiceL always backtrack. There is no attempt combinator because every alternative already behaves like one. See Migrating from FParsec below.The quick brown fox jumps over the lazy dog.
^ At index 4 (Ln 1, Col 5)
All choices failed.
├───Expected 'a'
└───All choices failed.
├───Unexpected 'q'
└───Expected 'c'
XParsec is capable of parsing extremely complex grammars, including F# itself. I'm documenting building a complete F# language parser with XParsec in an ongoing blog series, starting with the prologue.
XParsec is API-shaped to be familiar to FParsec users, but a few semantics are deliberately different. Two are worth calling out:
<|>, choice, and choiceL always backtrack. FParsec's alternative combinators only continue to the next branch if the previous branch failed without consuming input; you wrap branches in attempt to force backtracking after partial consumption. XParsec's alternatives save the reader position before running each branch and restore it on any failure. There is no attempt combinator — drop attempt calls when migrating; every alternative already behaves like one. The save is a struct copy, so the always-backtrack default is cheap.pzero produces a structural Empty error. Aggregating combinators (<|>, choice, manyTill, …) filter Empty siblings before constructing nested errors, so pzero <|> p propagates only p's error rather than wrapping a blank stub. The default formatter renders nothing for Empty.If you need "fail in place when input was consumed" behaviour for a specific alternative, use notFollowedBy/<?> to gate or relabel rather than reaching for attempt.
dotnet test
npm run test
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on XParsec:
| Package | Downloads |
|---|---|
|
Partas.Tools.SepochSemver
An opinionated spec extension and parser of Semver with an optional EPOCH and Scope prefix. |
|
|
Partas.Tools.ConventionalCommits
Conventional Commits v1.0.0 spec commit message parser. |
|
|
Fidelity.Toml
A fully TOML 1.0.0 compliant parser and serializer for F#, built with XParsec. BCL-minimal design for future self-hosting. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 279 | 5/9/2026 |
| 0.4.1 | 143 | 4/19/2026 |
| 0.4.0 | 257 | 3/28/2026 |
| 0.3.1 | 871 | 1/15/2026 |
| 0.3.0 | 313 | 1/1/2026 |
| 0.2.5 | 693 | 12/9/2025 |
| 0.2.4 | 446 | 11/23/2025 |
| 0.2.3 | 261 | 10/12/2025 |
| 0.2.2 | 378 | 8/27/2025 |
| 0.2.1 | 2,146 | 8/4/2025 |
| 0.2.0 | 1,160 | 7/3/2025 |
| 0.1.0 | 392 | 4/20/2025 |
| 0.0.3 | 309 | 4/6/2025 |
| 0.0.2 | 228 | 4/5/2025 |