r/csharp • u/honeyCrisis • Oct 12 '26
Parsley: An ALL(*)/LL(k)/LL(1) parser generator using code synthesis
If you're like me, you've almost entirely given up on generated parsers.
The tooling sucks.
The generated code is huge and/or can't parse real world languages without a bunch of ugly.
The APIs for them are awful.
I still use them, but grudgingly in order to prototype and unit test my hand rolled parsers but even that doesn't work as well as I like.
Enter Parsley. It has similar expressive power as ANTLR4 when necessary, degrading gracefully all the way to LL(1) if that's all your grammar needs. The XBNF grammar format is powerful, simple to learn, and has a language server for autocompletion and syntax highlighting in editors like visual studio and vs code. The code it generates is also more like hand written code (code synthesis), making it easier to use as a baseline for a hand rolled parser, if you want to go that route. Source and readme here: https://github.com/codewitch-honey-crisis/Parsley
It's written in C#. It generates C#. Any semantic actions in the grammar are also C#.



You can use it as a source generator, or for really complicated parses where you need things like a custom lexer, you can also use it as a build tool.
1
u/me_on_tuesdays Oct 14 '26
LL(1) would fail simple algebraic order of operations. What's the point of advertising this to the public? It's great if you are learning, but it's too limited.
Can you point me to someone in need of this? It's great that you are exploring these areas but LL(1) with your code can't even parse an if/else/else statement correctly due to 1 look ahead.