Farkle


What is Farkle?

Farkle is a text parser library for .NET, featuring the best of both worlds: LALR parser combinators. Users define the terminals and nonterminals of their grammars, what to do when each of them is encountered, and Farkle takes care of the rest.

It can be installed from NuGet.

Features

  • Speed: Farkle is fast. Its performance is a top priority and lots of time has been invested in its optimization.
  • Language compatibility: Farkle is usable from both C# and F#, with an intuitive API for each language. It even supports C# 8.0's nullable reference types!
  • Fast development cycle: Unlike parser generators, Farkle does not generate any source files. Your grammars are type-safe and created entirely from code, allowing features like IntelliSense and real-time syntax error reporting.
  • Integration with MSBuild: Farkle can optionally integrate with MSBuild to enable features like ahead-of-time grammar building which drastically reduces startup times and catches grammar errors like LALR conflicts at compile time.
  • Large file support: Farkle can parse large files without entirely reading them to memory.
  • Grammar introspection: Farkle provides APIs that allow your grammars to be inspected from code.
  • Wide framework support: Farkle targets .NET Standard 2.0, supporting .NET Framework 4.6.1+, .NET Core 2.0+, Xamarin, UWP and Unity.

Learn more about Farkle's features, compared with other .NET parsers.

Documentation

The library comes with comprehensible documentation.

Samples

  • A JSON parser powered by Farkle and written in both C# and F#.

  • A mathematical expression parser powered by Farkle and written in F#, also showcasing some more advanced features.

  • A simple indent-based language parser that supports virtual terminals written in F#. The most advanced example; it explains how to write a custom tokenizer.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.

The library is available under the MIT license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.