A Packrat parser generator for Parsing Expression Grammars (PEG) implemented in Go.
PEG is a parser generator tool that implements Packrat parsing for Parsing Expression Grammars (PEG) in Go. It allows developers to define grammars that can handle complex parsing tasks with features like backtracking and negative look-ahead, which are challenging for regular expression engines. The tool generates Go code from PEG grammar files, enabling integration into Go applications.
Go developers and language tooling engineers who need to build parsers for custom languages, data formats, or complex text processing tasks.
Developers choose PEG for its efficient Packrat parsing algorithm, seamless Go code generation, and support for advanced parsing features not available in standard regex libraries, making it ideal for implementing robust parsers.
Peg, Parsing Expression Grammar, is an implementation of a Packrat parser generator.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements memoization for linear-time parsing in many cases, as highlighted in the README, making it suitable for complex grammars without performance degradation.
Supports backtracking and negative look-ahead assertions, which are explicitly mentioned as capabilities beyond regular expression engines.
Generates Go code directly from PEG grammar files, enabling easy use with standard Go tooling like go generate, as demonstrated in the usage examples.
Uses a well-defined syntax for grammar rules, documented in peg-file-syntax.md, allowing precise control over parsing logic and integration with code.
The grammar syntax is documented separately in peg-file-syntax.md, requiring additional effort to access and learn compared to integrated help.
Only outputs Go code, limiting its utility for polyglot projects or teams needing parsers in other languages.
Requires running go generate before building or testing, adding steps to the workflow that can complicate setup and iteration.
Packrat parsing's memoization ensures speed but can lead to high memory consumption for large inputs or complex grammars, a common criticism of the algorithm.