Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ParserAbstract.php

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

ParserAbstract

Namespace

PhpParser

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal