98 {
99 static $cursor;
100
101 if (true === $main) {
102 $cursor = 0;
104 } else {
106 }
107
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));
115 }
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]);
129
130 return $grammar;
131 } else {
133 }
134 }
135
136 return $grammar;
137 }
sprintf('%.4f', $callTime)
Exception thrown when an error occurs at runtime.