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

Breadcrumb

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

function Parser::parseIterationStatement

Parses do-while, while, for, for-in and for-of statements

Return value

Node\Node|null

1 call to Parser::parseIterationStatement()
Parser::parseBreakableStatement in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a breakable statement

File

vendor/mck89/peast/lib/Peast/Syntax/Parser.php, line 1357

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseIterationStatement() {
    if ($node = $this->parseWhileStatement()) {
        return $node;
    }
    elseif ($node = $this->parseDoWhileStatement()) {
        return $node;
    }
    elseif ($startForToken = $this->scanner
        ->consume("for")) {
        $forAwait = false;
        if ($this->features->asyncIterationGenerators && $this->context->allowAwait && $this->scanner
            ->consume("await")) {
            $forAwait = true;
        }
        if ($this->scanner
            ->consume("(") && (($node = $this->parseForVarStatement($startForToken)) || ($node = $this->parseForLetConstStatement($startForToken)) || ($node = $this->parseForNotVarLetConstStatement($startForToken, $forAwait)))) {
            if ($forAwait) {
                if (!$node instanceof Node\ForOfStatement) {
                    $this->error("Async iteration is allowed only with for-of statements", $startForToken->location->start);
                }
                $node->setAwait(true);
            }
            return $node;
        }
        $this->error();
    }
    return null;
}

API Navigation

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