function Parser::parseArgumentList
Parses an arguments list
Return value
array|null
1 call to Parser::parseArgumentList()
- Parser::parseArguments in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an arguments list wrapped in round brackets
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 3596
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseArgumentList() {
$list = array();
$hasComma = false;
while (true) {
$spread = $this->scanner
->consume("...");
$exp = $this->isolateContext(array(
"allowIn" => true,
), "parseAssignmentExpression");
if (!$exp) {
//If there's no expression and the spread dots have been found
//or there is a trailing comma that is not allowed, throw an
//error
if ($spread || $hasComma && !$this->features->trailingCommaFunctionCallDeclaration) {
$this->error();
}
break;
}
if ($spread) {
$node = $this->createNode("SpreadElement", $spread);
$node->setArgument($exp);
$list[] = $this->completeNode($node);
}
else {
$list[] = $exp;
}
if (!$this->scanner
->consume(",")) {
break;
}
$hasComma = true;
}
return $list;
}