php-parser/grammar/rebuildParser.php

51 lines
1.1 KiB
PHP

<?php
echo '<pre>';
echo 'Building parser. Output: "',
`kmyacc -l -v -L c -m php.kmyacc -p PHPParser_Parser zend_language_parser.phpy`,
'"', "\n";
$source = file_get_contents('y.tab.c');
$source = str_replace(
array(
'"$EOF"',
'#',
),
array(
'\'$EOF\'',
'$',
),
$source
);
echo 'Moving parser to lib/PHPParser/Parser.php.', "\n";
file_put_contents(dirname(__DIR__) . '/lib/PHPParser/Parser.php', $source);
unlink(__DIR__ . '/y.tab.c');
echo 'Building debug parser. Output: "',
`kmyacc -l -v -t -L c -m php.kmyacc -p PHPParser_ParserDebug zend_language_parser.phpy`,
'"', "\n";
$source = file_get_contents('y.tab.c');
$source = str_replace(
array(
'"$EOF"',
'"$start : start"',
'#',
),
array(
'\'$EOF\'',
'\'$start : start\'',
'$',
),
$source
);
echo 'Moving debug parser to lib/PHPParser/ParserDebug.php.', "\n";
file_put_contents(dirname(__DIR__) . '/lib/PHPParser/ParserDebug.php', $source);
unlink(__DIR__ . '/y.tab.c');
echo 'Done.';
echo '</pre>';