function Parser::parseConditionalExpression
Parses a conditional expression
Return value
Node\Node|null
1 call to Parser::parseConditionalExpression()
- Parser::parseAssignmentExpression in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an assignment expression
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 3101
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseConditionalExpression() {
if ($test = $this->parseLogicalBinaryExpression()) {
if ($this->scanner
->consume("?")) {
$consequent = $this->isolateContext(array(
"allowIn" => true,
), "parseAssignmentExpression");
if ($consequent && $this->scanner
->consume(":") && ($alternate = $this->parseAssignmentExpression())) {
$node = $this->createNode("ConditionalExpression", $test);
$node->setTest($test);
$node->setConsequent($consequent);
$node->setAlternate($alternate);
return $this->completeNode($node);
}
$this->error();
}
else {
return $test;
}
}
return null;
}