A C# parser combinator library with high-quality error reporting and token-driven parsing.
Superpower is a C# parser combinator library that allows developers to construct parsers declaratively, matching the structure of the grammar they are implementing. It solves the problem of building parsers that are both performant and provide high-quality, user-friendly error messages when encountering invalid input. The library supports both character-based text parsing and token-driven parsing, where input is first broken into tokens for clearer error reporting.
C# developers who need to implement parsers for domain-specific languages, data formats, configuration files, or query languages, especially those prioritizing good error messages and maintainable code.
Developers choose Superpower for its balance of performance, ease of use, and excellent error reporting. Its token-driven parsing approach yields error messages that are far more informative than typical character-level errors, and its combinator-based design allows parsers to be built and tested modularly.
A C# parser construction toolkit with high-quality error reporting
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Parsers are built in a style that closely matches the target grammar, improving readability and maintainability, as demonstrated in the JSON parser example where combinators mirror structural rules.
Token-driven parsing enables error reporting in terms of tokens (e.g., 'unexpected identifier') rather than characters, with the [Token] attribute allowing custom examples to enhance clarity.
Benchmarks show it outperforms similar libraries like Sprache with minimal allocations and reduced backtracking, as cited in the performance section where it parsed expressions 3.5x faster.
Integrates directly into C# projects without external tools or build-time code generation, simplifying deployment and setup, as emphasized in the 'Usage' section.
While TokenizerBuilder aids assembly, handwritten tokenizers for optimal performance or flexibility require significant code and deep understanding, as the README admits they are 'more complicated'.
Lacks built-in support for common parsing challenges like left recursion or sophisticated error recovery, forcing developers to implement workarounds manually, which can increase complexity.
Compared to full parser generators like ANTLR, Superpower has fewer community resources, pre-built grammars, and integration tools, limiting out-of-the-box solutions for complex languages.