12@trigger_error(
'The grammar feature is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED);
 
   29        if (!is_object($grammar)) {
 
   33        $grammar->setParser($this->parser);
 
   54    protected function getAttribute($node, $attribute, $arguments = array(), 
$type = Twig_Node_Expression_GetAttr::TYPE_ANY, $line = -1)
 
   65    protected function call($node, $attribute, $arguments = array(), $line = -1)
 
   67        return $this->
getAttribute($node, $attribute, $arguments, Twig_Node_Expression_GetAttr::TYPE_METHOD, $line);
 
  101        if (
true === $main) {
 
  108        while ($cursor < strlen($str)) {
 
  109            if (preg_match(
'/\s+/A', $str, $match, 
null, $cursor)) {
 
  110                $cursor += strlen($match[0]);
 
  111            } elseif (preg_match(
'/<(\w+)(?:\:(\w+))?>/A', $str, $match, 
null, $cursor)) {
 
  112                $class = sprintf(
'Twig_Extensions_Grammar_%s', ucfirst(isset($match[2]) ? $match[2] : 
'Expression'));
 
  113                if (!class_exists($class)) {
 
  114                    throw new Twig_Error_Runtime(sprintf(
'Unable to understand "%s" in grammar (%s class does not exist)', $match[0], $class));
 
  116                $grammar->addGrammar(
new $class($match[1]));
 
  117                $cursor += strlen($match[0]);
 
  118            } elseif (preg_match(
'/\w+/A', $str, $match, 
null, $cursor)) {
 
  120                $cursor += strlen($match[0]);
 
  121            } elseif (preg_match(
'/,/A', $str, $match, 
null, $cursor)) {
 
  123                $cursor += strlen($match[0]);
 
  124            } elseif (preg_match(
'/\[/A', $str, $match, 
null, $cursor)) {
 
  125                $cursor += strlen($match[0]);
 
  126                $grammar->addGrammar(self::parseGrammar($str, 
false));
 
  127            } elseif (
true !== $main && preg_match(
'/\]/A', $str, $match, 
null, $cursor)) {
 
  128                $cursor += strlen($match[0]);
 
  132                throw new Twig_Error_Runtime(sprintf(
'Unable to parse grammar "%s" near "...%s..."', $str, substr($str, $cursor, 10)));
 
An exception for terminatinating execution or to throw for unit testing.
Exception thrown when an error occurs at runtime.
getNode(array $values, $line)
Gets the nodes based on the parsed values.
output(Twig_Node $node, $line=-1)
getAttribute($node, $attribute, $arguments=array(), $type=Twig_Node_Expression_GetAttr::TYPE_ANY, $line=-1)
static parseGrammar($str, $main=true)
call($node, $attribute, $arguments=array(), $line=-1)
getGrammar()
Gets the grammar as an object or as a string.
markAsSafe(Twig_Node $node, $line=-1)
parse(Twig_Token $token)
Parses a token and returns a node.
getNodeValues(array $values)
Represents a node that outputs an expression.
Represents a node in the AST.
Base class for all token parsers.