function ParserAbstract::getExpectedTokens
Get limited number of expected tokens in given state.
Parameters
int $state State:
Return value
string[] Expected tokens. If too many, an empty array is returned.
1 call to ParserAbstract::getExpectedTokens()
- ParserAbstract::getErrorMessage in vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php - Format error message including expected tokens.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php, line 446
Class
Namespace
PhpParserCode
protected function getExpectedTokens(int $state) : array {
$expected = [];
$base = $this->actionBase[$state];
foreach ($this->symbolToName as $symbol => $name) {
$idx = $base + $symbol;
if ($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol || $state < $this->YY2TBLSTATE && ($idx = $this->actionBase[$state + $this->numNonLeafStates] + $symbol) >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol) {
if ($this->action[$idx] !== $this->unexpectedTokenRule && $this->action[$idx] !== $this->defaultAction && $symbol !== $this->errorSymbol) {
if (count($expected) === 4) {
/* Too many expected tokens */
return [];
}
$expected[] = $name;
}
}
}
return $expected;
}