You are here

public function Twig_ExpressionParser::parseExpression in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/ExpressionParser.php \Twig_ExpressionParser::parseExpression()
8 calls to Twig_ExpressionParser::parseExpression()
Twig_ExpressionParser::getPrimary in vendor/Twig/ExpressionParser.php
Twig_ExpressionParser::parseArguments in vendor/Twig/ExpressionParser.php
Parses arguments.
Twig_ExpressionParser::parseArrayExpression in vendor/Twig/ExpressionParser.php
Twig_ExpressionParser::parseConditionalExpression in vendor/Twig/ExpressionParser.php
Twig_ExpressionParser::parseHashExpression in vendor/Twig/ExpressionParser.php

... See full list

File

vendor/Twig/ExpressionParser.php, line 39

Class

Twig_ExpressionParser
Parses expressions.

Code

public function parseExpression($precedence = 0) {
  $expr = $this
    ->getPrimary();
  $token = $this->parser
    ->getCurrentToken();
  while ($this
    ->isBinary($token) && $this->binaryOperators[$token
    ->getValue()]['precedence'] >= $precedence) {
    $op = $this->binaryOperators[$token
      ->getValue()];
    $this->parser
      ->getStream()
      ->next();
    if (isset($op['callable'])) {
      $expr = call_user_func($op['callable'], $this->parser, $expr);
    }
    else {
      $expr1 = $this
        ->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
      $class = $op['class'];
      $expr = new $class($expr, $expr1, $token
        ->getLine());
    }
    $token = $this->parser
      ->getCurrentToken();
  }
  if (0 === $precedence) {
    return $this
      ->parseConditionalExpression($expr);
  }
  return $expr;
}