public function Twig_ExpressionParser::parseExpression in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/ExpressionParser.php \Twig_ExpressionParser::parseExpression()
8 calls to Twig_ExpressionParser::parseExpression()
- Twig_ExpressionParser::getPrimary in vendor/
twig/ twig/ lib/ Twig/ ExpressionParser.php - Twig_ExpressionParser::parseArguments in vendor/
twig/ twig/ lib/ Twig/ ExpressionParser.php - Parses arguments.
- Twig_ExpressionParser::parseArrayExpression in vendor/
twig/ twig/ lib/ Twig/ ExpressionParser.php - Twig_ExpressionParser::parseConditionalExpression in vendor/
twig/ twig/ lib/ Twig/ ExpressionParser.php - Twig_ExpressionParser::parseHashExpression in vendor/
twig/ twig/ lib/ Twig/ ExpressionParser.php
File
- vendor/
twig/ twig/ lib/ 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;
}