You are here

protected function Twig_ExpressionParser::parseConditionalExpression in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/ExpressionParser.php \Twig_ExpressionParser::parseConditionalExpression()
1 call to Twig_ExpressionParser::parseConditionalExpression()
Twig_ExpressionParser::parseExpression in vendor/twig/twig/lib/Twig/ExpressionParser.php

File

vendor/twig/twig/lib/Twig/ExpressionParser.php, line 87

Class

Twig_ExpressionParser
Parses expressions.

Code

protected function parseConditionalExpression($expr) {
  while ($this->parser
    ->getStream()
    ->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
    if (!$this->parser
      ->getStream()
      ->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
      $expr2 = $this
        ->parseExpression();
      if ($this->parser
        ->getStream()
        ->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
        $expr3 = $this
          ->parseExpression();
      }
      else {
        $expr3 = new Twig_Node_Expression_Constant('', $this->parser
          ->getCurrentToken()
          ->getLine());
      }
    }
    else {
      $expr2 = $expr;
      $expr3 = $this
        ->parseExpression();
    }
    $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser
      ->getCurrentToken()
      ->getLine());
  }
  return $expr;
}