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.
The package is a build-time parser generator, aligning with Laravel’s static code generation patterns (e.g., migrations, factories). However, its template-based generation conflicts with Laravel’s convention-over-configuration philosophy, requiring manual integration via service providers or facades. The generated parser is a standalone PHP class, which can be injected into Laravel’s dependency container but lacks native Laravel abstractions (e.g., no Eloquent model integration or Artisan command scaffolding).
Technically feasible but high-effort due to:
-n for named semantic values introduced in v0.0.7).Critical risks:
%union, %type, or associativity (%left/%right) support—limiting grammar expressiveness.Key Questions:
--dev) to enforce build-time generation.*.y file commits).examples/ grammars in a sandbox project.Illuminate\Support\Collection).%union).template.php to output Laravel-friendly classes (e.g., use Illuminate\Support\Facades\Log).phpyacc as a build step (e.g., phpyacc -n -f grammar.y -t template.php -o app/Generated/Parser.php).pestphp for edge cases).Log facade.phpyacc -v output.| Failure Type | Impact | Mitigation |
|---|---|---|
| Parser generation fails | Build pipeline breaks; no deployments. | Retry logic in CI; fallback to manual generation. |
| Runtime parsing errors | Silent crashes or incorrect ASTs. | Add input validation (e.g., log lexer output for debugging). |
| PHP version mismatch | Generated code breaks on upgrade. | Pin to specific ircmaxell/php-yacc version; test upgrades in staging. |
| Grammar conflicts | Undetected Shift/Reduce conflicts corrupt parsing. | Run phpyacc -v in CI; enforce grammar reviews. |
| License compliance | NOASSERTION license may cause legal risks. | Consult legal team; consider forking under MIT/BSD. |
template.php logic is undocumented.examples/template.php and adapt for Laravel.phpyacc in GitHub Actions/Docker.PHPUnit).How can I help you explore Laravel packages today?