1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2025-01-22 22:01:18 +01:00
PHP-Parser/grammar/rebuildParser.php
2011-06-05 18:40:04 +02:00

43 lines
1003 B
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(
'"$EOF"',
'\'$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>';