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