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 'LITERALEND' => 'literal close',
75 'AS' => 'as',
76 'TO' => 'to',
77 );
80 function __construct($data,$compiler)
81 {
82 // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
83 $this->data = $data;
84 $this->counter = 0;
85 $this->line = 1;
86 $this->smarty = $compiler->smarty;
87 $this->compiler = $compiler;
88 $this->ldel = preg_quote($this->smarty->left_delimiter,'/');
89 $this->ldel_length = strlen($this->smarty->left_delimiter);
90 $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
91 $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
92 $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
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 => 2,
146 26 => 0,
147 27 => 0,
148 );
149 if ($this->counter >= strlen($this->data)) {
150 return false; // end of input
151 }
152 $yy_global_pattern = "/^(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|^(".$this->ldel."\\s*for\\s+)|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)|^(.)/iS";
154 do {
155 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
156 $yysubmatches = $yymatches;
157 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
158 if (!count($yymatches)) {
159 throw new Exception('Error: lexing failed because a rule matched' .
160 'an empty string. Input "' . substr($this->data,
161 $this->counter, 5) . '... state TEXT');
162 }
163 next($yymatches); // skip global match
164 $this->token = key($yymatches); // token number
165 if ($tokenMap[$this->token]) {
166 // extract sub-patterns for passing to lex function
167 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
168 $tokenMap[$this->token]);
169 } else {
170 $yysubmatches = array();
171 }
172 $this->value = current($yymatches); // token value
173 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
174 if ($r === null) {
175 $this->counter += strlen($this->value);
176 $this->line += substr_count($this->value, "\n");
177 // accept this token
178 return true;
179 } elseif ($r === true) {
180 // we have changed state
181 // process this token in the new state
182 return $this->yylex();
183 } elseif ($r === false) {
184 $this->counter += strlen($this->value);
185 $this->line += substr_count($this->value, "\n");
186 if ($this->counter >= strlen($this->data)) {
187 return false; // end of input
188 }
189 // skip this token
190 continue;
191 } } else {
192 throw new Exception('Unexpected input at line' . $this->line .
193 ': ' . $this->data[$this->counter]);
194 }
195 break;
196 } while (true);
198 } // end function
201 const TEXT = 1;
202 function yy_r1_1($yy_subpatterns)
203 {
205 $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILD;
206 }
207 function yy_r1_2($yy_subpatterns)
208 {
210 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
211 }
212 function yy_r1_3($yy_subpatterns)
213 {
215 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
216 }
217 function yy_r1_5($yy_subpatterns)
218 {
220 if ($this->strip) {
221 return false;
222 } else {
223 $this->token = Smarty_Internal_Templateparser::TP_LINEBREAK;
224 }
225 }
226 function yy_r1_6($yy_subpatterns)
227 {
229 $this->strip = true;
230 return false;
231 }
232 function yy_r1_7($yy_subpatterns)
233 {
235 if ($this->smarty->auto_literal) {
236 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
237 } else {
238 $this->strip = true;
239 return false;
240 }
241 }
242 function yy_r1_8($yy_subpatterns)
243 {
245 $this->strip = false;
246 return false;
247 }
248 function yy_r1_9($yy_subpatterns)
249 {
251 if ($this->smarty->auto_literal) {
252 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
253 } else {
254 $this->strip = false;
255 return false;
256 }
257 }
258 function yy_r1_10($yy_subpatterns)
259 {
261 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
262 $this->yypushstate(self::LITERAL);
263 }
264 function yy_r1_11($yy_subpatterns)
265 {
267 if ($this->smarty->auto_literal) {
268 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
269 } else {
270 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
271 $this->yypushstate(self::SMARTY);
272 $this->taglineno = $this->line;
273 }
274 }
275 function yy_r1_12($yy_subpatterns)
276 {
278 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
279 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
280 } else {
281 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
282 $this->yypushstate(self::SMARTY);
283 $this->taglineno = $this->line;
284 }
285 }
286 function yy_r1_14($yy_subpatterns)
287 {
289 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
290 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
291 } else {
292 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
293 $this->yypushstate(self::SMARTY);
294 $this->taglineno = $this->line;
295 }
296 }
297 function yy_r1_15($yy_subpatterns)
298 {
300 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
301 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
302 } else {
303 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
304 $this->yypushstate(self::SMARTY);
305 $this->taglineno = $this->line;
306 }
307 }
308 function yy_r1_16($yy_subpatterns)
309 {
311 if ($this->smarty->auto_literal) {
312 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
313 } else {
314 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
315 $this->yypushstate(self::SMARTY);
316 $this->taglineno = $this->line;
317 }
318 }
319 function yy_r1_17($yy_subpatterns)
320 {
322 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
323 $this->yypushstate(self::SMARTY);
324 $this->taglineno = $this->line;
325 }
326 function yy_r1_18($yy_subpatterns)
327 {
329 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
330 $this->yypushstate(self::SMARTY);
331 $this->taglineno = $this->line;
332 }
333 function yy_r1_19($yy_subpatterns)
334 {
336 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
337 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
338 } elseif ($this->value == '<?xml') {
339 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
340 } else {
341 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
342 $this->value = substr($this->value, 0, 2);
343 }
344 }
345 function yy_r1_20($yy_subpatterns)
346 {
348 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
349 }
350 function yy_r1_21($yy_subpatterns)
351 {
353 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
354 }
355 function yy_r1_22($yy_subpatterns)
356 {
358 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
359 }
360 function yy_r1_23($yy_subpatterns)
361 {
363 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
364 }
365 function yy_r1_26($yy_subpatterns)
366 {
368 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
369 }
370 function yy_r1_27($yy_subpatterns)
371 {
373 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
374 }
377 function yylex2()
378 {
379 $tokenMap = array (
380 1 => 0,
381 2 => 0,
382 3 => 1,
383 5 => 0,
384 6 => 0,
385 7 => 0,
386 8 => 0,
387 9 => 0,
388 10 => 0,
389 11 => 0,
390 12 => 0,
391 13 => 0,
392 14 => 0,
393 15 => 0,
394 16 => 0,
395 17 => 0,
396 18 => 0,
397 19 => 0,
398 20 => 1,
399 22 => 1,
400 24 => 1,
401 26 => 0,
402 27 => 0,
403 28 => 0,
404 29 => 0,
405 30 => 0,
406 31 => 0,
407 32 => 0,
408 33 => 0,
409 34 => 0,
410 35 => 0,
411 36 => 0,
412 37 => 0,
413 38 => 0,
414 39 => 0,
415 40 => 0,
416 41 => 0,
417 42 => 0,
418 43 => 3,
419 47 => 0,
420 48 => 0,
421 49 => 0,
422 50 => 0,
423 51 => 0,
424 52 => 0,
425 53 => 0,
426 54 => 0,
427 55 => 1,
428 57 => 1,
429 59 => 0,
430 60 => 0,
431 61 => 0,
432 62 => 0,
433 63 => 0,
434 64 => 0,
435 65 => 0,
436 66 => 0,
437 67 => 0,
438 68 => 0,
439 69 => 0,
440 70 => 0,
441 71 => 0,
442 72 => 0,
443 73 => 0,
444 74 => 0,
445 75 => 0,
446 76 => 0,
447 );
448 if ($this->counter >= strlen($this->data)) {
449 return false; // end of input
450 }
451 $yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|^(".$this->ldel."\\s*for\\s+)|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+as\\s+)|^(\\s+to\\s+)|^(\\s+step\\s+)|^(\\s+instanceof\\s+)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+eq\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(le|lte)\\s+)|^(\\s*>\\s*|\\s+gt\\s+)|^(\\s*<\\s*|\\s+lt\\s+)|^(\\s+mod\\s+)|^(!\\s*|not\\s+)|^(\\s*&&\\s*|\\s*and\\s+)|^(\\s*\\|\\|\\s*|\\s*or\\s+)|^(\\s*xor\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\+\\+|--)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^(0[xX][0-9a-fA-F]+)|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/iS";
453 do {
454 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
455 $yysubmatches = $yymatches;
456 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
457 if (!count($yymatches)) {
458 throw new Exception('Error: lexing failed because a rule matched' .
459 'an empty string. Input "' . substr($this->data,
460 $this->counter, 5) . '... state SMARTY');
461 }
462 next($yymatches); // skip global match
463 $this->token = key($yymatches); // token number
464 if ($tokenMap[$this->token]) {
465 // extract sub-patterns for passing to lex function
466 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
467 $tokenMap[$this->token]);
468 } else {
469 $yysubmatches = array();
470 }
471 $this->value = current($yymatches); // token value
472 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
473 if ($r === null) {
474 $this->counter += strlen($this->value);
475 $this->line += substr_count($this->value, "\n");
476 // accept this token
477 return true;
478 } elseif ($r === true) {
479 // we have changed state
480 // process this token in the new state
481 return $this->yylex();
482 } elseif ($r === false) {
483 $this->counter += strlen($this->value);
484 $this->line += substr_count($this->value, "\n");
485 if ($this->counter >= strlen($this->data)) {
486 return false; // end of input
487 }
488 // skip this token
489 continue;
490 } } else {
491 throw new Exception('Unexpected input at line' . $this->line .
492 ': ' . $this->data[$this->counter]);
493 }
494 break;
495 } while (true);
497 } // end function
500 const SMARTY = 2;
501 function yy_r2_1($yy_subpatterns)
502 {
504 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
505 }
506 function yy_r2_2($yy_subpatterns)
507 {
509 if ($this->smarty->auto_literal) {
510 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
511 } else {
512 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
513 $this->yypushstate(self::SMARTY);
514 $this->taglineno = $this->line;
515 }
516 }
517 function yy_r2_3($yy_subpatterns)
518 {
520 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
521 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
522 } else {
523 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
524 $this->yypushstate(self::SMARTY);
525 $this->taglineno = $this->line;
526 }
527 }
528 function yy_r2_5($yy_subpatterns)
529 {
531 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
532 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
533 } else {
534 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
535 $this->yypushstate(self::SMARTY);
536 $this->taglineno = $this->line;
537 }
538 }
539 function yy_r2_6($yy_subpatterns)
540 {
542 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
543 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
544 } else {
545 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
546 $this->yypushstate(self::SMARTY);
547 $this->taglineno = $this->line;
548 }
549 }
550 function yy_r2_7($yy_subpatterns)
551 {
553 if ($this->smarty->auto_literal) {
554 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
555 } else {
556 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
557 $this->yypushstate(self::SMARTY);
558 $this->taglineno = $this->line;
559 }
560 }
561 function yy_r2_8($yy_subpatterns)
562 {
564 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
565 $this->yypopstate();
566 }
567 function yy_r2_9($yy_subpatterns)
568 {
570 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
571 $this->yypushstate(self::SMARTY);
572 $this->taglineno = $this->line;
573 }
574 function yy_r2_10($yy_subpatterns)
575 {
577 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
578 $this->yypushstate(self::SMARTY);
579 $this->taglineno = $this->line;
580 }
581 function yy_r2_11($yy_subpatterns)
582 {
584 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
585 $this->yypopstate();
586 }
587 function yy_r2_12($yy_subpatterns)
588 {
590 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
591 }
592 function yy_r2_13($yy_subpatterns)
593 {
595 $this->token = Smarty_Internal_Templateparser::TP_AS;
596 }
597 function yy_r2_14($yy_subpatterns)
598 {
600 $this->token = Smarty_Internal_Templateparser::TP_TO;
601 }
602 function yy_r2_15($yy_subpatterns)
603 {
605 $this->token = Smarty_Internal_Templateparser::TP_STEP;
606 }
607 function yy_r2_16($yy_subpatterns)
608 {
610 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
611 }
612 function yy_r2_17($yy_subpatterns)
613 {
615 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
616 }
617 function yy_r2_18($yy_subpatterns)
618 {
620 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
621 }
622 function yy_r2_19($yy_subpatterns)
623 {
625 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
626 }
627 function yy_r2_20($yy_subpatterns)
628 {
630 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
631 }
632 function yy_r2_22($yy_subpatterns)
633 {
635 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
636 }
637 function yy_r2_24($yy_subpatterns)
638 {
640 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
641 }
642 function yy_r2_26($yy_subpatterns)
643 {
645 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
646 }
647 function yy_r2_27($yy_subpatterns)
648 {
650 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
651 }
652 function yy_r2_28($yy_subpatterns)
653 {
655 $this->token = Smarty_Internal_Templateparser::TP_MOD;
656 }
657 function yy_r2_29($yy_subpatterns)
658 {
660 $this->token = Smarty_Internal_Templateparser::TP_NOT;
661 }
662 function yy_r2_30($yy_subpatterns)
663 {
665 $this->token = Smarty_Internal_Templateparser::TP_LAND;
666 }
667 function yy_r2_31($yy_subpatterns)
668 {
670 $this->token = Smarty_Internal_Templateparser::TP_LOR;
671 }
672 function yy_r2_32($yy_subpatterns)
673 {
675 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
676 }
677 function yy_r2_33($yy_subpatterns)
678 {
680 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
681 }
682 function yy_r2_34($yy_subpatterns)
683 {
685 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
686 }
687 function yy_r2_35($yy_subpatterns)
688 {
690 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
691 }
692 function yy_r2_36($yy_subpatterns)
693 {
695 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
696 }
697 function yy_r2_37($yy_subpatterns)
698 {
700 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
701 }
702 function yy_r2_38($yy_subpatterns)
703 {
705 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
706 }
707 function yy_r2_39($yy_subpatterns)
708 {
710 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
711 }
712 function yy_r2_40($yy_subpatterns)
713 {
715 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
716 }
717 function yy_r2_41($yy_subpatterns)
718 {
720 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
721 }
722 function yy_r2_42($yy_subpatterns)
723 {
725 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
726 }
727 function yy_r2_43($yy_subpatterns)
728 {
730 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
731 }
732 function yy_r2_47($yy_subpatterns)
733 {
735 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
736 }
737 function yy_r2_48($yy_subpatterns)
738 {
740 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
741 }
742 function yy_r2_49($yy_subpatterns)
743 {
745 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
746 }
747 function yy_r2_50($yy_subpatterns)
748 {
750 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
751 }
752 function yy_r2_51($yy_subpatterns)
753 {
755 $this->token = Smarty_Internal_Templateparser::TP_PTR;
756 }
757 function yy_r2_52($yy_subpatterns)
758 {
760 $this->token = Smarty_Internal_Templateparser::TP_APTR;
761 }
762 function yy_r2_53($yy_subpatterns)
763 {
765 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
766 }
767 function yy_r2_54($yy_subpatterns)
768 {
770 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
771 }
772 function yy_r2_55($yy_subpatterns)
773 {
775 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
776 }
777 function yy_r2_57($yy_subpatterns)
778 {
780 $this->token = Smarty_Internal_Templateparser::TP_MATH;
781 }
782 function yy_r2_59($yy_subpatterns)
783 {
785 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
786 }
787 function yy_r2_60($yy_subpatterns)
788 {
790 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
791 }
792 function yy_r2_61($yy_subpatterns)
793 {
795 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
796 }
797 function yy_r2_62($yy_subpatterns)
798 {
800 $this->token = Smarty_Internal_Templateparser::TP_COLON;
801 }
802 function yy_r2_63($yy_subpatterns)
803 {
805 $this->token = Smarty_Internal_Templateparser::TP_AT;
806 }
807 function yy_r2_64($yy_subpatterns)
808 {
810 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
811 }
812 function yy_r2_65($yy_subpatterns)
813 {
815 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
816 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
817 }
818 function yy_r2_66($yy_subpatterns)
819 {
821 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
822 $this->yypopstate();
823 }
824 function yy_r2_67($yy_subpatterns)
825 {
827 $this->token = Smarty_Internal_Templateparser::TP_VERT;
828 }
829 function yy_r2_68($yy_subpatterns)
830 {
832 $this->token = Smarty_Internal_Templateparser::TP_DOT;
833 }
834 function yy_r2_69($yy_subpatterns)
835 {
837 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
838 }
839 function yy_r2_70($yy_subpatterns)
840 {
842 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
843 }
844 function yy_r2_71($yy_subpatterns)
845 {
847 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
848 }
849 function yy_r2_72($yy_subpatterns)
850 {
852 $this->token = Smarty_Internal_Templateparser::TP_HEX;
853 }
854 function yy_r2_73($yy_subpatterns)
855 {
857 $this->token = Smarty_Internal_Templateparser::TP_ID;
858 }
859 function yy_r2_74($yy_subpatterns)
860 {
862 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
863 }
864 function yy_r2_75($yy_subpatterns)
865 {
867 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
868 }
869 function yy_r2_76($yy_subpatterns)
870 {
872 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
873 }
877 function yylex3()
878 {
879 $tokenMap = array (
880 1 => 0,
881 2 => 0,
882 3 => 0,
883 4 => 0,
884 5 => 0,
885 6 => 0,
886 7 => 0,
887 8 => 2,
888 11 => 0,
889 );
890 if ($this->counter >= strlen($this->data)) {
891 return false; // end of input
892 }
893 $yy_global_pattern = "/^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^(.)/iS";
895 do {
896 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
897 $yysubmatches = $yymatches;
898 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
899 if (!count($yymatches)) {
900 throw new Exception('Error: lexing failed because a rule matched' .
901 'an empty string. Input "' . substr($this->data,
902 $this->counter, 5) . '... state LITERAL');
903 }
904 next($yymatches); // skip global match
905 $this->token = key($yymatches); // token number
906 if ($tokenMap[$this->token]) {
907 // extract sub-patterns for passing to lex function
908 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
909 $tokenMap[$this->token]);
910 } else {
911 $yysubmatches = array();
912 }
913 $this->value = current($yymatches); // token value
914 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
915 if ($r === null) {
916 $this->counter += strlen($this->value);
917 $this->line += substr_count($this->value, "\n");
918 // accept this token
919 return true;
920 } elseif ($r === true) {
921 // we have changed state
922 // process this token in the new state
923 return $this->yylex();
924 } elseif ($r === false) {
925 $this->counter += strlen($this->value);
926 $this->line += substr_count($this->value, "\n");
927 if ($this->counter >= strlen($this->data)) {
928 return false; // end of input
929 }
930 // skip this token
931 continue;
932 } } else {
933 throw new Exception('Unexpected input at line' . $this->line .
934 ': ' . $this->data[$this->counter]);
935 }
936 break;
937 } while (true);
939 } // end function
942 const LITERAL = 3;
943 function yy_r3_1($yy_subpatterns)
944 {
946 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
947 $this->yypushstate(self::LITERAL);
948 }
949 function yy_r3_2($yy_subpatterns)
950 {
952 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
953 $this->yypopstate();
954 }
955 function yy_r3_3($yy_subpatterns)
956 {
958 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
959 }
960 function yy_r3_4($yy_subpatterns)
961 {
963 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
964 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
965 } else {
966 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
967 $this->value = substr($this->value, 0, 2);
968 }
969 }
970 function yy_r3_5($yy_subpatterns)
971 {
973 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
974 }
975 function yy_r3_6($yy_subpatterns)
976 {
978 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
979 }
980 function yy_r3_7($yy_subpatterns)
981 {
983 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
984 }
985 function yy_r3_8($yy_subpatterns)
986 {
988 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
989 }
990 function yy_r3_11($yy_subpatterns)
991 {
993 $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
994 }
997 function yylex4()
998 {
999 $tokenMap = array (
1000 1 => 0,
1001 2 => 1,
1002 4 => 0,
1003 5 => 0,
1004 6 => 0,
1005 7 => 0,
1006 8 => 0,
1007 9 => 0,
1008 10 => 0,
1009 11 => 0,
1010 12 => 0,
1011 13 => 3,
1012 17 => 0,
1013 18 => 0,
1014 );
1015 if ($this->counter >= strlen($this->data)) {
1016 return false; // end of input
1017 }
1018 $yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|^(".$this->ldel."\\s*for\\s+)|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)|^(.)/iS";
1020 do {
1021 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1022 $yysubmatches = $yymatches;
1023 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1024 if (!count($yymatches)) {
1025 throw new Exception('Error: lexing failed because a rule matched' .
1026 'an empty string. Input "' . substr($this->data,
1027 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1028 }
1029 next($yymatches); // skip global match
1030 $this->token = key($yymatches); // token number
1031 if ($tokenMap[$this->token]) {
1032 // extract sub-patterns for passing to lex function
1033 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1034 $tokenMap[$this->token]);
1035 } else {
1036 $yysubmatches = array();
1037 }
1038 $this->value = current($yymatches); // token value
1039 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1040 if ($r === null) {
1041 $this->counter += strlen($this->value);
1042 $this->line += substr_count($this->value, "\n");
1043 // accept this token
1044 return true;
1045 } elseif ($r === true) {
1046 // we have changed state
1047 // process this token in the new state
1048 return $this->yylex();
1049 } elseif ($r === false) {
1050 $this->counter += strlen($this->value);
1051 $this->line += substr_count($this->value, "\n");
1052 if ($this->counter >= strlen($this->data)) {
1053 return false; // end of input
1054 }
1055 // skip this token
1056 continue;
1057 } } else {
1058 throw new Exception('Unexpected input at line' . $this->line .
1059 ': ' . $this->data[$this->counter]);
1060 }
1061 break;
1062 } while (true);
1064 } // end function
1067 const DOUBLEQUOTEDSTRING = 4;
1068 function yy_r4_1($yy_subpatterns)
1069 {
1071 if ($this->smarty->auto_literal) {
1072 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1073 } else {
1074 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1075 $this->yypushstate(self::SMARTY);
1076 $this->taglineno = $this->line;
1077 }
1078 }
1079 function yy_r4_2($yy_subpatterns)
1080 {
1082 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1083 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1084 } else {
1085 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
1086 $this->yypushstate(self::SMARTY);
1087 $this->taglineno = $this->line;
1088 }
1089 }
1090 function yy_r4_4($yy_subpatterns)
1091 {
1093 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1094 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1095 } else {
1096 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
1097 $this->yypushstate(self::SMARTY);
1098 $this->taglineno = $this->line;
1099 }
1100 }
1101 function yy_r4_5($yy_subpatterns)
1102 {
1104 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1105 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1106 } else {
1107 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
1108 $this->yypushstate(self::SMARTY);
1109 $this->taglineno = $this->line;
1110 }
1111 }
1112 function yy_r4_6($yy_subpatterns)
1113 {
1115 if ($this->smarty->auto_literal) {
1116 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1117 } else {
1118 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1119 $this->yypushstate(self::SMARTY);
1120 $this->taglineno = $this->line;
1121 }
1122 }
1123 function yy_r4_7($yy_subpatterns)
1124 {
1126 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1127 $this->yypushstate(self::SMARTY);
1128 $this->taglineno = $this->line;
1129 }
1130 function yy_r4_8($yy_subpatterns)
1131 {
1133 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1134 $this->yypushstate(self::SMARTY);
1135 $this->taglineno = $this->line;
1136 }
1137 function yy_r4_9($yy_subpatterns)
1138 {
1140 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1141 $this->yypopstate();
1142 }
1143 function yy_r4_10($yy_subpatterns)
1144 {
1146 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1147 $this->value = substr($this->value,0,-1);
1148 $this->yypushstate(self::SMARTY);
1149 $this->taglineno = $this->line;
1150 }
1151 function yy_r4_11($yy_subpatterns)
1152 {
1154 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1155 }
1156 function yy_r4_12($yy_subpatterns)
1157 {
1159 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1160 }
1161 function yy_r4_13($yy_subpatterns)
1162 {
1164 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1165 }
1166 function yy_r4_17($yy_subpatterns)
1167 {
1169 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1170 }
1171 function yy_r4_18($yy_subpatterns)
1172 {
1174 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1175 }
1177 }
1178 ?>