protected function Twig_ExpressionParser::parseConditionalExpression

1 call to Twig_ExpressionParser::parseConditionalExpression()
Twig_ExpressionParser::parseExpression in drupal/core/vendor/twig/twig/lib/Twig/ExpressionParser.php

File

drupal/core/vendor/twig/twig/lib/Twig/ExpressionParser.php, line 88

Class

Twig_ExpressionParser
Parses expressions.

Code

protected function parseConditionalExpression($expr) {
  while ($this->parser
    ->getStream()
    ->test(Twig_Token::PUNCTUATION_TYPE, '?')) {
    $this->parser
      ->getStream()
      ->next();
    $expr2 = $this
      ->parseExpression();
    $this->parser
      ->getStream()
      ->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'The ternary operator must have a default value');
    $expr3 = $this
      ->parseExpression();
    $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser
      ->getCurrentToken()
      ->getLine());
  }
  return $expr;
}