} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$this->parser->getStream()->next();
$expr = $this->parseExpression();
- $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')');
+ $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
return $this->parsePostfixExpression($expr);
}
while ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '?')) {
$this->parser->getStream()->next();
$expr2 = $this->parseExpression();
- $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ':');
+ $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'The ternary operator must have a default value');
$expr3 = $this->parseExpression();
$expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
public function parseArrayExpression()
{
$stream = $this->parser->getStream();
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
$elements = array();
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
if (!empty($elements)) {
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma (,)');
// trailing ,?
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
$elements[] = $this->parseExpression();
}
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
return new Twig_Node_Expression_Array($elements, $stream->getCurrent()->getLine());
}
public function parseHashExpression()
{
$stream = $this->parser->getStream();
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
$elements = array();
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
if (!empty($elements)) {
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma (,)');
// trailing ,?
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
}
$key = $stream->next()->getValue();
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
$elements[$key] = $this->parseExpression();
}
- $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}');
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
return new Twig_Node_Expression_Array($elements, $stream->getCurrent()->getLine());
}
$args = array();
while (!$parser->test(Twig_Token::PUNCTUATION_TYPE, ')')) {
if (!empty($args)) {
- $parser->expect(Twig_Token::PUNCTUATION_TYPE, ',');
+ $parser->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma (,)');
}
$args[] = $this->parseExpression();
}
- $parser->expect(Twig_Token::PUNCTUATION_TYPE, ')');
+ $parser->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
return new Twig_Node($args);
}
$targets = array();
while (true) {
if (!empty($targets)) {
- $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ',');
+ $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Multiple assignments must be separated by a comma (,)');
}
if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ')') ||
$this->parser->getStream()->test(Twig_Token::VAR_END_TYPE) ||
$is_multitarget = false;
while (true) {
if (!empty($targets)) {
- $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ',');
+ $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Multiple assignments must be separated by a comma (,)');
}
if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ')') ||
$this->parser->getStream()->test(Twig_Token::VAR_END_TYPE) ||