protected function Twig_ExpressionParser::getPrimary in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/ExpressionParser.php \Twig_ExpressionParser::getPrimary()
1 call to Twig_ExpressionParser::getPrimary()
- Twig_ExpressionParser::parseExpression in vendor/
Twig/ ExpressionParser.php
File
- vendor/
Twig/ ExpressionParser.php, line 65
Class
- Twig_ExpressionParser
- Parses expressions.
Code
protected function getPrimary() {
$token = $this->parser
->getCurrentToken();
if ($this
->isUnary($token)) {
$operator = $this->unaryOperators[$token
->getValue()];
$this->parser
->getStream()
->next();
$expr = $this
->parseExpression($operator['precedence']);
$class = $operator['class'];
return $this
->parsePostfixExpression(new $class($expr, $token
->getLine()));
}
elseif ($token
->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$this->parser
->getStream()
->next();
$expr = $this
->parseExpression();
$this->parser
->getStream()
->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
return $this
->parsePostfixExpression($expr);
}
return $this
->parsePrimaryExpression();
}