1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-12 09:29:47 +01:00
PHP-Parser/grammar/rebuildParser.php

33 lines
715 B
PHP
Raw Normal View History

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