public function parsePrimaryExpression() {
$token = $this->parser
->getCurrentToken();
switch ($token
->getType()) {
case Twig_Token::NAME_TYPE:
$this->parser
->getStream()
->next();
switch ($token
->getValue()) {
case 'true':
case 'TRUE':
$node = new Twig_Node_Expression_Constant(true, $token
->getLine());
break;
case 'false':
case 'FALSE':
$node = new Twig_Node_Expression_Constant(false, $token
->getLine());
break;
case 'none':
case 'NONE':
case 'null':
case 'NULL':
$node = new Twig_Node_Expression_Constant(null, $token
->getLine());
break;
default:
if ('(' === $this->parser
->getCurrentToken()
->getValue()) {
$node = $this
->getFunctionNode($token
->getValue(), $token
->getLine());
}
else {
$node = new Twig_Node_Expression_Name($token
->getValue(), $token
->getLine());
}
}
break;
case Twig_Token::NUMBER_TYPE:
$this->parser
->getStream()
->next();
$node = new Twig_Node_Expression_Constant($token
->getValue(), $token
->getLine());
break;
case Twig_Token::STRING_TYPE:
case Twig_Token::INTERPOLATION_START_TYPE:
$node = $this
->parseStringExpression();
break;
default:
if ($token
->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
$node = $this
->parseArrayExpression();
}
elseif ($token
->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
$node = $this
->parseHashExpression();
}
else {
throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token
->getType(), $token
->getLine()), $token
->getValue()), $token
->getLine(), $this->parser
->getFilename());
}
}
return $this
->parsePostfixExpression($node);
}