mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 12:35:05 +01:00
8f623fb241
The dispatch using $this->{'reduceRule' . $rule}() is very expensive because it involves * One allocation when converting $rule to a string * Another allocation when concatenating the two strings * Lowercasing during the method call * Various uncached method checks, e.g. visibility. Using an array of closures for semantic action dispatch is significantly more efficient.
107 lines
2.3 KiB
Plaintext
107 lines
2.3 KiB
Plaintext
<?php
|
|
$meta #
|
|
#semval($) $this->semValue
|
|
#semval($,%t) $this->semValue
|
|
#semval(%n) $stackPos-(%l-%n)
|
|
#semval(%n,%t) $stackPos-(%l-%n)
|
|
|
|
namespace PhpParser\Parser;
|
|
|
|
use PhpParser\Error;
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Expr;
|
|
use PhpParser\Node\Name;
|
|
use PhpParser\Node\Scalar;
|
|
use PhpParser\Node\Stmt;
|
|
#include;
|
|
|
|
/* This is an automatically GENERATED file, which should not be manually edited.
|
|
* Instead edit one of the following:
|
|
* * the grammar files grammar/php5.y or grammar/php7.y
|
|
* * the skeleton file grammar/parser.template
|
|
* * the preprocessing script grammar/rebuildParsers.php
|
|
*/
|
|
class #(-p) extends \PhpParser\ParserAbstract
|
|
{
|
|
protected $tokenToSymbolMapSize = #(YYMAXLEX);
|
|
protected $actionTableSize = #(YYLAST);
|
|
protected $gotoTableSize = #(YYGLAST);
|
|
|
|
protected $invalidSymbol = #(YYBADCH);
|
|
protected $errorSymbol = #(YYINTERRTOK);
|
|
protected $defaultAction = #(YYDEFAULT);
|
|
protected $unexpectedTokenRule = #(YYUNEXPECTED);
|
|
|
|
protected $YY2TBLSTATE = #(YY2TBLSTATE);
|
|
protected $YYNLSTATES = #(YYNLSTATES);
|
|
|
|
protected $symbolToName = array(
|
|
#listvar terminals
|
|
);
|
|
|
|
protected $tokenToSymbol = array(
|
|
#listvar yytranslate
|
|
);
|
|
|
|
protected $action = array(
|
|
#listvar yyaction
|
|
);
|
|
|
|
protected $actionCheck = array(
|
|
#listvar yycheck
|
|
);
|
|
|
|
protected $actionBase = array(
|
|
#listvar yybase
|
|
);
|
|
|
|
protected $actionDefault = array(
|
|
#listvar yydefault
|
|
);
|
|
|
|
protected $goto = array(
|
|
#listvar yygoto
|
|
);
|
|
|
|
protected $gotoCheck = array(
|
|
#listvar yygcheck
|
|
);
|
|
|
|
protected $gotoBase = array(
|
|
#listvar yygbase
|
|
);
|
|
|
|
protected $gotoDefault = array(
|
|
#listvar yygdefault
|
|
);
|
|
|
|
protected $ruleToNonTerminal = array(
|
|
#listvar yylhs
|
|
);
|
|
|
|
protected $ruleToLength = array(
|
|
#listvar yylen
|
|
);
|
|
#if -t
|
|
|
|
protected $productions = array(
|
|
#production-strings;
|
|
);
|
|
#endif
|
|
|
|
protected function initReduceCallbacks() {
|
|
$this->reduceCallbacks = [
|
|
#reduce
|
|
%n => function ($stackPos) {
|
|
%b
|
|
},
|
|
#noact
|
|
%n => function ($stackPos) {
|
|
$this->semValue = $this->semStack[$stackPos];
|
|
},
|
|
#endreduce
|
|
];
|
|
}
|
|
}
|
|
#tailcode;
|