1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-30 04:19:30 +01:00

Default to using php-yacc to generate the parsers

This commit is contained in:
Nikita Popov 2019-10-19 15:24:38 +02:00
parent 3226eb4086
commit eacc5dbe19
3 changed files with 10 additions and 13 deletions

View File

@ -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": {

View File

@ -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.

View File

@ -15,14 +15,8 @@ $tokensResultsFile = $resultDir . '/Tokens.php';
$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);