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

Breadcrumb

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

function Parser::parseLabelledStatement

Parses a labelled statement

Return value

Node\LabeledStatement|null

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

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseLabelledStatement() {
    if ($label = $this->parseIdentifier(static::$labelledIdentifier, ":")) {
        $this->scanner
            ->consume(":");
        if (($body = $this->parseStatement()) || ($body = $this->parseFunctionOrGeneratorDeclaration(false, false))) {
            
            //Labelled functions are not allowed in strict mode
            if ($body instanceof Node\FunctionDeclaration && $this->scanner
                ->getStrictMode()) {
                $this->error("Labelled functions are not allowed in strict mode");
            }
            $node = $this->createNode("LabeledStatement", $label);
            $node->setLabel($label);
            $node->setBody($body);
            return $this->completeNode($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