ircmaxell/php-yacc
PHP port of kmyacc: a YACC/LALR(1) parser generator. Feed it a YACC grammar plus a parser template to generate a PHP parser. Useful for building fast parsers for structured languages; generation is resource-heavy, runtime parsing is efficient.
Adopt When:
Look Elsewhere When:
kmyacc under the hood) for stability.To Executives:
"This package lets us build custom language tools—like domain-specific query engines or config parsers—without heavy engineering debt. For example, we could replace manual parsing of legacy formats with a maintainable, generated parser in weeks. While it’s not production-grade, it’s a tactical win for internal tools where we control the grammar and can own its maintenance. The trade-off is minimal upfront cost for projects where off-the-shelf solutions are overkill."
To Engineering:
*"We’ll use this to generate parsers once at build time (never at runtime), with semantic actions to build ASTs. Key constraints:
- Fork and maintain: Last release is 2020; we’ll pin to
~0.0.7and patch as needed.- CI-only generation: Run
phpyaccin CI; commit generated code.- Simple grammars only: Avoid Shift/Reduce conflicts; use
-nfor named semantic values.- Debugging: Expect to log lexer output and inspect
stderrfor parser conflicts. Pros: Faster iteration than hand-written parsers. Cons: No active support; requires YACC expertise. Ideal for internal tools where we can control the grammar."*
To Architects:
*"This fills a gap in PHP’s parser ecosystem but comes with trade-offs:
- Pros: Native PHP, no external dependencies, flexible for custom grammars.
- Cons: High maintenance risk, no Laravel integrations, and missing YACC features (e.g.,
%union). Recommendation: Use for non-critical projects where the team can commit to ownership. For production systems, pair with a maintained lexer (e.g.,symfony/flex) or evaluate ANTLR-PHP."*
How can I help you explore Laravel packages today?