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

Breadcrumb

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

function Parser::parseDirectivePrologues

Parse directive prologues. The result is an array where the first element is the array of parsed nodes and the second element is the array of directive prologues values

Return value

array|null

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

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseDirectivePrologues() {
    $directives = $nodes = array();
    while (($token = $this->scanner
        ->getToken()) && $token->type === Token::TYPE_STRING_LITERAL) {
        $directive = substr($token->value, 1, -1);
        if ($directive === "use strict") {
            $directives[] = $directive;
            $directiveNode = $this->parseStringLiteral();
            $this->assertEndOfStatement();
            $node = $this->createNode("ExpressionStatement", $directiveNode);
            $node->setExpression($directiveNode);
            $nodes[] = $this->completeNode($node);
        }
        else {
            break;
        }
    }
    return count($nodes) ? array(
        $nodes,
        $directives,
    ) : null;
}

API Navigation

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