protected function parseLiteralExpression()
{
$token = $this->stream->getCurrentToken();
switch ($token->getType()) {
case Token::CONSTANT:
$this->stream->next();
switch ($token->getValue()) {
case 'true':
$node = new Expression\ConstantExpression(true, $token->getLine());
break;
case 'false':
$node = new Expression\ConstantExpression(false, $token->getLine());
break;
case 'null':
$node = new Expression\ConstantExpression(null, $token->getLine());
break;
}
break;
case Token::NUMBER:
$this->stream->next();
if (preg_match('/\\./', $token->getValue())) {
$node = new Expression\ConstantExpression(floatval($token->getValue()), $token->getLine());
} else {
$node = new Expression\ConstantExpression(intval($token->getValue()), $token->getLine());
}
break;
case Token::STRING:
$this->stream->next();
$node = new Expression\StringExpression(strval($token->getValue()), $token->getLine());
break;
default:
throw new SyntaxError(sprintf('unexpected "%s", expecting an expression', str_replace("\n", '\\n', $token->getValue())), $token);
}
return $this->parsePostfixExpression($node);
}