4 * This file is part of Twig.
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
16 * This parser implements a "Precedence climbing" algorithm.
18 * @see http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
19 * @see http://en.wikipedia.org/wiki/Operator-precedence_parser
21 * @author Fabien Potencier <fabien@symfony.com>
25 class Twig_ExpressionParser
27 const OPERATOR_LEFT = 1;
28 const OPERATOR_RIGHT = 2;
31 protected $unaryOperators;
32 protected $binaryOperators;
36 public function __construct(Twig_Parser $parser, $env = null)
38 $this->parser = $parser;
40 if ($env instanceof Twig_Environment) {
42 $this->unaryOperators = $env->getUnaryOperators();
43 $this->binaryOperators = $env->getBinaryOperators();
45 @trigger_error('Passing the operators as constructor arguments to '.__METHOD__.' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
47 $this->env = $parser->getEnvironment();
48 $this->unaryOperators = func_get_arg(1);
49 $this->binaryOperators = func_get_arg(2);
53 public function parseExpression($precedence = 0)
55 $expr = $this->getPrimary();
56 $token = $this->parser->getCurrentToken();
57 while ($this->isBinary($token) && $this->binaryOperators[$token->getValue()]['precedence'] >= $precedence) {
58 $op = $this->binaryOperators[$token->getValue()];
59 $this->parser->getStream()->next();
61 if ('is not' === $token->getValue()) {
62 $expr = $this->parseNotTestExpression($expr);
63 } elseif ('is' === $token->getValue()) {
64 $expr = $this->parseTestExpression($expr);
65 } elseif (isset($op['callable'])) {
66 $expr = call_user_func($op['callable'], $this->parser, $expr);
68 $expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
69 $class = $op['class'];
70 $expr = new $class($expr, $expr1, $token->getLine());
73 $token = $this->parser->getCurrentToken();
76 if (0 === $precedence) {
77 return $this->parseConditionalExpression($expr);
83 protected function getPrimary()
85 $token = $this->parser->getCurrentToken();
87 if ($this->isUnary($token)) {
88 $operator = $this->unaryOperators[$token->getValue()];
89 $this->parser->getStream()->next();
90 $expr = $this->parseExpression($operator['precedence']);
91 $class = $operator['class'];
93 return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
94 } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
95 $this->parser->getStream()->next();
96 $expr = $this->parseExpression();
97 $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
99 return $this->parsePostfixExpression($expr);
102 return $this->parsePrimaryExpression();
105 protected function parseConditionalExpression($expr)
107 while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
108 if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
109 $expr2 = $this->parseExpression();
110 if ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
111 $expr3 = $this->parseExpression();
113 $expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
117 $expr3 = $this->parseExpression();
120 $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
126 protected function isUnary(Twig_Token $token)
128 return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
131 protected function isBinary(Twig_Token $token)
133 return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
136 public function parsePrimaryExpression()
138 $token = $this->parser->getCurrentToken();
139 switch ($token->getType()) {
140 case Twig_Token::NAME_TYPE:
141 $this->parser->getStream()->next();
142 switch ($token->getValue()) {
145 $node = new Twig_Node_Expression_Constant(true, $token->getLine());
150 $node = new Twig_Node_Expression_Constant(false, $token->getLine());
157 $node = new Twig_Node_Expression_Constant(null, $token->getLine());
161 if ('(' === $this->parser->getCurrentToken()->getValue()) {
162 $node = $this->getFunctionNode($token->getValue(), $token->getLine());
164 $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
169 case Twig_Token::NUMBER_TYPE:
170 $this->parser->getStream()->next();
171 $node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
174 case Twig_Token::STRING_TYPE:
175 case Twig_Token::INTERPOLATION_START_TYPE:
176 $node = $this->parseStringExpression();
179 case Twig_Token::OPERATOR_TYPE:
180 if (preg_match(Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
181 // in this context, string operators are variable names
182 $this->parser->getStream()->next();
183 $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
185 } elseif (isset($this->unaryOperators[$token->getValue()])) {
186 $class = $this->unaryOperators[$token->getValue()]['class'];
188 $ref = new ReflectionClass($class);
189 $negClass = 'Twig_Node_Expression_Unary_Neg';
190 $posClass = 'Twig_Node_Expression_Unary_Pos';
191 if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
192 throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
195 $this->parser->getStream()->next();
196 $expr = $this->parsePrimaryExpression();
198 $node = new $class($expr, $token->getLine());
204 if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
205 $node = $this->parseArrayExpression();
206 } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
207 $node = $this->parseHashExpression();
208 } elseif ($token->test(Twig_Token::OPERATOR_TYPE, '=') && ('==' === $this->parser->getStream()->look(-1)->getValue() || '!=' === $this->parser->getStream()->look(-1)->getValue())) {
209 throw new Twig_Error_Syntax(sprintf('Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
211 throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
215 return $this->parsePostfixExpression($node);
218 public function parseStringExpression()
220 $stream = $this->parser->getStream();
223 // a string cannot be followed by another string in a single expression
224 $nextCanBeString = true;
226 if ($nextCanBeString && $token = $stream->nextIf(Twig_Token::STRING_TYPE)) {
227 $nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
228 $nextCanBeString = false;
229 } elseif ($stream->nextIf(Twig_Token::INTERPOLATION_START_TYPE)) {
230 $nodes[] = $this->parseExpression();
231 $stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
232 $nextCanBeString = true;
238 $expr = array_shift($nodes);
239 foreach ($nodes as $node) {
240 $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getTemplateLine());
246 public function parseArrayExpression()
248 $stream = $this->parser->getStream();
249 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
251 $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
253 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
255 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
258 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
264 $node->addElement($this->parseExpression());
266 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
271 public function parseHashExpression()
273 $stream = $this->parser->getStream();
274 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
276 $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
278 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
280 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
283 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
289 // a hash key can be:
293 // * a name, which is equivalent to a string -- a
294 // * an expression, which must be enclosed in parentheses -- (1 + 2)
295 if (($token = $stream->nextIf(Twig_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_Token::NUMBER_TYPE)) {
296 $key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
297 } elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
298 $key = $this->parseExpression();
300 $current = $stream->getCurrent();
302 throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $stream->getSourceContext());
305 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
306 $value = $this->parseExpression();
308 $node->addElement($value, $key);
310 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
315 public function parsePostfixExpression($node)
318 $token = $this->parser->getCurrentToken();
319 if (Twig_Token::PUNCTUATION_TYPE == $token->getType()) {
320 if ('.' == $token->getValue() || '[' == $token->getValue()) {
321 $node = $this->parseSubscriptExpression($node);
322 } elseif ('|' == $token->getValue()) {
323 $node = $this->parseFilterExpression($node);
335 public function getFunctionNode($name, $line)
339 $this->parseArguments();
340 if (!count($this->parser->getBlockStack())) {
341 throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext());
344 if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
345 throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getStream()->getSourceContext());
348 return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
350 $args = $this->parseArguments();
351 if (count($args) < 1) {
352 throw new Twig_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
355 return new Twig_Node_Expression_BlockReference($args->getNode(0), count($args) > 1 ? $args->getNode(1) : null, $line);
357 $args = $this->parseArguments();
358 if (count($args) < 2) {
359 throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext());
362 return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
364 if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
365 $arguments = new Twig_Node_Expression_Array(array(), $line);
366 foreach ($this->parseArguments() as $n) {
367 $arguments->addElement($n);
370 $node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line);
371 $node->setAttribute('safe', true);
376 $args = $this->parseArguments(true);
377 $class = $this->getFunctionNodeClass($name, $line);
379 return new $class($name, $args, $line);
383 public function parseSubscriptExpression($node)
385 $stream = $this->parser->getStream();
386 $token = $stream->next();
387 $lineno = $token->getLine();
388 $arguments = new Twig_Node_Expression_Array(array(), $lineno);
389 $type = Twig_Template::ANY_CALL;
390 if ('.' == $token->getValue()) {
391 $token = $stream->next();
393 Twig_Token::NAME_TYPE == $token->getType()
395 Twig_Token::NUMBER_TYPE == $token->getType()
397 (Twig_Token::OPERATOR_TYPE == $token->getType() && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
399 $arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno);
401 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
402 $type = Twig_Template::METHOD_CALL;
403 foreach ($this->parseArguments() as $n) {
404 $arguments->addElement($n);
408 throw new Twig_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext());
411 if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
412 if (!$arg instanceof Twig_Node_Expression_Constant) {
413 throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $stream->getSourceContext());
416 $name = $arg->getAttribute('value');
418 if ($this->parser->isReservedMacroName($name)) {
419 throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
422 $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
423 $node->setAttribute('safe', true);
428 $type = Twig_Template::ARRAY_CALL;
432 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) {
434 $arg = new Twig_Node_Expression_Constant(0, $token->getLine());
436 $arg = $this->parseExpression();
439 if ($stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
444 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
445 $length = new Twig_Node_Expression_Constant(null, $token->getLine());
447 $length = $this->parseExpression();
450 $class = $this->getFilterNodeClass('slice', $token->getLine());
451 $arguments = new Twig_Node(array($arg, $length));
452 $filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
454 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
459 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
462 return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
465 public function parseFilterExpression($node)
467 $this->parser->getStream()->next();
469 return $this->parseFilterExpressionRaw($node);
472 public function parseFilterExpressionRaw($node, $tag = null)
475 $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
477 $name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
478 if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
479 $arguments = new Twig_Node();
481 $arguments = $this->parseArguments(true);
484 $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine());
486 $node = new $class($node, $name, $arguments, $token->getLine(), $tag);
488 if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) {
492 $this->parser->getStream()->next();
501 * @param bool $namedArguments Whether to allow named arguments or not
502 * @param bool $definition Whether we are parsing arguments for a function definition
506 * @throws Twig_Error_Syntax
508 public function parseArguments($namedArguments = false, $definition = false)
511 $stream = $this->parser->getStream();
513 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
514 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) {
516 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
520 $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name');
521 $value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine());
523 $value = $this->parseExpression();
527 if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
528 if (!$value instanceof Twig_Node_Expression_Name) {
529 throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $stream->getSourceContext());
531 $name = $value->getAttribute('name');
534 $value = $this->parsePrimaryExpression();
536 if (!$this->checkConstantExpression($value)) {
537 throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $stream->getSourceContext());
540 $value = $this->parseExpression();
545 if (null === $name) {
546 $name = $value->getAttribute('name');
547 $value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
549 $args[$name] = $value;
551 if (null === $name) {
554 $args[$name] = $value;
558 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
560 return new Twig_Node($args);
563 public function parseAssignmentExpression()
565 $stream = $this->parser->getStream();
568 $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
569 $value = $token->getValue();
570 if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
571 throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
573 $targets[] = new Twig_Node_Expression_AssignName($value, $token->getLine());
575 if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
580 return new Twig_Node($targets);
583 public function parseMultitargetExpression()
587 $targets[] = $this->parseExpression();
588 if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
593 return new Twig_Node($targets);
596 private function parseNotTestExpression(Twig_NodeInterface $node)
598 return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine());
601 private function parseTestExpression(Twig_NodeInterface $node)
603 $stream = $this->parser->getStream();
604 list($name, $test) = $this->getTest($node->getTemplateLine());
606 $class = $this->getTestNodeClass($test);
608 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
609 $arguments = $this->parser->getExpressionParser()->parseArguments(true);
612 return new $class($node, $name, $arguments, $this->parser->getCurrentToken()->getLine());
615 private function getTest($line)
617 $stream = $this->parser->getStream();
618 $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
620 if ($test = $this->env->getTest($name)) {
621 return array($name, $test);
624 if ($stream->test(Twig_Token::NAME_TYPE)) {
626 $name = $name.' '.$this->parser->getCurrentToken()->getValue();
628 if ($test = $this->env->getTest($name)) {
631 return array($name, $test);
635 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $stream->getSourceContext());
636 $e->addSuggestions($name, array_keys($this->env->getTests()));
641 private function getTestNodeClass($test)
643 if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) {
644 $stream = $this->parser->getStream();
645 $message = sprintf('Twig Test "%s" is deprecated', $test->getName());
646 if (!is_bool($test->getDeprecatedVersion())) {
647 $message .= sprintf(' since version %s', $test->getDeprecatedVersion());
649 if ($test->getAlternative()) {
650 $message .= sprintf('. Use "%s" instead', $test->getAlternative());
652 $src = $stream->getSourceContext();
653 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine());
655 @trigger_error($message, E_USER_DEPRECATED);
658 if ($test instanceof Twig_SimpleTest) {
659 return $test->getNodeClass();
662 return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
665 protected function getFunctionNodeClass($name, $line)
667 if (false === $function = $this->env->getFunction($name)) {
668 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext());
669 $e->addSuggestions($name, array_keys($this->env->getFunctions()));
674 if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
675 $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
676 if (!is_bool($function->getDeprecatedVersion())) {
677 $message .= sprintf(' since version %s', $function->getDeprecatedVersion());
679 if ($function->getAlternative()) {
680 $message .= sprintf('. Use "%s" instead', $function->getAlternative());
682 $src = $this->parser->getStream()->getSourceContext();
683 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
685 @trigger_error($message, E_USER_DEPRECATED);
688 if ($function instanceof Twig_SimpleFunction) {
689 return $function->getNodeClass();
692 return $function instanceof Twig_Function_Node ? $function->getClass() : 'Twig_Node_Expression_Function';
695 protected function getFilterNodeClass($name, $line)
697 if (false === $filter = $this->env->getFilter($name)) {
698 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext());
699 $e->addSuggestions($name, array_keys($this->env->getFilters()));
704 if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
705 $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
706 if (!is_bool($filter->getDeprecatedVersion())) {
707 $message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
709 if ($filter->getAlternative()) {
710 $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
712 $src = $this->parser->getStream()->getSourceContext();
713 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
715 @trigger_error($message, E_USER_DEPRECATED);
718 if ($filter instanceof Twig_SimpleFilter) {
719 return $filter->getNodeClass();
722 return $filter instanceof Twig_Filter_Node ? $filter->getClass() : 'Twig_Node_Expression_Filter';
725 // checks that the node only contains "constant" elements
726 protected function checkConstantExpression(Twig_NodeInterface $node)
728 if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array
729 || $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos
734 foreach ($node as $n) {
735 if (!$this->checkConstantExpression($n)) {
744 class_alias('Twig_ExpressionParser', 'Twig\ExpressionParser', false);