You are here

protected function Twig_ExpressionParser::parseConditionalExpression in Translation template extractor 6.3

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

File

vendor/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;
}