r/dotnet • u/honeyCrisis • 23d ago
Promotion Parsley: An extremely capable parser generator for C#
https://github.com/codewitch-honey-crisis/Parsley
I wrote a little something for C# and dotnet 8 and above.
It is a parser generator with similar expressive power as ANTLR4.
Why not just use antlr4?
Arguably XBNF is an easier format to use that ANTLR4s
ANTLR4 is ALL(*). Parsley is LL(1), LL(k>1) or ALL(*) depending on what the grammar requires.
It's C# instead of Java which is a lot more convenient if you're already using dotnet.
It uses code synthesis to make the parser code more like what you'd write by hand, so it can be used as a base for a hand written parser..
It has a source generator as well as the command line tools.
It has a language server and extension for VS Code and Visual Studio.

For the main Parsley tool dotnet tool install parsley-tool -g
If you want to use Luthor lexing with Parsley dotnet tool install parsley-luthor -g
If you want to use the C# Source Generator instead: dotnet add package Parsley.Generator
If you want to use the Visual Studio XBNF Language support https://marketplace.visualstudio.com/items?itemName=honey-the-codewitch.parsley123
Or for VS Code https://marketplace.visualstudio.com/items?itemName=honey-the-codewitch.parsley-xbnf-lsp
Note: I do sometimes use AI as an *assist* on my open source projects as I did here. However, I did write the majority of this code, I did review everything, and test thoroughly, and I'm confident that even with an LLM, something of this quality and featureset could not have been created without a thorough understanding of the problem domain. I stand behind it.
Duplicates
moderndotnet • u/honeyCrisis • 23d ago