Commit | Line | Data |
---|---|---|
2aa91ff2 S |
1 | <?php |
2 | /** | |
3 | * Smarty Internal Plugin Templatelexer | |
4 | * This is the lexer to break the template source into tokens | |
5 | * | |
6 | * @package Smarty | |
7 | * @subpackage Compiler | |
8 | * @author Uwe Tews | |
9 | */ | |
10 | ||
11 | /** | |
ccd27f54 S |
12 | * Smarty_Internal_Templatelexer |
13 | * This is the template file lexer. | |
14 | * It is generated from the smarty_internal_templatelexer.plex file | |
15 | * | |
16 | * @package Smarty | |
17 | * @subpackage Compiler | |
18 | * @author Uwe Tews | |
2aa91ff2 S |
19 | */ |
20 | class Smarty_Internal_Templatelexer | |
21 | { | |
ccd27f54 S |
22 | /** |
23 | * Source | |
24 | * | |
25 | * @var string | |
26 | */ | |
2aa91ff2 | 27 | public $data; |
ccd27f54 S |
28 | /** |
29 | * byte counter | |
30 | * | |
31 | * @var int | |
32 | */ | |
2aa91ff2 | 33 | public $counter; |
ccd27f54 S |
34 | /** |
35 | * token number | |
36 | * | |
37 | * @var int | |
38 | */ | |
2aa91ff2 | 39 | public $token; |
ccd27f54 S |
40 | /** |
41 | * token value | |
42 | * | |
43 | * @var string | |
44 | */ | |
2aa91ff2 | 45 | public $value; |
ccd27f54 S |
46 | /** |
47 | * current line | |
48 | * | |
49 | * @var int | |
50 | */ | |
2aa91ff2 | 51 | public $line; |
ccd27f54 S |
52 | /** |
53 | * tag start line | |
54 | * | |
55 | * @var | |
56 | */ | |
2aa91ff2 | 57 | public $taglineno; |
ccd27f54 S |
58 | /** |
59 | * flag if parsing php script | |
60 | * | |
61 | * @var bool | |
62 | */ | |
2aa91ff2 | 63 | public $is_phpScript = false; |
ccd27f54 S |
64 | /** |
65 | * php code type | |
66 | * | |
67 | * @var string | |
68 | */ | |
69 | public $phpType = ''; | |
70 | /** | |
71 | * escaped left delimiter | |
72 | * | |
73 | * @var string | |
74 | */ | |
75 | public $ldel = ''; | |
76 | /** | |
77 | * escaped left delimiter length | |
78 | * | |
79 | * @var int | |
80 | */ | |
81 | public $ldel_length = 0; | |
82 | /** | |
83 | * escaped right delimiter | |
84 | * | |
85 | * @var string | |
86 | */ | |
87 | public $rdel = ''; | |
88 | /** | |
89 | * escaped right delimiter length | |
90 | * | |
91 | * @var int | |
92 | */ | |
93 | public $rdel_length = 0; | |
94 | /** | |
95 | * state number | |
96 | * | |
97 | * @var int | |
98 | */ | |
2aa91ff2 | 99 | public $state = 1; |
ccd27f54 S |
100 | /** |
101 | * Smarty object | |
102 | * | |
103 | * @var Smarty | |
104 | */ | |
105 | public $smarty = null; | |
106 | /** | |
107 | * compiler object | |
108 | * | |
109 | * @var Smarty_Internal_TemplateCompilerBase | |
110 | */ | |
111 | private $compiler = null; | |
112 | /** | |
113 | * literal tag nesting level | |
114 | * | |
115 | * @var int | |
116 | */ | |
117 | private $literal_cnt = 0; | |
118 | /** | |
119 | * trace file | |
120 | * | |
121 | * @var resource | |
122 | */ | |
2aa91ff2 | 123 | public $yyTraceFILE; |
ccd27f54 S |
124 | /** |
125 | * trace prompt | |
126 | * | |
127 | * @var string | |
128 | */ | |
2aa91ff2 | 129 | public $yyTracePrompt; |
ccd27f54 S |
130 | /** |
131 | * state names | |
132 | * | |
133 | * @var array | |
134 | */ | |
2aa91ff2 | 135 | public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY'); |
ccd27f54 S |
136 | /** |
137 | * token names | |
138 | * | |
139 | * @var array | |
140 | */ | |
2aa91ff2 S |
141 | public $smarty_token_names = array( // Text for parser error messages |
142 | 'IDENTITY' => '===', | |
143 | 'NONEIDENTITY' => '!==', | |
144 | 'EQUALS' => '==', | |
145 | 'NOTEQUALS' => '!=', | |
146 | 'GREATEREQUAL' => '(>=,ge)', | |
147 | 'LESSEQUAL' => '(<=,le)', | |
148 | 'GREATERTHAN' => '(>,gt)', | |
149 | 'LESSTHAN' => '(<,lt)', | |
150 | 'MOD' => '(%,mod)', | |
151 | 'NOT' => '(!,not)', | |
152 | 'LAND' => '(&&,and)', | |
153 | 'LOR' => '(||,or)', | |
154 | 'LXOR' => 'xor', | |
155 | 'OPENP' => '(', | |
156 | 'CLOSEP' => ')', | |
157 | 'OPENB' => '[', | |
158 | 'CLOSEB' => ']', | |
159 | 'PTR' => '->', | |
160 | 'APTR' => '=>', | |
161 | 'EQUAL' => '=', | |
162 | 'NUMBER' => 'number', | |
163 | 'UNIMATH' => '+" , "-', | |
164 | 'MATH' => '*" , "/" , "%', | |
165 | 'INCDEC' => '++" , "--', | |
166 | 'SPACE' => ' ', | |
167 | 'DOLLAR' => '$', | |
168 | 'SEMICOLON' => ';', | |
169 | 'COLON' => ':', | |
170 | 'DOUBLECOLON' => '::', | |
171 | 'AT' => '@', | |
172 | 'HATCH' => '#', | |
173 | 'QUOTE' => '"', | |
174 | 'BACKTICK' => '`', | |
175 | 'VERT' => '|', | |
176 | 'DOT' => '.', | |
177 | 'COMMA' => '","', | |
178 | 'ANDSYM' => '"&"', | |
179 | 'QMARK' => '"?"', | |
180 | 'ID' => 'identifier', | |
181 | 'TEXT' => 'text', | |
182 | 'FAKEPHPSTARTTAG' => 'Fake PHP start tag', | |
183 | 'PHPSTARTTAG' => 'PHP start tag', | |
184 | 'PHPENDTAG' => 'PHP end tag', | |
185 | 'LITERALSTART' => 'Literal start', | |
186 | 'LITERALEND' => 'Literal end', | |
187 | 'LDELSLASH' => 'closing tag', | |
188 | 'COMMENT' => 'comment', | |
189 | 'AS' => 'as', | |
190 | 'TO' => 'to', | |
191 | ); | |
192 | ||
ccd27f54 S |
193 | /** |
194 | * constructor | |
195 | * | |
196 | * @param string $data template source | |
197 | * @param Smarty_Internal_TemplateCompilerBase $compiler | |
198 | */ | |
199 | function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler) | |
2aa91ff2 | 200 | { |
2aa91ff2 S |
201 | $this->data = $data; |
202 | $this->counter = 0; | |
203 | if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) { | |
204 | $this->counter += strlen($match[0]); | |
205 | } | |
206 | $this->line = 1; | |
207 | $this->smarty = $compiler->smarty; | |
208 | $this->compiler = $compiler; | |
209 | $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); | |
210 | $this->ldel_length = strlen($this->smarty->left_delimiter); | |
211 | $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); | |
212 | $this->rdel_length = strlen($this->smarty->right_delimiter); | |
213 | $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; | |
214 | $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; | |
215 | } | |
216 | ||
217 | public function PrintTrace() | |
218 | { | |
219 | $this->yyTraceFILE = fopen('php://output', 'w'); | |
220 | $this->yyTracePrompt = '<br>'; | |
221 | } | |
222 | ||
223 | private $_yy_state = 1; | |
224 | private $_yy_stack = array(); | |
225 | ||
226 | public function yylex() | |
227 | { | |
228 | return $this->{'yylex' . $this->_yy_state}(); | |
229 | } | |
230 | ||
231 | public function yypushstate($state) | |
232 | { | |
233 | if ($this->yyTraceFILE) { | |
234 | fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); | |
235 | } | |
236 | array_push($this->_yy_stack, $this->_yy_state); | |
237 | $this->_yy_state = $state; | |
238 | if ($this->yyTraceFILE) { | |
239 | fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); | |
240 | } | |
241 | } | |
242 | ||
243 | public function yypopstate() | |
244 | { | |
245 | if ($this->yyTraceFILE) { | |
246 | fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); | |
247 | } | |
248 | $this->_yy_state = array_pop($this->_yy_stack); | |
249 | if ($this->yyTraceFILE) { | |
250 | fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); | |
251 | } | |
252 | } | |
253 | ||
254 | public function yybegin($state) | |
255 | { | |
256 | $this->_yy_state = $state; | |
257 | if ($this->yyTraceFILE) { | |
258 | fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); | |
259 | } | |
260 | } | |
261 | ||
262 | public function yylex1() | |
263 | { | |
264 | $tokenMap = array( | |
265 | 1 => 0, | |
266 | 2 => 1, | |
267 | 4 => 0, | |
268 | 5 => 0, | |
269 | 6 => 0, | |
270 | 7 => 1, | |
271 | 9 => 0, | |
272 | 10 => 0, | |
273 | 11 => 0, | |
ccd27f54 | 274 | 12 => 6, |
2aa91ff2 S |
275 | 19 => 0, |
276 | 20 => 0, | |
277 | 21 => 0, | |
ccd27f54 S |
278 | 22 => 1, |
279 | 24 => 6, | |
280 | 31 => 7, | |
281 | 39 => 6, | |
282 | 46 => 3, | |
283 | 50 => 0, | |
2aa91ff2 S |
284 | ); |
285 | if ($this->counter >= strlen($this->data)) { | |
286 | return false; // end of input | |
287 | } | |
ccd27f54 | 288 | $yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G((" . $this->ldel . "\\s*php\\s*(.)*?" . $this->rdel . "((.)*?)" . $this->ldel . "\\s*\/php\\s*" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]?php\\s*(.)*?" . $this->rdel . "))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G(<\\?xml\\s+([\S\s]*?)\\?>)|\G(<%((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)%>)|\G((<\\?(?:php\\s+|=)?)((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)\\?>)|\G(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)<\/script>)|\G((<(\\?(?:php\\s+|=)?|(script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|%))|\\?>|%>)|\G([\S\s])/iS"; |
2aa91ff2 S |
289 | |
290 | do { | |
291 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
292 | $yysubmatches = $yymatches; | |
ccd27f54 | 293 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
294 | if (!count($yymatches)) { |
295 | throw new Exception('Error: lexing failed because a rule matched' . | |
296 | ' an empty string. Input "' . substr($this->data, | |
297 | $this->counter, 5) . '... state TEXT'); | |
298 | } | |
299 | next($yymatches); // skip global match | |
300 | $this->token = key($yymatches); // token number | |
301 | if ($tokenMap[$this->token]) { | |
302 | // extract sub-patterns for passing to lex function | |
303 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
304 | $tokenMap[$this->token]); | |
305 | } else { | |
306 | $yysubmatches = array(); | |
307 | } | |
308 | $this->value = current($yymatches); // token value | |
309 | $r = $this->{'yy_r1_' . $this->token}($yysubmatches); | |
310 | if ($r === null) { | |
311 | $this->counter += strlen($this->value); | |
312 | $this->line += substr_count($this->value, "\n"); | |
313 | // accept this token | |
314 | return true; | |
315 | } elseif ($r === true) { | |
316 | // we have changed state | |
317 | // process this token in the new state | |
318 | return $this->yylex(); | |
319 | } elseif ($r === false) { | |
320 | $this->counter += strlen($this->value); | |
321 | $this->line += substr_count($this->value, "\n"); | |
322 | if ($this->counter >= strlen($this->data)) { | |
323 | return false; // end of input | |
324 | } | |
325 | // skip this token | |
326 | continue; | |
327 | } | |
328 | } else { | |
329 | throw new Exception('Unexpected input at line' . $this->line . | |
330 | ': ' . $this->data[$this->counter]); | |
331 | } | |
332 | break; | |
333 | } while (true); | |
334 | } // end function | |
335 | ||
336 | const TEXT = 1; | |
337 | ||
338 | function yy_r1_1($yy_subpatterns) | |
339 | { | |
340 | ||
341 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
342 | } | |
343 | ||
344 | function yy_r1_2($yy_subpatterns) | |
345 | { | |
346 | ||
347 | $this->token = Smarty_Internal_Templateparser::TP_COMMENT; | |
348 | } | |
349 | ||
350 | function yy_r1_4($yy_subpatterns) | |
351 | { | |
352 | ||
353 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
354 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
355 | } else { | |
356 | $this->token = Smarty_Internal_Templateparser::TP_STRIPON; | |
357 | } | |
358 | } | |
359 | ||
360 | function yy_r1_5($yy_subpatterns) | |
361 | { | |
362 | ||
363 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
364 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
365 | } else { | |
366 | $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF; | |
367 | } | |
368 | } | |
369 | ||
370 | function yy_r1_6($yy_subpatterns) | |
371 | { | |
372 | ||
373 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
374 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
375 | } else { | |
376 | $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; | |
377 | $this->yypushstate(self::LITERAL); | |
378 | } | |
379 | } | |
380 | ||
381 | function yy_r1_7($yy_subpatterns) | |
382 | { | |
383 | ||
384 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
385 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
386 | } else { | |
387 | $this->token = Smarty_Internal_Templateparser::TP_LDELIF; | |
388 | $this->yypushstate(self::SMARTY); | |
389 | $this->taglineno = $this->line; | |
390 | } | |
391 | } | |
392 | ||
393 | function yy_r1_9($yy_subpatterns) | |
394 | { | |
395 | ||
396 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
397 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
398 | } else { | |
399 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; | |
400 | $this->yypushstate(self::SMARTY); | |
401 | $this->taglineno = $this->line; | |
402 | } | |
403 | } | |
404 | ||
405 | function yy_r1_10($yy_subpatterns) | |
406 | { | |
407 | ||
408 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
409 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
410 | } else { | |
411 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; | |
412 | $this->yypushstate(self::SMARTY); | |
413 | $this->taglineno = $this->line; | |
414 | } | |
415 | } | |
416 | ||
417 | function yy_r1_11($yy_subpatterns) | |
418 | { | |
419 | ||
420 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
421 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
422 | } else { | |
423 | $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; | |
424 | $this->yypushstate(self::SMARTY); | |
425 | $this->taglineno = $this->line; | |
426 | } | |
427 | } | |
428 | ||
429 | function yy_r1_12($yy_subpatterns) | |
ccd27f54 S |
430 | { |
431 | ||
432 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
433 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
434 | } else { | |
435 | $this->token = Smarty_Internal_Templateparser::TP_PHP; | |
436 | $this->phpType = 'tag'; | |
437 | $this->taglineno = $this->line; | |
438 | } | |
439 | } | |
440 | ||
441 | function yy_r1_19($yy_subpatterns) | |
2aa91ff2 S |
442 | { |
443 | ||
444 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
445 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
446 | } else { | |
447 | $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; | |
448 | $this->yypushstate(self::SMARTY); | |
449 | $this->taglineno = $this->line; | |
450 | } | |
451 | } | |
452 | ||
ccd27f54 | 453 | function yy_r1_20($yy_subpatterns) |
2aa91ff2 S |
454 | { |
455 | ||
456 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
457 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
458 | } else { | |
459 | $this->token = Smarty_Internal_Templateparser::TP_LDEL; | |
460 | $this->yypushstate(self::SMARTY); | |
461 | $this->taglineno = $this->line; | |
462 | } | |
463 | } | |
464 | ||
ccd27f54 | 465 | function yy_r1_21($yy_subpatterns) |
2aa91ff2 S |
466 | { |
467 | ||
ccd27f54 | 468 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
2aa91ff2 S |
469 | } |
470 | ||
ccd27f54 | 471 | function yy_r1_22($yy_subpatterns) |
2aa91ff2 S |
472 | { |
473 | ||
ccd27f54 S |
474 | $this->token = Smarty_Internal_Templateparser::TP_XMLTAG; |
475 | $this->taglineno = $this->line; | |
2aa91ff2 S |
476 | } |
477 | ||
ccd27f54 | 478 | function yy_r1_24($yy_subpatterns) |
2aa91ff2 S |
479 | { |
480 | ||
ccd27f54 S |
481 | $this->phpType = 'asp'; |
482 | $this->taglineno = $this->line; | |
483 | $this->token = Smarty_Internal_Templateparser::TP_PHP; | |
2aa91ff2 S |
484 | } |
485 | ||
ccd27f54 | 486 | function yy_r1_31($yy_subpatterns) |
2aa91ff2 S |
487 | { |
488 | ||
ccd27f54 S |
489 | $this->phpType = 'php'; |
490 | $this->taglineno = $this->line; | |
491 | $this->token = Smarty_Internal_Templateparser::TP_PHP; | |
2aa91ff2 S |
492 | } |
493 | ||
ccd27f54 | 494 | function yy_r1_39($yy_subpatterns) |
2aa91ff2 S |
495 | { |
496 | ||
ccd27f54 S |
497 | $this->phpType = 'script'; |
498 | $this->taglineno = $this->line; | |
499 | $this->token = Smarty_Internal_Templateparser::TP_PHP; | |
2aa91ff2 S |
500 | } |
501 | ||
ccd27f54 | 502 | function yy_r1_46($yy_subpatterns) |
2aa91ff2 S |
503 | { |
504 | ||
ccd27f54 S |
505 | $this->phpType = 'unmatched'; |
506 | $this->taglineno = $this->line; | |
507 | $this->token = Smarty_Internal_Templateparser::TP_PHP; | |
2aa91ff2 S |
508 | } |
509 | ||
ccd27f54 | 510 | function yy_r1_50($yy_subpatterns) |
2aa91ff2 S |
511 | { |
512 | ||
2aa91ff2 | 513 | $to = strlen($this->data); |
ccd27f54 | 514 | preg_match("/{$this->ldel}|<\?|<%|\?>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
2aa91ff2 S |
515 | if (isset($match[0][1])) { |
516 | $to = $match[0][1]; | |
517 | } | |
518 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
519 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
520 | } | |
521 | ||
522 | public function yylex2() | |
523 | { | |
524 | $tokenMap = array( | |
525 | 1 => 0, | |
526 | 2 => 0, | |
527 | 3 => 1, | |
528 | 5 => 0, | |
529 | 6 => 0, | |
530 | 7 => 0, | |
531 | 8 => 0, | |
532 | 9 => 0, | |
533 | 10 => 0, | |
534 | 11 => 0, | |
535 | 12 => 0, | |
536 | 13 => 0, | |
537 | 14 => 0, | |
538 | 15 => 1, | |
539 | 17 => 1, | |
540 | 19 => 1, | |
541 | 21 => 0, | |
542 | 22 => 0, | |
543 | 23 => 0, | |
544 | 24 => 0, | |
545 | 25 => 0, | |
546 | 26 => 0, | |
547 | 27 => 0, | |
548 | 28 => 0, | |
549 | 29 => 0, | |
550 | 30 => 0, | |
551 | 31 => 0, | |
552 | 32 => 0, | |
553 | 33 => 0, | |
554 | 34 => 0, | |
555 | 35 => 0, | |
556 | 36 => 0, | |
557 | 37 => 0, | |
558 | 38 => 3, | |
559 | 42 => 0, | |
560 | 43 => 0, | |
561 | 44 => 0, | |
562 | 45 => 0, | |
563 | 46 => 0, | |
564 | 47 => 0, | |
565 | 48 => 0, | |
566 | 49 => 0, | |
567 | 50 => 1, | |
568 | 52 => 1, | |
569 | 54 => 0, | |
570 | 55 => 0, | |
571 | 56 => 0, | |
ccd27f54 | 572 | 57 => 2, |
2aa91ff2 S |
573 | 60 => 0, |
574 | 61 => 0, | |
575 | 62 => 0, | |
576 | 63 => 0, | |
577 | 64 => 0, | |
578 | 65 => 0, | |
579 | 66 => 0, | |
580 | 67 => 0, | |
581 | 68 => 0, | |
582 | 69 => 0, | |
ccd27f54 S |
583 | 70 => 0, |
584 | 71 => 0, | |
2aa91ff2 | 585 | 72 => 0, |
ccd27f54 | 586 | 73 => 1, |
2aa91ff2 S |
587 | 75 => 0, |
588 | 76 => 0, | |
ccd27f54 S |
589 | 77 => 0, |
590 | 78 => 0, | |
591 | 79 => 0, | |
2aa91ff2 S |
592 | ); |
593 | if ($this->counter >= strlen($this->data)) { | |
594 | return false; // end of input | |
595 | } | |
ccd27f54 | 596 | $yy_global_pattern = "/\G(\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G(\\$)|\G(\\s*" . $this->rdel . ")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(@)|\G(#)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*=\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/iS"; |
2aa91ff2 S |
597 | |
598 | do { | |
599 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
600 | $yysubmatches = $yymatches; | |
ccd27f54 | 601 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
602 | if (!count($yymatches)) { |
603 | throw new Exception('Error: lexing failed because a rule matched' . | |
604 | ' an empty string. Input "' . substr($this->data, | |
605 | $this->counter, 5) . '... state SMARTY'); | |
606 | } | |
607 | next($yymatches); // skip global match | |
608 | $this->token = key($yymatches); // token number | |
609 | if ($tokenMap[$this->token]) { | |
610 | // extract sub-patterns for passing to lex function | |
611 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
612 | $tokenMap[$this->token]); | |
613 | } else { | |
614 | $yysubmatches = array(); | |
615 | } | |
616 | $this->value = current($yymatches); // token value | |
617 | $r = $this->{'yy_r2_' . $this->token}($yysubmatches); | |
618 | if ($r === null) { | |
619 | $this->counter += strlen($this->value); | |
620 | $this->line += substr_count($this->value, "\n"); | |
621 | // accept this token | |
622 | return true; | |
623 | } elseif ($r === true) { | |
624 | // we have changed state | |
625 | // process this token in the new state | |
626 | return $this->yylex(); | |
627 | } elseif ($r === false) { | |
628 | $this->counter += strlen($this->value); | |
629 | $this->line += substr_count($this->value, "\n"); | |
630 | if ($this->counter >= strlen($this->data)) { | |
631 | return false; // end of input | |
632 | } | |
633 | // skip this token | |
634 | continue; | |
635 | } | |
636 | } else { | |
637 | throw new Exception('Unexpected input at line' . $this->line . | |
638 | ': ' . $this->data[$this->counter]); | |
639 | } | |
640 | break; | |
641 | } while (true); | |
642 | } // end function | |
643 | ||
644 | const SMARTY = 2; | |
645 | ||
646 | function yy_r2_1($yy_subpatterns) | |
647 | { | |
648 | ||
649 | $this->token = Smarty_Internal_Templateparser::TP_QUOTE; | |
650 | $this->yypushstate(self::DOUBLEQUOTEDSTRING); | |
651 | } | |
652 | ||
653 | function yy_r2_2($yy_subpatterns) | |
654 | { | |
655 | ||
656 | $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; | |
657 | } | |
658 | ||
659 | function yy_r2_3($yy_subpatterns) | |
660 | { | |
661 | ||
662 | $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; | |
663 | $this->taglineno = $this->line; | |
664 | } | |
665 | ||
666 | function yy_r2_5($yy_subpatterns) | |
667 | { | |
668 | ||
669 | $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; | |
670 | } | |
671 | ||
672 | function yy_r2_6($yy_subpatterns) | |
673 | { | |
674 | ||
675 | $this->token = Smarty_Internal_Templateparser::TP_RDEL; | |
676 | $this->yypopstate(); | |
677 | } | |
678 | ||
679 | function yy_r2_7($yy_subpatterns) | |
680 | { | |
681 | ||
682 | $this->token = Smarty_Internal_Templateparser::TP_ISIN; | |
683 | } | |
684 | ||
685 | function yy_r2_8($yy_subpatterns) | |
686 | { | |
687 | ||
688 | $this->token = Smarty_Internal_Templateparser::TP_AS; | |
689 | } | |
690 | ||
691 | function yy_r2_9($yy_subpatterns) | |
692 | { | |
693 | ||
694 | $this->token = Smarty_Internal_Templateparser::TP_TO; | |
695 | } | |
696 | ||
697 | function yy_r2_10($yy_subpatterns) | |
698 | { | |
699 | ||
700 | $this->token = Smarty_Internal_Templateparser::TP_STEP; | |
701 | } | |
702 | ||
703 | function yy_r2_11($yy_subpatterns) | |
704 | { | |
705 | ||
706 | $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; | |
707 | } | |
708 | ||
709 | function yy_r2_12($yy_subpatterns) | |
710 | { | |
711 | ||
712 | $this->token = Smarty_Internal_Templateparser::TP_IDENTITY; | |
713 | } | |
714 | ||
715 | function yy_r2_13($yy_subpatterns) | |
716 | { | |
717 | ||
718 | $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY; | |
719 | } | |
720 | ||
721 | function yy_r2_14($yy_subpatterns) | |
722 | { | |
723 | ||
724 | $this->token = Smarty_Internal_Templateparser::TP_EQUALS; | |
725 | } | |
726 | ||
727 | function yy_r2_15($yy_subpatterns) | |
728 | { | |
729 | ||
730 | $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS; | |
731 | } | |
732 | ||
733 | function yy_r2_17($yy_subpatterns) | |
734 | { | |
735 | ||
736 | $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL; | |
737 | } | |
738 | ||
739 | function yy_r2_19($yy_subpatterns) | |
740 | { | |
741 | ||
742 | $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL; | |
743 | } | |
744 | ||
745 | function yy_r2_21($yy_subpatterns) | |
746 | { | |
747 | ||
748 | $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN; | |
749 | } | |
750 | ||
751 | function yy_r2_22($yy_subpatterns) | |
752 | { | |
753 | ||
754 | $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN; | |
755 | } | |
756 | ||
757 | function yy_r2_23($yy_subpatterns) | |
758 | { | |
759 | ||
760 | $this->token = Smarty_Internal_Templateparser::TP_MOD; | |
761 | } | |
762 | ||
763 | function yy_r2_24($yy_subpatterns) | |
764 | { | |
765 | ||
766 | $this->token = Smarty_Internal_Templateparser::TP_NOT; | |
767 | } | |
768 | ||
769 | function yy_r2_25($yy_subpatterns) | |
770 | { | |
771 | ||
772 | $this->token = Smarty_Internal_Templateparser::TP_LAND; | |
773 | } | |
774 | ||
775 | function yy_r2_26($yy_subpatterns) | |
776 | { | |
777 | ||
778 | $this->token = Smarty_Internal_Templateparser::TP_LOR; | |
779 | } | |
780 | ||
781 | function yy_r2_27($yy_subpatterns) | |
782 | { | |
783 | ||
784 | $this->token = Smarty_Internal_Templateparser::TP_LXOR; | |
785 | } | |
786 | ||
787 | function yy_r2_28($yy_subpatterns) | |
788 | { | |
789 | ||
790 | $this->token = Smarty_Internal_Templateparser::TP_ISODDBY; | |
791 | } | |
792 | ||
793 | function yy_r2_29($yy_subpatterns) | |
794 | { | |
795 | ||
796 | $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY; | |
797 | } | |
798 | ||
799 | function yy_r2_30($yy_subpatterns) | |
800 | { | |
801 | ||
802 | $this->token = Smarty_Internal_Templateparser::TP_ISODD; | |
803 | } | |
804 | ||
805 | function yy_r2_31($yy_subpatterns) | |
806 | { | |
807 | ||
808 | $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD; | |
809 | } | |
810 | ||
811 | function yy_r2_32($yy_subpatterns) | |
812 | { | |
813 | ||
814 | $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY; | |
815 | } | |
816 | ||
817 | function yy_r2_33($yy_subpatterns) | |
818 | { | |
819 | ||
820 | $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY; | |
821 | } | |
822 | ||
823 | function yy_r2_34($yy_subpatterns) | |
824 | { | |
825 | ||
826 | $this->token = Smarty_Internal_Templateparser::TP_ISEVEN; | |
827 | } | |
828 | ||
829 | function yy_r2_35($yy_subpatterns) | |
830 | { | |
831 | ||
832 | $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN; | |
833 | } | |
834 | ||
835 | function yy_r2_36($yy_subpatterns) | |
836 | { | |
837 | ||
838 | $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY; | |
839 | } | |
840 | ||
841 | function yy_r2_37($yy_subpatterns) | |
842 | { | |
843 | ||
844 | $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY; | |
845 | } | |
846 | ||
847 | function yy_r2_38($yy_subpatterns) | |
848 | { | |
849 | ||
850 | $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; | |
851 | } | |
852 | ||
853 | function yy_r2_42($yy_subpatterns) | |
854 | { | |
855 | ||
856 | $this->token = Smarty_Internal_Templateparser::TP_OPENP; | |
857 | } | |
858 | ||
859 | function yy_r2_43($yy_subpatterns) | |
860 | { | |
861 | ||
862 | $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; | |
863 | } | |
864 | ||
865 | function yy_r2_44($yy_subpatterns) | |
866 | { | |
867 | ||
868 | $this->token = Smarty_Internal_Templateparser::TP_OPENB; | |
869 | } | |
870 | ||
871 | function yy_r2_45($yy_subpatterns) | |
872 | { | |
873 | ||
874 | $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; | |
875 | } | |
876 | ||
877 | function yy_r2_46($yy_subpatterns) | |
878 | { | |
879 | ||
880 | $this->token = Smarty_Internal_Templateparser::TP_PTR; | |
881 | } | |
882 | ||
883 | function yy_r2_47($yy_subpatterns) | |
884 | { | |
885 | ||
886 | $this->token = Smarty_Internal_Templateparser::TP_APTR; | |
887 | } | |
888 | ||
889 | function yy_r2_48($yy_subpatterns) | |
890 | { | |
891 | ||
892 | $this->token = Smarty_Internal_Templateparser::TP_EQUAL; | |
893 | } | |
894 | ||
895 | function yy_r2_49($yy_subpatterns) | |
896 | { | |
897 | ||
898 | $this->token = Smarty_Internal_Templateparser::TP_INCDEC; | |
899 | } | |
900 | ||
901 | function yy_r2_50($yy_subpatterns) | |
902 | { | |
903 | ||
904 | $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; | |
905 | } | |
906 | ||
907 | function yy_r2_52($yy_subpatterns) | |
908 | { | |
909 | ||
910 | $this->token = Smarty_Internal_Templateparser::TP_MATH; | |
911 | } | |
912 | ||
913 | function yy_r2_54($yy_subpatterns) | |
914 | { | |
915 | ||
916 | $this->token = Smarty_Internal_Templateparser::TP_AT; | |
917 | } | |
918 | ||
919 | function yy_r2_55($yy_subpatterns) | |
920 | { | |
921 | ||
922 | $this->token = Smarty_Internal_Templateparser::TP_HATCH; | |
923 | } | |
924 | ||
925 | function yy_r2_56($yy_subpatterns) | |
926 | { | |
927 | ||
928 | // resolve conflicts with shorttag and right_delimiter starting with '=' | |
929 | if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) { | |
930 | preg_match("/\s+/", $this->value, $match); | |
931 | $this->value = $match[0]; | |
932 | $this->token = Smarty_Internal_Templateparser::TP_SPACE; | |
933 | } else { | |
934 | $this->token = Smarty_Internal_Templateparser::TP_ATTR; | |
935 | } | |
936 | } | |
937 | ||
938 | function yy_r2_57($yy_subpatterns) | |
ccd27f54 S |
939 | { |
940 | ||
941 | $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; | |
942 | } | |
943 | ||
944 | function yy_r2_60($yy_subpatterns) | |
2aa91ff2 S |
945 | { |
946 | ||
947 | $this->token = Smarty_Internal_Templateparser::TP_ID; | |
948 | } | |
949 | ||
ccd27f54 | 950 | function yy_r2_61($yy_subpatterns) |
2aa91ff2 S |
951 | { |
952 | ||
953 | $this->token = Smarty_Internal_Templateparser::TP_INTEGER; | |
954 | } | |
955 | ||
ccd27f54 | 956 | function yy_r2_62($yy_subpatterns) |
2aa91ff2 S |
957 | { |
958 | ||
959 | $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; | |
960 | $this->yypopstate(); | |
961 | } | |
962 | ||
ccd27f54 | 963 | function yy_r2_63($yy_subpatterns) |
2aa91ff2 S |
964 | { |
965 | ||
966 | $this->token = Smarty_Internal_Templateparser::TP_VERT; | |
967 | } | |
968 | ||
ccd27f54 | 969 | function yy_r2_64($yy_subpatterns) |
2aa91ff2 S |
970 | { |
971 | ||
972 | $this->token = Smarty_Internal_Templateparser::TP_DOT; | |
973 | } | |
974 | ||
ccd27f54 | 975 | function yy_r2_65($yy_subpatterns) |
2aa91ff2 S |
976 | { |
977 | ||
978 | $this->token = Smarty_Internal_Templateparser::TP_COMMA; | |
979 | } | |
980 | ||
ccd27f54 | 981 | function yy_r2_66($yy_subpatterns) |
2aa91ff2 S |
982 | { |
983 | ||
984 | $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; | |
985 | } | |
986 | ||
ccd27f54 | 987 | function yy_r2_67($yy_subpatterns) |
2aa91ff2 S |
988 | { |
989 | ||
990 | $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; | |
991 | } | |
992 | ||
ccd27f54 | 993 | function yy_r2_68($yy_subpatterns) |
2aa91ff2 S |
994 | { |
995 | ||
996 | $this->token = Smarty_Internal_Templateparser::TP_COLON; | |
997 | } | |
998 | ||
ccd27f54 | 999 | function yy_r2_69($yy_subpatterns) |
2aa91ff2 S |
1000 | { |
1001 | ||
1002 | $this->token = Smarty_Internal_Templateparser::TP_ANDSYM; | |
1003 | } | |
1004 | ||
ccd27f54 | 1005 | function yy_r2_70($yy_subpatterns) |
2aa91ff2 S |
1006 | { |
1007 | ||
1008 | $this->token = Smarty_Internal_Templateparser::TP_QMARK; | |
1009 | } | |
1010 | ||
ccd27f54 | 1011 | function yy_r2_71($yy_subpatterns) |
2aa91ff2 S |
1012 | { |
1013 | ||
1014 | $this->token = Smarty_Internal_Templateparser::TP_HEX; | |
1015 | } | |
1016 | ||
ccd27f54 | 1017 | function yy_r2_72($yy_subpatterns) |
2aa91ff2 S |
1018 | { |
1019 | ||
1020 | $this->token = Smarty_Internal_Templateparser::TP_SPACE; | |
1021 | } | |
1022 | ||
ccd27f54 | 1023 | function yy_r2_73($yy_subpatterns) |
2aa91ff2 S |
1024 | { |
1025 | ||
1026 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1027 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1028 | } else { | |
1029 | $this->token = Smarty_Internal_Templateparser::TP_LDELIF; | |
1030 | $this->yypushstate(self::SMARTY); | |
1031 | $this->taglineno = $this->line; | |
1032 | } | |
1033 | } | |
1034 | ||
ccd27f54 | 1035 | function yy_r2_75($yy_subpatterns) |
2aa91ff2 S |
1036 | { |
1037 | ||
1038 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1039 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1040 | } else { | |
1041 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; | |
1042 | $this->yypushstate(self::SMARTY); | |
1043 | $this->taglineno = $this->line; | |
1044 | } | |
1045 | } | |
1046 | ||
ccd27f54 | 1047 | function yy_r2_76($yy_subpatterns) |
2aa91ff2 S |
1048 | { |
1049 | ||
1050 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1051 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1052 | } else { | |
1053 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; | |
1054 | $this->yypushstate(self::SMARTY); | |
1055 | $this->taglineno = $this->line; | |
1056 | } | |
1057 | } | |
1058 | ||
ccd27f54 | 1059 | function yy_r2_77($yy_subpatterns) |
2aa91ff2 S |
1060 | { |
1061 | ||
1062 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1063 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1064 | } else { | |
1065 | $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; | |
1066 | $this->yypushstate(self::SMARTY); | |
1067 | $this->taglineno = $this->line; | |
1068 | } | |
1069 | } | |
1070 | ||
ccd27f54 | 1071 | function yy_r2_78($yy_subpatterns) |
2aa91ff2 S |
1072 | { |
1073 | ||
1074 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1075 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1076 | } else { | |
1077 | $this->token = Smarty_Internal_Templateparser::TP_LDEL; | |
1078 | $this->yypushstate(self::SMARTY); | |
1079 | $this->taglineno = $this->line; | |
1080 | } | |
1081 | } | |
1082 | ||
ccd27f54 | 1083 | function yy_r2_79($yy_subpatterns) |
2aa91ff2 S |
1084 | { |
1085 | ||
1086 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1087 | } | |
1088 | ||
1089 | public function yylex3() | |
1090 | { | |
1091 | $tokenMap = array( | |
1092 | 1 => 0, | |
1093 | 2 => 0, | |
1094 | 3 => 0, | |
1095 | ); | |
1096 | if ($this->counter >= strlen($this->data)) { | |
1097 | return false; // end of input | |
1098 | } | |
1099 | $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS"; | |
1100 | ||
1101 | do { | |
1102 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
1103 | $yysubmatches = $yymatches; | |
ccd27f54 | 1104 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
1105 | if (!count($yymatches)) { |
1106 | throw new Exception('Error: lexing failed because a rule matched' . | |
1107 | ' an empty string. Input "' . substr($this->data, | |
1108 | $this->counter, 5) . '... state LITERAL'); | |
1109 | } | |
1110 | next($yymatches); // skip global match | |
1111 | $this->token = key($yymatches); // token number | |
1112 | if ($tokenMap[$this->token]) { | |
1113 | // extract sub-patterns for passing to lex function | |
1114 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
1115 | $tokenMap[$this->token]); | |
1116 | } else { | |
1117 | $yysubmatches = array(); | |
1118 | } | |
1119 | $this->value = current($yymatches); // token value | |
1120 | $r = $this->{'yy_r3_' . $this->token}($yysubmatches); | |
1121 | if ($r === null) { | |
1122 | $this->counter += strlen($this->value); | |
1123 | $this->line += substr_count($this->value, "\n"); | |
1124 | // accept this token | |
1125 | return true; | |
1126 | } elseif ($r === true) { | |
1127 | // we have changed state | |
1128 | // process this token in the new state | |
1129 | return $this->yylex(); | |
1130 | } elseif ($r === false) { | |
1131 | $this->counter += strlen($this->value); | |
1132 | $this->line += substr_count($this->value, "\n"); | |
1133 | if ($this->counter >= strlen($this->data)) { | |
1134 | return false; // end of input | |
1135 | } | |
1136 | // skip this token | |
1137 | continue; | |
1138 | } | |
1139 | } else { | |
1140 | throw new Exception('Unexpected input at line' . $this->line . | |
1141 | ': ' . $this->data[$this->counter]); | |
1142 | } | |
1143 | break; | |
1144 | } while (true); | |
1145 | } // end function | |
1146 | ||
1147 | const LITERAL = 3; | |
1148 | ||
1149 | function yy_r3_1($yy_subpatterns) | |
1150 | { | |
1151 | ||
1152 | $this->literal_cnt ++; | |
1153 | $this->token = Smarty_Internal_Templateparser::TP_LITERAL; | |
1154 | } | |
1155 | ||
1156 | function yy_r3_2($yy_subpatterns) | |
1157 | { | |
1158 | ||
1159 | if ($this->literal_cnt) { | |
1160 | $this->literal_cnt --; | |
1161 | $this->token = Smarty_Internal_Templateparser::TP_LITERAL; | |
1162 | } else { | |
1163 | $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; | |
1164 | $this->yypopstate(); | |
1165 | } | |
1166 | } | |
1167 | ||
1168 | function yy_r3_3($yy_subpatterns) | |
1169 | { | |
1170 | ||
1171 | $to = strlen($this->data); | |
1172 | preg_match("/{$this->ldel}\/?literal{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); | |
1173 | if (isset($match[0][1])) { | |
1174 | $to = $match[0][1]; | |
1175 | } else { | |
1176 | $this->compiler->trigger_template_error("missing or misspelled literal closing tag"); | |
1177 | } | |
1178 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
1179 | $this->token = Smarty_Internal_Templateparser::TP_LITERAL; | |
1180 | } | |
1181 | ||
1182 | public function yylex4() | |
1183 | { | |
1184 | $tokenMap = array( | |
1185 | 1 => 1, | |
1186 | 3 => 0, | |
1187 | 4 => 0, | |
1188 | 5 => 0, | |
1189 | 6 => 0, | |
1190 | 7 => 0, | |
1191 | 8 => 0, | |
1192 | 9 => 0, | |
1193 | 10 => 0, | |
1194 | 11 => 0, | |
1195 | 12 => 0, | |
1196 | 13 => 3, | |
1197 | 17 => 0, | |
1198 | ); | |
1199 | if ($this->counter >= strlen($this->data)) { | |
1200 | return false; // end of input | |
1201 | } | |
1202 | $yy_global_pattern = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/iS"; | |
1203 | ||
1204 | do { | |
1205 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
1206 | $yysubmatches = $yymatches; | |
ccd27f54 | 1207 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
1208 | if (!count($yymatches)) { |
1209 | throw new Exception('Error: lexing failed because a rule matched' . | |
1210 | ' an empty string. Input "' . substr($this->data, | |
1211 | $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); | |
1212 | } | |
1213 | next($yymatches); // skip global match | |
1214 | $this->token = key($yymatches); // token number | |
1215 | if ($tokenMap[$this->token]) { | |
1216 | // extract sub-patterns for passing to lex function | |
1217 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
1218 | $tokenMap[$this->token]); | |
1219 | } else { | |
1220 | $yysubmatches = array(); | |
1221 | } | |
1222 | $this->value = current($yymatches); // token value | |
1223 | $r = $this->{'yy_r4_' . $this->token}($yysubmatches); | |
1224 | if ($r === null) { | |
1225 | $this->counter += strlen($this->value); | |
1226 | $this->line += substr_count($this->value, "\n"); | |
1227 | // accept this token | |
1228 | return true; | |
1229 | } elseif ($r === true) { | |
1230 | // we have changed state | |
1231 | // process this token in the new state | |
1232 | return $this->yylex(); | |
1233 | } elseif ($r === false) { | |
1234 | $this->counter += strlen($this->value); | |
1235 | $this->line += substr_count($this->value, "\n"); | |
1236 | if ($this->counter >= strlen($this->data)) { | |
1237 | return false; // end of input | |
1238 | } | |
1239 | // skip this token | |
1240 | continue; | |
1241 | } | |
1242 | } else { | |
1243 | throw new Exception('Unexpected input at line' . $this->line . | |
1244 | ': ' . $this->data[$this->counter]); | |
1245 | } | |
1246 | break; | |
1247 | } while (true); | |
1248 | } // end function | |
1249 | ||
1250 | const DOUBLEQUOTEDSTRING = 4; | |
1251 | ||
1252 | function yy_r4_1($yy_subpatterns) | |
1253 | { | |
1254 | ||
1255 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1256 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1257 | } else { | |
1258 | $this->token = Smarty_Internal_Templateparser::TP_LDELIF; | |
1259 | $this->yypushstate(self::SMARTY); | |
1260 | $this->taglineno = $this->line; | |
1261 | } | |
1262 | } | |
1263 | ||
1264 | function yy_r4_3($yy_subpatterns) | |
1265 | { | |
1266 | ||
1267 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1268 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1269 | } else { | |
1270 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; | |
1271 | $this->yypushstate(self::SMARTY); | |
1272 | $this->taglineno = $this->line; | |
1273 | } | |
1274 | } | |
1275 | ||
1276 | function yy_r4_4($yy_subpatterns) | |
1277 | { | |
1278 | ||
1279 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1280 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1281 | } else { | |
1282 | $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; | |
1283 | $this->yypushstate(self::SMARTY); | |
1284 | $this->taglineno = $this->line; | |
1285 | } | |
1286 | } | |
1287 | ||
1288 | function yy_r4_5($yy_subpatterns) | |
1289 | { | |
1290 | ||
1291 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1292 | } | |
1293 | ||
1294 | function yy_r4_6($yy_subpatterns) | |
1295 | { | |
1296 | ||
1297 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1298 | } | |
1299 | ||
1300 | function yy_r4_7($yy_subpatterns) | |
1301 | { | |
1302 | ||
1303 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1304 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1305 | } else { | |
1306 | $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; | |
1307 | $this->yypushstate(self::SMARTY); | |
1308 | $this->taglineno = $this->line; | |
1309 | } | |
1310 | } | |
1311 | ||
1312 | function yy_r4_8($yy_subpatterns) | |
1313 | { | |
1314 | ||
1315 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1316 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1317 | } else { | |
1318 | $this->token = Smarty_Internal_Templateparser::TP_LDEL; | |
1319 | $this->yypushstate(self::SMARTY); | |
1320 | $this->taglineno = $this->line; | |
1321 | } | |
1322 | } | |
1323 | ||
1324 | function yy_r4_9($yy_subpatterns) | |
1325 | { | |
1326 | ||
1327 | $this->token = Smarty_Internal_Templateparser::TP_QUOTE; | |
1328 | $this->yypopstate(); | |
1329 | } | |
1330 | ||
1331 | function yy_r4_10($yy_subpatterns) | |
1332 | { | |
1333 | ||
1334 | $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; | |
1335 | $this->value = substr($this->value, 0, - 1); | |
1336 | $this->yypushstate(self::SMARTY); | |
1337 | $this->taglineno = $this->line; | |
1338 | } | |
1339 | ||
1340 | function yy_r4_11($yy_subpatterns) | |
1341 | { | |
1342 | ||
1343 | $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; | |
1344 | } | |
1345 | ||
1346 | function yy_r4_12($yy_subpatterns) | |
1347 | { | |
1348 | ||
1349 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1350 | } | |
1351 | ||
1352 | function yy_r4_13($yy_subpatterns) | |
1353 | { | |
1354 | ||
1355 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1356 | } | |
1357 | ||
1358 | function yy_r4_17($yy_subpatterns) | |
1359 | { | |
1360 | ||
1361 | $to = strlen($this->data); | |
1362 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
1363 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; | |
1364 | } | |
1365 | ||
1366 | public function yylex5() | |
1367 | { | |
1368 | $tokenMap = array( | |
1369 | 1 => 0, | |
1370 | 2 => 0, | |
1371 | 3 => 0, | |
1372 | 4 => 0, | |
1373 | ); | |
1374 | if ($this->counter >= strlen($this->data)) { | |
1375 | return false; // end of input | |
1376 | } | |
1377 | $yy_global_pattern = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/iS"; | |
1378 | ||
1379 | do { | |
1380 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
1381 | $yysubmatches = $yymatches; | |
ccd27f54 | 1382 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
1383 | if (!count($yymatches)) { |
1384 | throw new Exception('Error: lexing failed because a rule matched' . | |
1385 | ' an empty string. Input "' . substr($this->data, | |
1386 | $this->counter, 5) . '... state CHILDBODY'); | |
1387 | } | |
1388 | next($yymatches); // skip global match | |
1389 | $this->token = key($yymatches); // token number | |
1390 | if ($tokenMap[$this->token]) { | |
1391 | // extract sub-patterns for passing to lex function | |
1392 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
1393 | $tokenMap[$this->token]); | |
1394 | } else { | |
1395 | $yysubmatches = array(); | |
1396 | } | |
1397 | $this->value = current($yymatches); // token value | |
1398 | $r = $this->{'yy_r5_' . $this->token}($yysubmatches); | |
1399 | if ($r === null) { | |
1400 | $this->counter += strlen($this->value); | |
1401 | $this->line += substr_count($this->value, "\n"); | |
1402 | // accept this token | |
1403 | return true; | |
1404 | } elseif ($r === true) { | |
1405 | // we have changed state | |
1406 | // process this token in the new state | |
1407 | return $this->yylex(); | |
1408 | } elseif ($r === false) { | |
1409 | $this->counter += strlen($this->value); | |
1410 | $this->line += substr_count($this->value, "\n"); | |
1411 | if ($this->counter >= strlen($this->data)) { | |
1412 | return false; // end of input | |
1413 | } | |
1414 | // skip this token | |
1415 | continue; | |
1416 | } | |
1417 | } else { | |
1418 | throw new Exception('Unexpected input at line' . $this->line . | |
1419 | ': ' . $this->data[$this->counter]); | |
1420 | } | |
1421 | break; | |
1422 | } while (true); | |
1423 | } // end function | |
1424 | ||
1425 | const CHILDBODY = 5; | |
1426 | ||
1427 | function yy_r5_1($yy_subpatterns) | |
1428 | { | |
1429 | ||
1430 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1431 | return false; | |
1432 | } else { | |
1433 | $this->token = Smarty_Internal_Templateparser::TP_STRIPON; | |
1434 | } | |
1435 | } | |
1436 | ||
1437 | function yy_r5_2($yy_subpatterns) | |
1438 | { | |
1439 | ||
1440 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1441 | return false; | |
1442 | } else { | |
1443 | $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF; | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | function yy_r5_3($yy_subpatterns) | |
1448 | { | |
1449 | ||
1450 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1451 | return false; | |
1452 | } else { | |
1453 | $this->yypopstate(); | |
1454 | return true; | |
1455 | } | |
1456 | } | |
1457 | ||
1458 | function yy_r5_4($yy_subpatterns) | |
1459 | { | |
1460 | ||
1461 | $to = strlen($this->data); | |
1462 | preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); | |
1463 | if (isset($match[0][1])) { | |
1464 | $to = $match[0][1]; | |
1465 | } | |
1466 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
1467 | return false; | |
1468 | } | |
1469 | ||
1470 | public function yylex6() | |
1471 | { | |
1472 | $tokenMap = array( | |
1473 | 1 => 0, | |
1474 | 2 => 0, | |
1475 | 3 => 0, | |
1476 | 4 => 1, | |
1477 | 6 => 0, | |
1478 | ); | |
1479 | if ($this->counter >= strlen($this->data)) { | |
1480 | return false; // end of input | |
1481 | } | |
1482 | $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*\/block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/iS"; | |
1483 | ||
1484 | do { | |
1485 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
1486 | $yysubmatches = $yymatches; | |
ccd27f54 | 1487 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
1488 | if (!count($yymatches)) { |
1489 | throw new Exception('Error: lexing failed because a rule matched' . | |
1490 | ' an empty string. Input "' . substr($this->data, | |
1491 | $this->counter, 5) . '... state CHILDBLOCK'); | |
1492 | } | |
1493 | next($yymatches); // skip global match | |
1494 | $this->token = key($yymatches); // token number | |
1495 | if ($tokenMap[$this->token]) { | |
1496 | // extract sub-patterns for passing to lex function | |
1497 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
1498 | $tokenMap[$this->token]); | |
1499 | } else { | |
1500 | $yysubmatches = array(); | |
1501 | } | |
1502 | $this->value = current($yymatches); // token value | |
1503 | $r = $this->{'yy_r6_' . $this->token}($yysubmatches); | |
1504 | if ($r === null) { | |
1505 | $this->counter += strlen($this->value); | |
1506 | $this->line += substr_count($this->value, "\n"); | |
1507 | // accept this token | |
1508 | return true; | |
1509 | } elseif ($r === true) { | |
1510 | // we have changed state | |
1511 | // process this token in the new state | |
1512 | return $this->yylex(); | |
1513 | } elseif ($r === false) { | |
1514 | $this->counter += strlen($this->value); | |
1515 | $this->line += substr_count($this->value, "\n"); | |
1516 | if ($this->counter >= strlen($this->data)) { | |
1517 | return false; // end of input | |
1518 | } | |
1519 | // skip this token | |
1520 | continue; | |
1521 | } | |
1522 | } else { | |
1523 | throw new Exception('Unexpected input at line' . $this->line . | |
1524 | ': ' . $this->data[$this->counter]); | |
1525 | } | |
1526 | break; | |
1527 | } while (true); | |
1528 | } // end function | |
1529 | ||
1530 | const CHILDBLOCK = 6; | |
1531 | ||
1532 | function yy_r6_1($yy_subpatterns) | |
1533 | { | |
1534 | ||
1535 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1536 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1537 | } else { | |
1538 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1539 | $this->yypushstate(self::CHILDLITERAL); | |
1540 | } | |
1541 | } | |
1542 | ||
1543 | function yy_r6_2($yy_subpatterns) | |
1544 | { | |
1545 | ||
1546 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1547 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1548 | } else { | |
1549 | $this->yypopstate(); | |
1550 | return true; | |
1551 | } | |
1552 | } | |
1553 | ||
1554 | function yy_r6_3($yy_subpatterns) | |
1555 | { | |
1556 | ||
1557 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1558 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1559 | } else { | |
1560 | $this->yypopstate(); | |
1561 | return true; | |
1562 | } | |
1563 | } | |
1564 | ||
1565 | function yy_r6_4($yy_subpatterns) | |
1566 | { | |
1567 | ||
1568 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1569 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1570 | } else { | |
1571 | $this->yypopstate(); | |
1572 | return true; | |
1573 | } | |
1574 | } | |
1575 | ||
1576 | function yy_r6_6($yy_subpatterns) | |
1577 | { | |
1578 | ||
1579 | $to = strlen($this->data); | |
1580 | preg_match("/" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|(\/)?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); | |
1581 | if (isset($match[0][1])) { | |
1582 | $to = $match[0][1]; | |
1583 | } | |
1584 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
1585 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1586 | } | |
1587 | ||
1588 | public function yylex7() | |
1589 | { | |
1590 | $tokenMap = array( | |
1591 | 1 => 0, | |
1592 | 2 => 0, | |
1593 | 3 => 0, | |
1594 | ); | |
1595 | if ($this->counter >= strlen($this->data)) { | |
1596 | return false; // end of input | |
1597 | } | |
1598 | $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS"; | |
1599 | ||
1600 | do { | |
1601 | if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { | |
1602 | $yysubmatches = $yymatches; | |
ccd27f54 | 1603 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
2aa91ff2 S |
1604 | if (!count($yymatches)) { |
1605 | throw new Exception('Error: lexing failed because a rule matched' . | |
1606 | ' an empty string. Input "' . substr($this->data, | |
1607 | $this->counter, 5) . '... state CHILDLITERAL'); | |
1608 | } | |
1609 | next($yymatches); // skip global match | |
1610 | $this->token = key($yymatches); // token number | |
1611 | if ($tokenMap[$this->token]) { | |
1612 | // extract sub-patterns for passing to lex function | |
1613 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, | |
1614 | $tokenMap[$this->token]); | |
1615 | } else { | |
1616 | $yysubmatches = array(); | |
1617 | } | |
1618 | $this->value = current($yymatches); // token value | |
1619 | $r = $this->{'yy_r7_' . $this->token}($yysubmatches); | |
1620 | if ($r === null) { | |
1621 | $this->counter += strlen($this->value); | |
1622 | $this->line += substr_count($this->value, "\n"); | |
1623 | // accept this token | |
1624 | return true; | |
1625 | } elseif ($r === true) { | |
1626 | // we have changed state | |
1627 | // process this token in the new state | |
1628 | return $this->yylex(); | |
1629 | } elseif ($r === false) { | |
1630 | $this->counter += strlen($this->value); | |
1631 | $this->line += substr_count($this->value, "\n"); | |
1632 | if ($this->counter >= strlen($this->data)) { | |
1633 | return false; // end of input | |
1634 | } | |
1635 | // skip this token | |
1636 | continue; | |
1637 | } | |
1638 | } else { | |
1639 | throw new Exception('Unexpected input at line' . $this->line . | |
1640 | ': ' . $this->data[$this->counter]); | |
1641 | } | |
1642 | break; | |
1643 | } while (true); | |
1644 | } // end function | |
1645 | ||
1646 | const CHILDLITERAL = 7; | |
1647 | ||
1648 | function yy_r7_1($yy_subpatterns) | |
1649 | { | |
1650 | ||
1651 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1652 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1653 | } else { | |
1654 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1655 | $this->yypushstate(self::CHILDLITERAL); | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | function yy_r7_2($yy_subpatterns) | |
1660 | { | |
1661 | ||
1662 | if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { | |
1663 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1664 | } else { | |
1665 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1666 | $this->yypopstate(); | |
1667 | } | |
1668 | } | |
1669 | ||
1670 | function yy_r7_3($yy_subpatterns) | |
1671 | { | |
1672 | ||
1673 | $to = strlen($this->data); | |
1674 | preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); | |
1675 | if (isset($match[0][1])) { | |
1676 | $to = $match[0][1]; | |
1677 | } else { | |
1678 | $this->compiler->trigger_template_error("missing or misspelled literal closing tag"); | |
1679 | } | |
1680 | $this->value = substr($this->data, $this->counter, $to - $this->counter); | |
1681 | $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; | |
1682 | } | |
1683 | } | |
1684 | ||
1685 |