php-parser/grammar/rebuildParser.php

51 lines
1.1 KiB
PHP
Raw Normal View History

<?php
echo '<pre>';
echo 'Building parser. Output: "',
trim(`kmyacc -l -L c -m php.kmyacc -p PHPParser_Parser zend_language_parser.phpy 2>&1`),
'"', "\n";
$source = file_get_contents('y.tab.c');
$source = str_replace(
array(
'"$EOF"',
'#',
),
array(
'\'$EOF\'',
'$',
),
$source
);
2011-06-05 18:40:04 +02:00
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: "',
trim(`kmyacc -l -t -L c -m php.kmyacc -p PHPParser_ParserDebug zend_language_parser.phpy 2>&1`),
'"', "\n";
$source = file_get_contents('y.tab.c');
$source = str_replace(
array(
'"$EOF"',
'"$start : start"',
'#',
),
array(
'\'$EOF\'',
'\'$start : start\'',
'$',
),
$source
);
2011-06-05 18:40:04 +02:00
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>';