Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Yacc Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Custom Language Development: Enables rapid prototyping of domain-specific languages (DSLs) or internal query/configuration languages (e.g., for Laravel-based workflows, API contracts, or policy engines) where existing tools (ANTLR, PEG.js) lack PHP-native support.
  • Build vs. Buy: Justifies internal investment in parser tooling for niche use cases (e.g., parsing legacy formats, custom rule engines) where off-the-shelf solutions are either too rigid or require non-PHP dependencies. Avoids vendor lock-in but requires upfront maintenance commitment.
  • Roadmap Alignment: Prioritizes projects with:
    • Simple grammars (e.g., arithmetic expressions, JSON-like configs) where LALR(1) limitations are acceptable.
    • Internal tooling (e.g., CLI tools, admin panels) where parser performance at runtime is secondary to development speed.
    • Forkable maintenance model—teams willing to adopt the package as a subproject (e.g., forking, patching, or replacing core components).
  • Laravel-Specific Use Cases:
    • Dynamic Configuration Parsers: Parse app-specific YAML/JSON-like configs with custom validation rules (e.g., for feature flags or A/B test definitions).
    • Query Builders: Generate parsers for custom query languages (e.g., filtering rules for Eloquent-like queries).
    • Migration Helpers: Parse legacy database schemas or migration scripts into structured ASTs for automated refactoring.

When to Consider This Package

  • Adopt When:

    • You need a PHP-native parser generator for a non-critical, short-term project (e.g., PoCs, internal scripts).
    • Your grammar is simple (avoids Shift/Reduce conflicts, no left-recursion) and can be expressed in LALR(1).
    • You can commit to maintenance (forking, patching, or replacing components) and have PHP expertise to debug generated code.
    • You’re parsing textual data with predictable structure (e.g., logs, configs, or DSLs) where runtime performance is not the bottleneck.
    • You’re not constrained by PHP version upgrades (last release predates PHP 8.2 features).
  • Look Elsewhere When:

    • Production-Critical Systems: Use ANTLR with PHP bindings or Nikita’s PHP-Parser (which already uses kmyacc under the hood) for stability.
    • Complex Grammars: Require %union, %type, or operator precedence—consider PEG.js (via JS interop) or custom recursive descent parsers.
    • High Throughput: Need sub-millisecond parsing—generated parsers are fast, but the toolchain itself is slow (not for runtime generation).
    • Legal/Compliance Needs: The NOASSERTION license may require review; prefer MIT/BSD-licensed alternatives.
    • Long-Term Support: No releases since 2020; prefer actively maintained tools like Symfony’s YAML/XML parsers for standard formats.

How to Pitch It (Stakeholders)

  • 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.7 and patch as needed.
    • CI-only generation: Run phpyacc in CI; commit generated code.
    • Simple grammars only: Avoid Shift/Reduce conflicts; use -n for named semantic values.
    • Debugging: Expect to log lexer output and inspect stderr for 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."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope