Skip to content

Commit

Permalink
Default to using php-yacc to generate the parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 19, 2019
1 parent 3226eb4 commit eacc5db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"ext-tokenizer": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0"
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0",
"ircmaxell/php-yacc": "0.0.4"
},
"extra": {
"branch-alias": {
Expand Down
10 changes: 6 additions & 4 deletions grammar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ applied to it:
Building the parser
===================

In order to rebuild the parser, you need [moriyoshi's fork of kmyacc](https://github.com/moriyoshi/kmyacc-forked).
After you compiled/installed it, run the `rebuildParsers.php` script.
Run `php grammar/rebuildParsers.php` to rebuild the parsers. Additional options:

By default only the `Parser.php` is built. If you want to additionally emit debug symbols and create `y.output`, run the
script with `--debug`. If you want to retain the preprocessed grammar pass `--keep-tmp-grammar`.
* The `KMYACC` environment variable can be used to specify an alternative `kmyacc` binary.
By default the `phpyacc` dev dependency will be used. To use the original `kmyacc`, you
need to compile [moriyoshi's fork](https://github.com/moriyoshi/kmyacc-forked).
* The `--debug` option enables emission of debug symbols and creates the `y.output` file.
* The `--keep-tmp-grammar` option preserves the preprocessed grammar file.
10 changes: 2 additions & 8 deletions grammar/rebuildParsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@

$kmyacc = getenv('KMYACC');
if (!$kmyacc) {
// Check for kmyacc binary in this directory, otherwise fall back to global name
if (file_exists(__DIR__ . '/kmyacc.exe')) {
$kmyacc = __DIR__ . '/kmyacc.exe';
} else if (file_exists(__DIR__ . '/kmyacc')) {
$kmyacc = __DIR__ . '/kmyacc';
} else {
$kmyacc = 'kmyacc';
}
// Use phpyacc from dev dependencies by default.
$kmyacc = PHP_BINARY . ' ' . __DIR__ . '/../vendor/bin/phpyacc';
}

$options = array_flip($argv);
Expand Down

0 comments on commit eacc5db

Please sign in to comment.