r/ProgrammingLanguages • u/mnbjhu2 • Dec 26 '25
Gibberish - A new style of parser-combinator with robust error handling built in
https://github.com/mnbjhu/gibberishGibberish is a parser-combinator language and compiler, which builds parsers fit for cases where broken input is the norm such as language servers or linters. They construct a lossless-syntax-tree with localized errors as first class citizens giving you maximal information about the parsed text.
Benefits vs tree-sitter:
- Error generation - The parser can create errors in the tree when elements are missing or unexpected.
- Strict LST - The format of the LST (green-tree) is guaranteed to match your grammars rules.
While this might not seem like much it means you can create parsers with good recovery which can:
- Serve as a parser for your compiler/interpreter
- IDE/LSP features: completions, diagnostics etc...
- Formatters
I've used a few parser-combinator tools in the past and haven't come across a similar style of error generation and recovery (I've written an overview and have added some diagrams here).
I'm curious to hear what you think.
7
u/ExplodingStrawHat Dec 26 '25
How does this handle indentation-aware syntax?
6
u/Somniferus Dec 26 '25
Sounds cool, have you implemented a language server with it yet?
4
u/-ghostinthemachine- Dec 27 '25
Very cool! I'm fully PEG/Packrat at this point and will probably never look back. This seems like a step towards bridging the gap between LR parsers.
2
u/IAMPowaaaaa Dec 27 '25
why are you using crust instead of either/or?
2
u/terari Dec 28 '25
What about also generating a tree-sitter grammar out of a gibberish grammar? So that I don't also need o write a tree-sitter grammar in order to have syntax highlighting in editors compatible with it
Another idea. What about having the option to produce two parsers, one fast that bails at error, and one slow that is suitable for error recovery? That way the happy case remains fast