xref: /PHP-Parser/grammar/README.md (revision bf39f6a4)
1What do all those files mean?
2=============================
3
4 * `php.y`:              PHP 5-8 grammar written in a pseudo language
5 * `parser.template`:    A `kmyacc` parser prototype file for PHP
6 * `rebuildParsers.php`: Preprocesses the grammar and builds the parser using `kmyacc`
7
8.phpy pseudo language
9=====================
10
11The `.y` file is a normal grammar in `kmyacc` (`yacc`) style, with some transformations
12applied to it:
13
14 * Nodes are created using the syntax `Name[..., ...]`. This is transformed into
15   `new Name(..., ..., attributes())`
16 * Some function-like constructs are resolved (see `rebuildParsers.php` for a list)
17
18Building the parser
19===================
20
21Run `php grammar/rebuildParsers.php` to rebuild the parsers. Additional options:
22
23 * The `KMYACC` environment variable can be used to specify an alternative `kmyacc` binary.
24   By default the `phpyacc` dev dependency will be used. To use the original `kmyacc`, you
25   need to compile [moriyoshi's fork](https://github.com/moriyoshi/kmyacc-forked).
26 * The `--debug` option enables emission of debug symbols and creates the `y.output` file.
27 * The `--keep-tmp-grammar` option preserves the preprocessed grammar file.
28