PHPackages                             ircmaxell/php-yacc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ircmaxell/php-yacc

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ircmaxell/php-yacc
==================

A PHP YACC Parser-Generator library

v0.0.8(5mo ago)156110.2k↑45.4%15[2 issues](https://github.com/ircmaxell/PHP-Yacc/issues)[1 PRs](https://github.com/ircmaxell/PHP-Yacc/pulls)10Apache-2.0PHPPHP &gt;=8.1CI failing

Since Oct 19Pushed 2mo ago9 watchersCompare

[ Source](https://github.com/ircmaxell/PHP-Yacc)[ Packagist](https://packagist.org/packages/ircmaxell/php-yacc)[ RSS](/packages/ircmaxell-php-yacc/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (5)Versions (11)Used By (10)

PHP-Yacc
========

[](#php-yacc)

This is a port of [`kmyacc`](https://github.com/moriyoshi/kmyacc-forked) into PHP. It is a parser-generator, meaning it takes a YACC grammar file and generates a parser file.

A Direct Port (For Now)
-----------------------

[](#a-direct-port-for-now)

Right now, this is a direct port. Meaning that it works exactly like `kmyacc`. Looking in the examples, you can see that this means that you must supply a "parser template" in addition to the grammar.

Longer term, we want to add simplifying functionality. We will always support providing a template, but we will offer a series of default templates for common use-cases.

What can I do with this?
------------------------

[](#what-can-i-do-with-this)

You can parse most structured and unstructured grammars. There are some gotchas to [LALR(1) parsers](https://en.wikipedia.org/wiki/LALR_parser) that you need to be aware of (for example, Shift/Shift conflicts and Shift/Reduce conflicts). But those are beyond this simple intro.

How does it work?
-----------------

[](#how-does-it-work)

I don't know. I just ported the code until it worked correctly.

YACC Grammar
------------

[](#yacc-grammar)

That's way beyond the scope of this documentation, but checkout [The YACC page here](http://dinosaur.compilertools.net/yacc/) for some info.

Over time we will document the grammar more...

How do I use it?
----------------

[](#how-do-i-use-it)

For now, check out the examples folder. The current state of the CLI tool will change, so any usage today should please provide feedback and use-cases so that we can better design the tooling support.

Why did you do this?
--------------------

[](#why-did-you-do-this)

Many projects have the need for parsers (and therefore parser-generators). Nikita's [PHP-Parser](https://github.com/nikic/PHP-Parser) is one tool that uses kmyacc to generate its parser. There are many other projects out there that either use hand-written parsers, or use kmyacc or another parser-generator.

Unfortunately, not many parser-generators exist for PHP. And those that do exist I have found to be rigid or not powerful enough to parse PHP itself.

This project is an aim to resolve that.

Performance
-----------

[](#performance)

There's a TON of performance optimizations possible here. The original code was a direct port, so some structures are definitely sub-optimal. Over time we will improve the performance.

However, this will always be at least a slightly-slow process. Generating a parser requires a lot of resources, so should never happen inside of a web request.

Using the generated parser however should be quite fast (the generated parser is fairly well optimized already).

What's left to do?
------------------

[](#whats-left-to-do)

A bunch of things. Here's the wishlist:

- Refactor to make conventions consistent (some parts currently use camelCase, some parts use snake\_case, etc).
- Performance tuning
- Unit test as much as possible
- Document as much as possible (It's a complicated series of algorithms with no source documentation in either project).
- Redesign the CLI binary and how it operates
- Decide whether multi-language support is worth while, or if we should just move to only PHP codegen support.
- Add default templates and parser implementations
    - At least one of which generates an "AST" by default, similar to Ruby's [Treetop library](https://github.com/nathansobo/treetop)
- Build a reasonably performant lexer-generator (very likely as a separate project)
- A lot of debugging (though we don't know of any bugs, they are there)
- Building out of features we didn't need for the initial go (for example, support for `%union`, etc).

And a lot more.

Contributing
------------

[](#contributing)

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance79

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 51.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~328 days

Recently: every ~574 days

Total

8

Last Release

154d ago

PHP version history (2 changes)v0.0.1PHP &gt;=7.0

v0.0.8PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a66e9e6117ecedd55b7cbfe3cd6a74d6f785be1b9f9e512b5a225b95b19f4d4b?d=identicon)[nikic](/maintainers/nikic)

![](https://www.gravatar.com/avatar/c87a667fe5a109ed083ba784409a76f0a18f30b0a05445fbb8ef5e4520b7a6e1?d=identicon)[ircmaxell](/maintainers/ircmaxell)

---

Top Contributors

[![nikic](https://avatars.githubusercontent.com/u/216080?v=4)](https://github.com/nikic "nikic (66 commits)")[![ircmaxell](https://avatars.githubusercontent.com/u/660654?v=4)](https://github.com/ircmaxell "ircmaxell (45 commits)")[![theodorejb](https://avatars.githubusercontent.com/u/3053271?v=4)](https://github.com/theodorejb "theodorejb (13 commits)")[![mecha](https://avatars.githubusercontent.com/u/5425482?v=4)](https://github.com/mecha "mecha (1 commits)")[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (1 commits)")[![stenin-nikita](https://avatars.githubusercontent.com/u/8615201?v=4)](https://github.com/stenin-nikita "stenin-nikita (1 commits)")[![SVGAnimate](https://avatars.githubusercontent.com/u/76270254?v=4)](https://github.com/SVGAnimate "SVGAnimate (1 commits)")[![bwoebi](https://avatars.githubusercontent.com/u/3154871?v=4)](https://github.com/bwoebi "bwoebi (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ircmaxell-php-yacc/health.svg)

```
[![Health](https://phpackages.com/badges/ircmaxell-php-yacc/health.svg)](https://phpackages.com/packages/ircmaxell-php-yacc)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
