131153dacd8aef86113400cf1fe2275d9101673c
1 <?php
2 /**
3 * Smarty Internal Plugin Templatelexer
4 *
5 * This is the lexer to break the template source into tokens
6 * @package Smarty
7 * @subpackage Compiler
8 * @author Uwe Tews
9 */
10 /**
11 * Smarty Internal Plugin Templatelexer
12 */
13 class Smarty_Internal_Templatelexer
14 {
15 public $data;
16 public $counter;
17 public $token;
18 public $value;
19 public $node;
20 public $line;
21 public $taglineno;
22 public $state = 1;
23 public $strip = false;
24 private $heredoc_id_stack = Array();
25 public $smarty_token_names = array ( // Text for parser error messages
26 'IDENTITY' => '===',
27 'NONEIDENTITY' => '!==',
28 'EQUALS' => '==',
29 'NOTEQUALS' => '!=',
30 'GREATEREQUAL' => '(>=,ge)',
31 'LESSEQUAL' => '(<=,le)',
32 'GREATERTHAN' => '(>,gt)',
33 'LESSTHAN' => '(<,lt)',
34 'MOD' => '(%,mod)',
35 'NOT' => '(!,not)',
36 'LAND' => '(&&,and)',
37 'LOR' => '(||,or)',
38 'LXOR' => 'xor',
39 'OPENP' => '(',
40 'CLOSEP' => ')',
41 'OPENB' => '[',
42 'CLOSEB' => ']',
43 'PTR' => '->',
44 'APTR' => '=>',
45 'EQUAL' => '=',
46 'NUMBER' => 'number',
47 'UNIMATH' => '+" , "-',
48 'MATH' => '*" , "/" , "%',
49 'INCDEC' => '++" , "--',
50 'SPACE' => ' ',
51 'DOLLAR' => '$',
52 'SEMICOLON' => ';',
53 'COLON' => ':',
54 'DOUBLECOLON' => '::',
55 'AT' => '@',
56 'HATCH' => '#',
57 'QUOTE' => '"',
58 'BACKTICK' => '`',
59 'VERT' => '|',
60 'DOT' => '.',
61 'COMMA' => '","',
62 'ANDSYM' => '"&"',
63 'QMARK' => '"?"',
64 'ID' => 'identifier',
65 'OTHER' => 'text',
66 'LINEBREAK' => 'newline',
67 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
68 'PHPSTARTTAG' => 'PHP start tag',
69 'PHPENDTAG' => 'PHP end tag',
70 'LITERALSTART' => 'Literal start',
71 'LITERALEND' => 'Literal end',
72 'LDELSLASH' => 'closing tag',
73 'COMMENT' => 'comment',
74 'AS' => 'as',
75 'TO' => 'to',
76 );
79 function __construct($data,$compiler)
80 {
81 // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
82 $this->data = $data;
83 $this->counter = 0;
84 $this->line = 1;
85 $this->smarty = $compiler->smarty;
86 $this->compiler = $compiler;
87 $this->ldel = preg_quote($this->smarty->left_delimiter,'/');
88 $this->ldel_length = strlen($this->smarty->left_delimiter);
89 $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
90 $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
91 $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
92 $this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
93 }
96 private $_yy_state = 1;
97 private $_yy_stack = array();
99 function yylex()
100 {
101 return $this->{'yylex' . $this->_yy_state}();
102 }
104 function yypushstate($state)
105 {
106 array_push($this->_yy_stack, $this->_yy_state);
107 $this->_yy_state = $state;
108 }
110 function yypopstate()
111 {
112 $this->_yy_state = array_pop($this->_yy_stack);
113 }
115 function yybegin($state)
116 {
117 $this->_yy_state = $state;
118 }
122 function yylex1()
123 {
124 $tokenMap = array (
125 1 => 0,
126 2 => 0,
127 3 => 1,
128 5 => 0,
129 6 => 0,
130 7 => 0,
131 8 => 0,
132 9 => 0,
133 10 => 0,
134 11 => 0,
135 12 => 1,
136 14 => 0,
137 15 => 0,
138 16 => 0,
139 17 => 0,
140 18 => 0,
141 19 => 0,
142 20 => 0,
143 21 => 0,
144 22 => 0,
145 23 => 0,
146 24 => 2,
147 27 => 0,
148 28 => 0,
149 );
150 if ($this->counter >= strlen($this->data)) {
151 return false; // end of input
152 }
153 $yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G([\t ]*[\r\n]+[\t ]*)|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|\G([\S\s]+)|\G(.)/iS";
155 do {
156 if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
157 $yysubmatches = $yymatches;
158 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
159 if (!count($yymatches)) {
160 throw new Exception('Error: lexing failed because a rule matched' .
161 ' an empty string. Input "' . substr($this->data,
162 $this->counter, 5) . '... state TEXT');
163 }
164 next($yymatches); // skip global match
165 $this->token = key($yymatches); // token number
166 if ($tokenMap[$this->token]) {
167 // extract sub-patterns for passing to lex function
168 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
169 $tokenMap[$this->token]);
170 } else {
171 $yysubmatches = array();
172 }
173 $this->value = current($yymatches); // token value
174 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
175 if ($r === null) {
176 $this->counter += strlen($this->value);
177 $this->line += substr_count($this->value, "\n");
178 // accept this token
179 return true;
180 } elseif ($r === true) {
181 // we have changed state
182 // process this token in the new state
183 return $this->yylex();
184 } elseif ($r === false) {
185 $this->counter += strlen($this->value);
186 $this->line += substr_count($this->value, "\n");
187 if ($this->counter >= strlen($this->data)) {
188 return false; // end of input
189 }
190 // skip this token
191 continue;
192 } } else {
193 throw new Exception('Unexpected input at line' . $this->line .
194 ': ' . $this->data[$this->counter]);
195 }
196 break;
197 } while (true);
199 } // end function
202 const TEXT = 1;
203 function yy_r1_1($yy_subpatterns)
204 {
206 $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILD;
207 }
208 function yy_r1_2($yy_subpatterns)
209 {
211 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
212 }
213 function yy_r1_3($yy_subpatterns)
214 {
216 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
217 }
218 function yy_r1_5($yy_subpatterns)
219 {
221 if ($this->strip) {
222 return false;
223 } else {
224 $this->token = Smarty_Internal_Templateparser::TP_LINEBREAK;
225 }
226 }
227 function yy_r1_6($yy_subpatterns)
228 {
230 $this->strip = true;
231 return false;
232 }
233 function yy_r1_7($yy_subpatterns)
234 {
236 if ($this->smarty->auto_literal) {
237 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
238 } else {
239 $this->strip = true;
240 return false;
241 }
242 }
243 function yy_r1_8($yy_subpatterns)
244 {
246 $this->strip = false;
247 return false;
248 }
249 function yy_r1_9($yy_subpatterns)
250 {
252 if ($this->smarty->auto_literal) {
253 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
254 } else {
255 $this->strip = false;
256 return false;
257 }
258 }
259 function yy_r1_10($yy_subpatterns)
260 {
262 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
263 $this->yypushstate(self::LITERAL);
264 }
265 function yy_r1_11($yy_subpatterns)
266 {
268 if ($this->smarty->auto_literal) {
269 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
270 } else {
271 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
272 $this->yypushstate(self::SMARTY);
273 $this->taglineno = $this->line;
274 }
275 }
276 function yy_r1_12($yy_subpatterns)
277 {
279 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
280 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
281 } else {
282 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
283 $this->yypushstate(self::SMARTY);
284 $this->taglineno = $this->line;
285 }
286 }
287 function yy_r1_14($yy_subpatterns)
288 {
290 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
291 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
292 } else {
293 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
294 $this->yypushstate(self::SMARTY);
295 $this->taglineno = $this->line;
296 }
297 }
298 function yy_r1_15($yy_subpatterns)
299 {
301 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
302 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
303 } else {
304 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
305 $this->yypushstate(self::SMARTY);
306 $this->taglineno = $this->line;
307 }
308 }
309 function yy_r1_16($yy_subpatterns)
310 {
312 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
313 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
314 } else {
315 $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
316 $this->yypushstate(self::SMARTY);
317 $this->taglineno = $this->line;
318 }
319 }
320 function yy_r1_17($yy_subpatterns)
321 {
323 if ($this->smarty->auto_literal) {
324 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
325 } else {
326 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
327 $this->yypushstate(self::SMARTY);
328 $this->taglineno = $this->line;
329 }
330 }
331 function yy_r1_18($yy_subpatterns)
332 {
334 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
335 $this->yypushstate(self::SMARTY);
336 $this->taglineno = $this->line;
337 }
338 function yy_r1_19($yy_subpatterns)
339 {
341 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
342 $this->yypushstate(self::SMARTY);
343 $this->taglineno = $this->line;
344 }
345 function yy_r1_20($yy_subpatterns)
346 {
348 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
349 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
350 } elseif ($this->value == '<?xml') {
351 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
352 } else {
353 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
354 $this->value = substr($this->value, 0, 2);
355 }
356 }
357 function yy_r1_21($yy_subpatterns)
358 {
360 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
361 }
362 function yy_r1_22($yy_subpatterns)
363 {
365 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
366 }
367 function yy_r1_23($yy_subpatterns)
368 {
370 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
371 }
372 function yy_r1_24($yy_subpatterns)
373 {
375 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
376 }
377 function yy_r1_27($yy_subpatterns)
378 {
380 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
381 }
382 function yy_r1_28($yy_subpatterns)
383 {
385 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
386 }
389 function yylex2()
390 {
391 $tokenMap = array (
392 1 => 0,
393 2 => 0,
394 3 => 1,
395 5 => 0,
396 6 => 0,
397 7 => 0,
398 8 => 0,
399 9 => 0,
400 10 => 0,
401 11 => 0,
402 12 => 0,
403 13 => 0,
404 14 => 0,
405 15 => 0,
406 16 => 0,
407 17 => 0,
408 18 => 0,
409 19 => 0,
410 20 => 1,
411 22 => 1,
412 24 => 1,
413 26 => 0,
414 27 => 0,
415 28 => 0,
416 29 => 0,
417 30 => 0,
418 31 => 0,
419 32 => 0,
420 33 => 0,
421 34 => 0,
422 35 => 0,
423 36 => 0,
424 37 => 0,
425 38 => 0,
426 39 => 0,
427 40 => 0,
428 41 => 0,
429 42 => 0,
430 43 => 3,
431 47 => 0,
432 48 => 0,
433 49 => 0,
434 50 => 0,
435 51 => 0,
436 52 => 0,
437 53 => 0,
438 54 => 0,
439 55 => 1,
440 57 => 1,
441 59 => 0,
442 60 => 0,
443 61 => 0,
444 62 => 0,
445 63 => 0,
446 64 => 0,
447 65 => 0,
448 66 => 0,
449 67 => 0,
450 68 => 0,
451 69 => 0,
452 70 => 0,
453 71 => 0,
454 72 => 0,
455 73 => 0,
456 74 => 0,
457 75 => 0,
458 76 => 0,
459 );
460 if ($this->counter >= strlen($this->data)) {
461 return false; // end of input
462 }
463 $yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$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*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G(.)/iS";
465 do {
466 if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
467 $yysubmatches = $yymatches;
468 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
469 if (!count($yymatches)) {
470 throw new Exception('Error: lexing failed because a rule matched' .
471 ' an empty string. Input "' . substr($this->data,
472 $this->counter, 5) . '... state SMARTY');
473 }
474 next($yymatches); // skip global match
475 $this->token = key($yymatches); // token number
476 if ($tokenMap[$this->token]) {
477 // extract sub-patterns for passing to lex function
478 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
479 $tokenMap[$this->token]);
480 } else {
481 $yysubmatches = array();
482 }
483 $this->value = current($yymatches); // token value
484 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
485 if ($r === null) {
486 $this->counter += strlen($this->value);
487 $this->line += substr_count($this->value, "\n");
488 // accept this token
489 return true;
490 } elseif ($r === true) {
491 // we have changed state
492 // process this token in the new state
493 return $this->yylex();
494 } elseif ($r === false) {
495 $this->counter += strlen($this->value);
496 $this->line += substr_count($this->value, "\n");
497 if ($this->counter >= strlen($this->data)) {
498 return false; // end of input
499 }
500 // skip this token
501 continue;
502 } } else {
503 throw new Exception('Unexpected input at line' . $this->line .
504 ': ' . $this->data[$this->counter]);
505 }
506 break;
507 } while (true);
509 } // end function
512 const SMARTY = 2;
513 function yy_r2_1($yy_subpatterns)
514 {
516 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
517 }
518 function yy_r2_2($yy_subpatterns)
519 {
521 if ($this->smarty->auto_literal) {
522 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
523 } else {
524 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
525 $this->yypushstate(self::SMARTY);
526 $this->taglineno = $this->line;
527 }
528 }
529 function yy_r2_3($yy_subpatterns)
530 {
532 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
533 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
534 } else {
535 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
536 $this->yypushstate(self::SMARTY);
537 $this->taglineno = $this->line;
538 }
539 }
540 function yy_r2_5($yy_subpatterns)
541 {
543 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
544 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
545 } else {
546 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
547 $this->yypushstate(self::SMARTY);
548 $this->taglineno = $this->line;
549 }
550 }
551 function yy_r2_6($yy_subpatterns)
552 {
554 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
555 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
556 } else {
557 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
558 $this->yypushstate(self::SMARTY);
559 $this->taglineno = $this->line;
560 }
561 }
562 function yy_r2_7($yy_subpatterns)
563 {
565 if ($this->smarty->auto_literal) {
566 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
567 } else {
568 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
569 $this->yypushstate(self::SMARTY);
570 $this->taglineno = $this->line;
571 }
572 }
573 function yy_r2_8($yy_subpatterns)
574 {
576 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
577 $this->yypopstate();
578 }
579 function yy_r2_9($yy_subpatterns)
580 {
582 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
583 $this->yypushstate(self::SMARTY);
584 $this->taglineno = $this->line;
585 }
586 function yy_r2_10($yy_subpatterns)
587 {
589 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
590 $this->yypushstate(self::SMARTY);
591 $this->taglineno = $this->line;
592 }
593 function yy_r2_11($yy_subpatterns)
594 {
596 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
597 $this->yypopstate();
598 }
599 function yy_r2_12($yy_subpatterns)
600 {
602 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
603 }
604 function yy_r2_13($yy_subpatterns)
605 {
607 $this->token = Smarty_Internal_Templateparser::TP_AS;
608 }
609 function yy_r2_14($yy_subpatterns)
610 {
612 $this->token = Smarty_Internal_Templateparser::TP_TO;
613 }
614 function yy_r2_15($yy_subpatterns)
615 {
617 $this->token = Smarty_Internal_Templateparser::TP_STEP;
618 }
619 function yy_r2_16($yy_subpatterns)
620 {
622 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
623 }
624 function yy_r2_17($yy_subpatterns)
625 {
627 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
628 }
629 function yy_r2_18($yy_subpatterns)
630 {
632 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
633 }
634 function yy_r2_19($yy_subpatterns)
635 {
637 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
638 }
639 function yy_r2_20($yy_subpatterns)
640 {
642 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
643 }
644 function yy_r2_22($yy_subpatterns)
645 {
647 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
648 }
649 function yy_r2_24($yy_subpatterns)
650 {
652 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
653 }
654 function yy_r2_26($yy_subpatterns)
655 {
657 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
658 }
659 function yy_r2_27($yy_subpatterns)
660 {
662 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
663 }
664 function yy_r2_28($yy_subpatterns)
665 {
667 $this->token = Smarty_Internal_Templateparser::TP_MOD;
668 }
669 function yy_r2_29($yy_subpatterns)
670 {
672 $this->token = Smarty_Internal_Templateparser::TP_NOT;
673 }
674 function yy_r2_30($yy_subpatterns)
675 {
677 $this->token = Smarty_Internal_Templateparser::TP_LAND;
678 }
679 function yy_r2_31($yy_subpatterns)
680 {
682 $this->token = Smarty_Internal_Templateparser::TP_LOR;
683 }
684 function yy_r2_32($yy_subpatterns)
685 {
687 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
688 }
689 function yy_r2_33($yy_subpatterns)
690 {
692 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
693 }
694 function yy_r2_34($yy_subpatterns)
695 {
697 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
698 }
699 function yy_r2_35($yy_subpatterns)
700 {
702 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
703 }
704 function yy_r2_36($yy_subpatterns)
705 {
707 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
708 }
709 function yy_r2_37($yy_subpatterns)
710 {
712 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
713 }
714 function yy_r2_38($yy_subpatterns)
715 {
717 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
718 }
719 function yy_r2_39($yy_subpatterns)
720 {
722 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
723 }
724 function yy_r2_40($yy_subpatterns)
725 {
727 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
728 }
729 function yy_r2_41($yy_subpatterns)
730 {
732 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
733 }
734 function yy_r2_42($yy_subpatterns)
735 {
737 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
738 }
739 function yy_r2_43($yy_subpatterns)
740 {
742 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
743 }
744 function yy_r2_47($yy_subpatterns)
745 {
747 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
748 }
749 function yy_r2_48($yy_subpatterns)
750 {
752 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
753 }
754 function yy_r2_49($yy_subpatterns)
755 {
757 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
758 }
759 function yy_r2_50($yy_subpatterns)
760 {
762 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
763 }
764 function yy_r2_51($yy_subpatterns)
765 {
767 $this->token = Smarty_Internal_Templateparser::TP_PTR;
768 }
769 function yy_r2_52($yy_subpatterns)
770 {
772 $this->token = Smarty_Internal_Templateparser::TP_APTR;
773 }
774 function yy_r2_53($yy_subpatterns)
775 {
777 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
778 }
779 function yy_r2_54($yy_subpatterns)
780 {
782 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
783 }
784 function yy_r2_55($yy_subpatterns)
785 {
787 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
788 }
789 function yy_r2_57($yy_subpatterns)
790 {
792 $this->token = Smarty_Internal_Templateparser::TP_MATH;
793 }
794 function yy_r2_59($yy_subpatterns)
795 {
797 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
798 }
799 function yy_r2_60($yy_subpatterns)
800 {
802 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
803 }
804 function yy_r2_61($yy_subpatterns)
805 {
807 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
808 }
809 function yy_r2_62($yy_subpatterns)
810 {
812 $this->token = Smarty_Internal_Templateparser::TP_COLON;
813 }
814 function yy_r2_63($yy_subpatterns)
815 {
817 $this->token = Smarty_Internal_Templateparser::TP_AT;
818 }
819 function yy_r2_64($yy_subpatterns)
820 {
822 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
823 }
824 function yy_r2_65($yy_subpatterns)
825 {
827 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
828 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
829 }
830 function yy_r2_66($yy_subpatterns)
831 {
833 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
834 $this->yypopstate();
835 }
836 function yy_r2_67($yy_subpatterns)
837 {
839 $this->token = Smarty_Internal_Templateparser::TP_VERT;
840 }
841 function yy_r2_68($yy_subpatterns)
842 {
844 $this->token = Smarty_Internal_Templateparser::TP_DOT;
845 }
846 function yy_r2_69($yy_subpatterns)
847 {
849 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
850 }
851 function yy_r2_70($yy_subpatterns)
852 {
854 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
855 }
856 function yy_r2_71($yy_subpatterns)
857 {
859 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
860 }
861 function yy_r2_72($yy_subpatterns)
862 {
864 $this->token = Smarty_Internal_Templateparser::TP_HEX;
865 }
866 function yy_r2_73($yy_subpatterns)
867 {
869 $this->token = Smarty_Internal_Templateparser::TP_ID;
870 }
871 function yy_r2_74($yy_subpatterns)
872 {
874 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
875 }
876 function yy_r2_75($yy_subpatterns)
877 {
879 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
880 }
881 function yy_r2_76($yy_subpatterns)
882 {
884 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
885 }
889 function yylex3()
890 {
891 $tokenMap = array (
892 1 => 0,
893 2 => 0,
894 3 => 0,
895 4 => 0,
896 5 => 0,
897 6 => 0,
898 7 => 0,
899 8 => 2,
900 11 => 0,
901 );
902 if ($this->counter >= strlen($this->data)) {
903 return false; // end of input
904 }
905 $yy_global_pattern = "/\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|\G([\t ]*[\r\n]+[\t ]*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|\G(.)/iS";
907 do {
908 if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
909 $yysubmatches = $yymatches;
910 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
911 if (!count($yymatches)) {
912 throw new Exception('Error: lexing failed because a rule matched' .
913 ' an empty string. Input "' . substr($this->data,
914 $this->counter, 5) . '... state LITERAL');
915 }
916 next($yymatches); // skip global match
917 $this->token = key($yymatches); // token number
918 if ($tokenMap[$this->token]) {
919 // extract sub-patterns for passing to lex function
920 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
921 $tokenMap[$this->token]);
922 } else {
923 $yysubmatches = array();
924 }
925 $this->value = current($yymatches); // token value
926 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
927 if ($r === null) {
928 $this->counter += strlen($this->value);
929 $this->line += substr_count($this->value, "\n");
930 // accept this token
931 return true;
932 } elseif ($r === true) {
933 // we have changed state
934 // process this token in the new state
935 return $this->yylex();
936 } elseif ($r === false) {
937 $this->counter += strlen($this->value);
938 $this->line += substr_count($this->value, "\n");
939 if ($this->counter >= strlen($this->data)) {
940 return false; // end of input
941 }
942 // skip this token
943 continue;
944 } } else {
945 throw new Exception('Unexpected input at line' . $this->line .
946 ': ' . $this->data[$this->counter]);
947 }
948 break;
949 } while (true);
951 } // end function
954 const LITERAL = 3;
955 function yy_r3_1($yy_subpatterns)
956 {
958 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
959 $this->yypushstate(self::LITERAL);
960 }
961 function yy_r3_2($yy_subpatterns)
962 {
964 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
965 $this->yypopstate();
966 }
967 function yy_r3_3($yy_subpatterns)
968 {
970 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
971 }
972 function yy_r3_4($yy_subpatterns)
973 {
975 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
976 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
977 } else {
978 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
979 $this->value = substr($this->value, 0, 2);
980 }
981 }
982 function yy_r3_5($yy_subpatterns)
983 {
985 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
986 }
987 function yy_r3_6($yy_subpatterns)
988 {
990 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
991 }
992 function yy_r3_7($yy_subpatterns)
993 {
995 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
996 }
997 function yy_r3_8($yy_subpatterns)
998 {
1000 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
1001 }
1002 function yy_r3_11($yy_subpatterns)
1003 {
1005 $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
1006 }
1009 function yylex4()
1010 {
1011 $tokenMap = array (
1012 1 => 0,
1013 2 => 1,
1014 4 => 0,
1015 5 => 0,
1016 6 => 0,
1017 7 => 0,
1018 8 => 0,
1019 9 => 0,
1020 10 => 0,
1021 11 => 0,
1022 12 => 0,
1023 13 => 3,
1024 17 => 0,
1025 18 => 0,
1026 );
1027 if ($this->counter >= strlen($this->data)) {
1028 return false; // end of input
1029 }
1030 $yy_global_pattern = "/\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|\G([\S\s]+)|\G(.)/iS";
1032 do {
1033 if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
1034 $yysubmatches = $yymatches;
1035 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1036 if (!count($yymatches)) {
1037 throw new Exception('Error: lexing failed because a rule matched' .
1038 ' an empty string. Input "' . substr($this->data,
1039 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1040 }
1041 next($yymatches); // skip global match
1042 $this->token = key($yymatches); // token number
1043 if ($tokenMap[$this->token]) {
1044 // extract sub-patterns for passing to lex function
1045 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1046 $tokenMap[$this->token]);
1047 } else {
1048 $yysubmatches = array();
1049 }
1050 $this->value = current($yymatches); // token value
1051 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1052 if ($r === null) {
1053 $this->counter += strlen($this->value);
1054 $this->line += substr_count($this->value, "\n");
1055 // accept this token
1056 return true;
1057 } elseif ($r === true) {
1058 // we have changed state
1059 // process this token in the new state
1060 return $this->yylex();
1061 } elseif ($r === false) {
1062 $this->counter += strlen($this->value);
1063 $this->line += substr_count($this->value, "\n");
1064 if ($this->counter >= strlen($this->data)) {
1065 return false; // end of input
1066 }
1067 // skip this token
1068 continue;
1069 } } else {
1070 throw new Exception('Unexpected input at line' . $this->line .
1071 ': ' . $this->data[$this->counter]);
1072 }
1073 break;
1074 } while (true);
1076 } // end function
1079 const DOUBLEQUOTEDSTRING = 4;
1080 function yy_r4_1($yy_subpatterns)
1081 {
1083 if ($this->smarty->auto_literal) {
1084 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1085 } else {
1086 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1087 $this->yypushstate(self::SMARTY);
1088 $this->taglineno = $this->line;
1089 }
1090 }
1091 function yy_r4_2($yy_subpatterns)
1092 {
1094 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1095 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1096 } else {
1097 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
1098 $this->yypushstate(self::SMARTY);
1099 $this->taglineno = $this->line;
1100 }
1101 }
1102 function yy_r4_4($yy_subpatterns)
1103 {
1105 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1106 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1107 } else {
1108 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
1109 $this->yypushstate(self::SMARTY);
1110 $this->taglineno = $this->line;
1111 }
1112 }
1113 function yy_r4_5($yy_subpatterns)
1114 {
1116 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1117 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1118 } else {
1119 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
1120 $this->yypushstate(self::SMARTY);
1121 $this->taglineno = $this->line;
1122 }
1123 }
1124 function yy_r4_6($yy_subpatterns)
1125 {
1127 if ($this->smarty->auto_literal) {
1128 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1129 } else {
1130 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1131 $this->yypushstate(self::SMARTY);
1132 $this->taglineno = $this->line;
1133 }
1134 }
1135 function yy_r4_7($yy_subpatterns)
1136 {
1138 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1139 $this->yypushstate(self::SMARTY);
1140 $this->taglineno = $this->line;
1141 }
1142 function yy_r4_8($yy_subpatterns)
1143 {
1145 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1146 $this->yypushstate(self::SMARTY);
1147 $this->taglineno = $this->line;
1148 }
1149 function yy_r4_9($yy_subpatterns)
1150 {
1152 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1153 $this->yypopstate();
1154 }
1155 function yy_r4_10($yy_subpatterns)
1156 {
1158 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1159 $this->value = substr($this->value,0,-1);
1160 $this->yypushstate(self::SMARTY);
1161 $this->taglineno = $this->line;
1162 }
1163 function yy_r4_11($yy_subpatterns)
1164 {
1166 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1167 }
1168 function yy_r4_12($yy_subpatterns)
1169 {
1171 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1172 }
1173 function yy_r4_13($yy_subpatterns)
1174 {
1176 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1177 }
1178 function yy_r4_17($yy_subpatterns)
1179 {
1181 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1182 }
1183 function yy_r4_18($yy_subpatterns)
1184 {
1186 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1187 }
1189 }
1190 ?>