Rename YYNLSTATES to numNonLeafStates

This commit is contained in:
Nikita Popov 2017-11-12 15:58:24 +01:00
parent c59e75f873
commit a75164c77e
4 changed files with 18 additions and 17 deletions

View File

@ -32,8 +32,8 @@ class #(-p) extends \PhpParser\ParserAbstract
protected $defaultAction = #(YYDEFAULT); protected $defaultAction = #(YYDEFAULT);
protected $unexpectedTokenRule = #(YYUNEXPECTED); protected $unexpectedTokenRule = #(YYUNEXPECTED);
protected $YY2TBLSTATE = #(YY2TBLSTATE); protected $YY2TBLSTATE = #(YY2TBLSTATE);
protected $YYNLSTATES = #(YYNLSTATES); protected $numNonLeafStates = #(YYNLSTATES);
protected $symbolToName = array( protected $symbolToName = array(
#listvar terminals #listvar terminals

View File

@ -26,8 +26,8 @@ class Php5 extends \PhpParser\ParserAbstract
protected $defaultAction = -32766; protected $defaultAction = -32766;
protected $unexpectedTokenRule = 32767; protected $unexpectedTokenRule = 32767;
protected $YY2TBLSTATE = 404; protected $YY2TBLSTATE = 404;
protected $YYNLSTATES = 669; protected $numNonLeafStates = 669;
protected $symbolToName = array( protected $symbolToName = array(
"EOF", "EOF",

View File

@ -26,8 +26,8 @@ class Php7 extends \PhpParser\ParserAbstract
protected $defaultAction = -32766; protected $defaultAction = -32766;
protected $unexpectedTokenRule = 32767; protected $unexpectedTokenRule = 32767;
protected $YY2TBLSTATE = 328; protected $YY2TBLSTATE = 328;
protected $YYNLSTATES = 578; protected $numNonLeafStates = 578;
protected $symbolToName = array( protected $symbolToName = array(
"EOF", "EOF",

View File

@ -46,7 +46,8 @@ abstract class ParserAbstract implements Parser
protected $unexpectedTokenRule; protected $unexpectedTokenRule;
protected $YY2TBLSTATE; protected $YY2TBLSTATE;
protected $YYNLSTATES; /** @var int Number of non-leaf states */
protected $numNonLeafStates;
/** @var int[] Map of lexer tokens to internal symbols */ /** @var int[] Map of lexer tokens to internal symbols */
protected $tokenToSymbol; protected $tokenToSymbol;
@ -231,11 +232,11 @@ abstract class ParserAbstract implements Parser
$idx = $this->actionBase[$state] + $symbol; $idx = $this->actionBase[$state] + $symbol;
if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol) if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol)
|| ($state < $this->YY2TBLSTATE || ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol)) && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol))
&& ($action = $this->action[$idx]) !== $this->defaultAction) { && ($action = $this->action[$idx]) !== $this->defaultAction) {
/* /*
* >= YYNLSTATES: shift and reduce * >= numNonLeafStates: shift and reduce
* > 0: shift * > 0: shift
* = 0: accept * = 0: accept
* < 0: reduce * < 0: reduce
@ -257,12 +258,12 @@ abstract class ParserAbstract implements Parser
--$this->errorState; --$this->errorState;
} }
if ($action < $this->YYNLSTATES) { if ($action < $this->numNonLeafStates) {
continue; continue;
} }
/* $yyn >= YYNLSTATES means shift-and-reduce */ /* $yyn >= numNonLeafStates means shift-and-reduce */
$rule = $action - $this->YYNLSTATES; $rule = $action - $this->numNonLeafStates;
} else { } else {
$rule = -$action; $rule = -$action;
} }
@ -323,7 +324,7 @@ abstract class ParserAbstract implements Parser
(($idx = $this->actionBase[$state] + $this->errorSymbol) >= 0 (($idx = $this->actionBase[$state] + $this->errorSymbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol) && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol)
|| ($state < $this->YY2TBLSTATE || ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $this->errorSymbol) >= 0 && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $this->errorSymbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol) && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol)
) || ($action = $this->action[$idx]) === $this->defaultAction) { // Not totally sure about this ) || ($action = $this->action[$idx]) === $this->defaultAction) { // Not totally sure about this
if ($stackPos <= 0) { if ($stackPos <= 0) {
@ -356,12 +357,12 @@ abstract class ParserAbstract implements Parser
} }
} }
if ($state < $this->YYNLSTATES) { if ($state < $this->numNonLeafStates) {
break; break;
} }
/* >= YYNLSTATES means shift-and-reduce */ /* >= numNonLeafStates means shift-and-reduce */
$rule = $state - $this->YYNLSTATES; $rule = $state - $this->numNonLeafStates;
} }
} }
@ -404,7 +405,7 @@ abstract class ParserAbstract implements Parser
$idx = $base + $symbol; $idx = $base + $symbol;
if ($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol if ($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol
|| $state < $this->YY2TBLSTATE || $state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol
) { ) {
if ($this->action[$idx] !== $this->unexpectedTokenRule if ($this->action[$idx] !== $this->unexpectedTokenRule