mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-12-02 09:27:58 +01:00
45 lines
904 B
PHP
45 lines
904 B
PHP
<?php
|
|
|
|
function __autoload($class) {
|
|
is_file($file = './lib/' . strtr($class, '_', '/') . '.php') && require_once $file;
|
|
}
|
|
|
|
echo '<pre>';
|
|
|
|
$parser = new Parser;
|
|
$prettyPrinter = new PrettyPrinter_Zend;
|
|
$nodeDumper = new NodeDumper;
|
|
|
|
// Output Demo
|
|
$stmts = $parser->yyparse(new Lexer(
|
|
'<?php
|
|
x::$y[z];
|
|
$x->y[z];
|
|
$x->y[z][k]->l()->m[t];
|
|
$x->y[z]();
|
|
$x->$y[z]();
|
|
$x->$$y[z]();'
|
|
),
|
|
function ($msg) {
|
|
echo $msg;
|
|
}
|
|
);
|
|
|
|
if (false !== $stmts) {
|
|
echo htmlspecialchars($nodeDumper->dump($stmts));
|
|
}
|
|
|
|
echo "\n\n";
|
|
|
|
$code = $prettyPrinter->pStmts(
|
|
$parser->yyparse(
|
|
new Lexer(file_get_contents(
|
|
'../symfonySandbox\src\vendor\symfony\src\Symfony\Components\Console\Input\InputDefinition.php'
|
|
)),
|
|
function ($msg) {
|
|
echo $msg;
|
|
}
|
|
)
|
|
);
|
|
|
|
echo htmlspecialchars($code); |