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 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
67 'PHPSTARTTAG' => 'PHP start tag',
68 'PHPENDTAG' => 'PHP end tag',
69 'LITERALSTART' => 'Literal start',
70 'LITERALEND' => 'Literal end',
71 'LDELSLASH' => 'closing tag',
72 'COMMENT' => 'comment',
73 'LITERALEND' => 'literal close',
74 'AS' => 'as',
75 'TO' => 'to',
76 );
79 function __construct($data,$compiler)
80 {
81 // set instance object
82 self::instance($this);
83 // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
84 $this->data = $data;
85 $this->counter = 0;
86 $this->line = 1;
87 $this->smarty = $compiler->smarty;
88 $this->compiler = $compiler;
89 $this->ldel = preg_quote($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 }
94 public static function &instance($new_instance = null)
95 {
96 static $instance = null;
97 if (isset($new_instance) && is_object($new_instance))
98 $instance = $new_instance;
99 return $instance;
100 }
104 private $_yy_state = 1;
105 private $_yy_stack = array();
107 function yylex()
108 {
109 return $this->{'yylex' . $this->_yy_state}();
110 }
112 function yypushstate($state)
113 {
114 array_push($this->_yy_stack, $this->_yy_state);
115 $this->_yy_state = $state;
116 }
118 function yypopstate()
119 {
120 $this->_yy_state = array_pop($this->_yy_stack);
121 }
123 function yybegin($state)
124 {
125 $this->_yy_state = $state;
126 }
130 function yylex1()
131 {
132 $tokenMap = array (
133 1 => 0,
134 2 => 1,
135 4 => 0,
136 5 => 0,
137 6 => 0,
138 7 => 0,
139 8 => 0,
140 9 => 0,
141 10 => 0,
142 11 => 0,
143 12 => 0,
144 13 => 0,
145 14 => 2,
146 17 => 0,
147 );
148 if ($this->counter >= strlen($this->data)) {
149 return false; // end of input
150 }
151 $yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>)))|^([\S\s]+)/";
153 do {
154 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
155 $yysubmatches = $yymatches;
156 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
157 if (!count($yymatches)) {
158 throw new Exception('Error: lexing failed because a rule matched' .
159 'an empty string. Input "' . substr($this->data,
160 $this->counter, 5) . '... state TEXT');
161 }
162 next($yymatches); // skip global match
163 $this->token = key($yymatches); // token number
164 if ($tokenMap[$this->token]) {
165 // extract sub-patterns for passing to lex function
166 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
167 $tokenMap[$this->token]);
168 } else {
169 $yysubmatches = array();
170 }
171 $this->value = current($yymatches); // token value
172 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
173 if ($r === null) {
174 $this->counter += strlen($this->value);
175 $this->line += substr_count($this->value, "\n");
176 // accept this token
177 return true;
178 } elseif ($r === true) {
179 // we have changed state
180 // process this token in the new state
181 return $this->yylex();
182 } elseif ($r === false) {
183 $this->counter += strlen($this->value);
184 $this->line += substr_count($this->value, "\n");
185 if ($this->counter >= strlen($this->data)) {
186 return false; // end of input
187 }
188 // skip this token
189 continue;
190 } } else {
191 throw new Exception('Unexpected input at line' . $this->line .
192 ': ' . $this->data[$this->counter]);
193 }
194 break;
195 } while (true);
197 } // end function
200 const TEXT = 1;
201 function yy_r1_1($yy_subpatterns)
202 {
204 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
205 }
206 function yy_r1_2($yy_subpatterns)
207 {
209 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
210 }
211 function yy_r1_4($yy_subpatterns)
212 {
214 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
215 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
216 } elseif ($this->value == '<?xml') {
217 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
218 } else {
219 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
220 $this->value = substr($this->value, 0, 2);
221 }
222 }
223 function yy_r1_5($yy_subpatterns)
224 {
226 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
227 }
228 function yy_r1_6($yy_subpatterns)
229 {
231 if ($this->strip) {
232 return false;
233 } else {
234 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
235 }
236 }
237 function yy_r1_7($yy_subpatterns)
238 {
240 $this->strip = true;
241 return false;
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 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
253 $this->yypushstate(self::LITERAL);
254 }
255 function yy_r1_10($yy_subpatterns)
256 {
258 if ($this->smarty->auto_literal) {
259 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
260 } else {
261 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
262 $this->yypushstate(self::SMARTY);
263 $this->taglineno = $this->line;
264 }
265 }
266 function yy_r1_11($yy_subpatterns)
267 {
269 if ($this->smarty->auto_literal) {
270 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
271 } else {
272 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
273 $this->yypushstate(self::SMARTY);
274 $this->taglineno = $this->line;
275 }
276 }
277 function yy_r1_12($yy_subpatterns)
278 {
280 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
281 $this->yypushstate(self::SMARTY);
282 $this->taglineno = $this->line;
283 }
284 function yy_r1_13($yy_subpatterns)
285 {
287 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
288 $this->yypushstate(self::SMARTY);
289 $this->taglineno = $this->line;
290 }
291 function yy_r1_14($yy_subpatterns)
292 {
294 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
295 }
296 function yy_r1_17($yy_subpatterns)
297 {
299 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
300 }
303 function yylex2()
304 {
305 $tokenMap = array (
306 1 => 0,
307 2 => 0,
308 3 => 0,
309 4 => 0,
310 5 => 0,
311 6 => 0,
312 7 => 0,
313 8 => 0,
314 9 => 1,
315 11 => 1,
316 13 => 1,
317 15 => 0,
318 16 => 0,
319 17 => 0,
320 18 => 1,
321 20 => 1,
322 22 => 1,
323 24 => 1,
324 26 => 1,
325 28 => 1,
326 30 => 1,
327 32 => 1,
328 34 => 1,
329 36 => 1,
330 38 => 1,
331 40 => 0,
332 41 => 0,
333 42 => 0,
334 43 => 0,
335 44 => 0,
336 45 => 0,
337 46 => 0,
338 47 => 0,
339 48 => 0,
340 49 => 0,
341 50 => 3,
342 54 => 0,
343 55 => 0,
344 56 => 0,
345 57 => 0,
346 58 => 0,
347 59 => 0,
348 60 => 0,
349 61 => 1,
350 63 => 1,
351 65 => 1,
352 67 => 0,
353 68 => 0,
354 69 => 0,
355 70 => 0,
356 71 => 0,
357 72 => 0,
358 73 => 0,
359 74 => 0,
360 75 => 0,
361 76 => 0,
362 77 => 0,
363 78 => 0,
364 79 => 0,
365 80 => 1,
366 82 => 0,
367 83 => 0,
368 84 => 0,
369 85 => 0,
370 86 => 0,
371 87 => 0,
372 );
373 if ($this->counter >= strlen($this->data)) {
374 return false; // end of input
375 }
376 $yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+(to)\\s+)|^(\\s+(step)\\s+)|^(\\s+instanceof\\s+)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|NEQ|ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(GE|GTE|ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(LE|LTE|le|lte)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(\\s+(MOD|mod)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|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*)|^((if|elseif|else if|while)(?![^\s]))|^(foreach(?![^\s]))|^(for(?![^\s]))|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/";
378 do {
379 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
380 $yysubmatches = $yymatches;
381 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
382 if (!count($yymatches)) {
383 throw new Exception('Error: lexing failed because a rule matched' .
384 'an empty string. Input "' . substr($this->data,
385 $this->counter, 5) . '... state SMARTY');
386 }
387 next($yymatches); // skip global match
388 $this->token = key($yymatches); // token number
389 if ($tokenMap[$this->token]) {
390 // extract sub-patterns for passing to lex function
391 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
392 $tokenMap[$this->token]);
393 } else {
394 $yysubmatches = array();
395 }
396 $this->value = current($yymatches); // token value
397 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
398 if ($r === null) {
399 $this->counter += strlen($this->value);
400 $this->line += substr_count($this->value, "\n");
401 // accept this token
402 return true;
403 } elseif ($r === true) {
404 // we have changed state
405 // process this token in the new state
406 return $this->yylex();
407 } elseif ($r === false) {
408 $this->counter += strlen($this->value);
409 $this->line += substr_count($this->value, "\n");
410 if ($this->counter >= strlen($this->data)) {
411 return false; // end of input
412 }
413 // skip this token
414 continue;
415 } } else {
416 throw new Exception('Unexpected input at line' . $this->line .
417 ': ' . $this->data[$this->counter]);
418 }
419 break;
420 } while (true);
422 } // end function
425 const SMARTY = 2;
426 function yy_r2_1($yy_subpatterns)
427 {
429 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
430 }
431 function yy_r2_2($yy_subpatterns)
432 {
434 if ($this->smarty->auto_literal) {
435 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
436 } else {
437 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
438 $this->yypushstate(self::SMARTY);
439 $this->taglineno = $this->line;
440 }
441 }
442 function yy_r2_3($yy_subpatterns)
443 {
445 if ($this->smarty->auto_literal) {
446 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
447 } else {
448 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
449 $this->yypushstate(self::SMARTY);
450 $this->taglineno = $this->line;
451 }
452 }
453 function yy_r2_4($yy_subpatterns)
454 {
456 if ($this->smarty->auto_literal) {
457 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
458 } else {
459 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
460 $this->yypopstate();
461 }
462 }
463 function yy_r2_5($yy_subpatterns)
464 {
466 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
467 $this->yypushstate(self::SMARTY);
468 $this->taglineno = $this->line;
469 }
470 function yy_r2_6($yy_subpatterns)
471 {
473 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
474 $this->yypushstate(self::SMARTY);
475 $this->taglineno = $this->line;
476 }
477 function yy_r2_7($yy_subpatterns)
478 {
480 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
481 $this->yypopstate();
482 }
483 function yy_r2_8($yy_subpatterns)
484 {
486 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
487 }
488 function yy_r2_9($yy_subpatterns)
489 {
491 $this->token = Smarty_Internal_Templateparser::TP_AS;
492 }
493 function yy_r2_11($yy_subpatterns)
494 {
496 $this->token = Smarty_Internal_Templateparser::TP_TO;
497 }
498 function yy_r2_13($yy_subpatterns)
499 {
501 $this->token = Smarty_Internal_Templateparser::TP_STEP;
502 }
503 function yy_r2_15($yy_subpatterns)
504 {
506 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
507 }
508 function yy_r2_16($yy_subpatterns)
509 {
511 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
512 }
513 function yy_r2_17($yy_subpatterns)
514 {
516 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
517 }
518 function yy_r2_18($yy_subpatterns)
519 {
521 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
522 }
523 function yy_r2_20($yy_subpatterns)
524 {
526 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
527 }
528 function yy_r2_22($yy_subpatterns)
529 {
531 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
532 }
533 function yy_r2_24($yy_subpatterns)
534 {
536 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
537 }
538 function yy_r2_26($yy_subpatterns)
539 {
541 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
542 }
543 function yy_r2_28($yy_subpatterns)
544 {
546 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
547 }
548 function yy_r2_30($yy_subpatterns)
549 {
551 $this->token = Smarty_Internal_Templateparser::TP_MOD;
552 }
553 function yy_r2_32($yy_subpatterns)
554 {
556 $this->token = Smarty_Internal_Templateparser::TP_NOT;
557 }
558 function yy_r2_34($yy_subpatterns)
559 {
561 $this->token = Smarty_Internal_Templateparser::TP_LAND;
562 }
563 function yy_r2_36($yy_subpatterns)
564 {
566 $this->token = Smarty_Internal_Templateparser::TP_LOR;
567 }
568 function yy_r2_38($yy_subpatterns)
569 {
571 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
572 }
573 function yy_r2_40($yy_subpatterns)
574 {
576 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
577 }
578 function yy_r2_41($yy_subpatterns)
579 {
581 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
582 }
583 function yy_r2_42($yy_subpatterns)
584 {
586 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
587 }
588 function yy_r2_43($yy_subpatterns)
589 {
591 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
592 }
593 function yy_r2_44($yy_subpatterns)
594 {
596 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
597 }
598 function yy_r2_45($yy_subpatterns)
599 {
601 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
602 }
603 function yy_r2_46($yy_subpatterns)
604 {
606 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
607 }
608 function yy_r2_47($yy_subpatterns)
609 {
611 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
612 }
613 function yy_r2_48($yy_subpatterns)
614 {
616 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
617 }
618 function yy_r2_49($yy_subpatterns)
619 {
621 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
622 }
623 function yy_r2_50($yy_subpatterns)
624 {
626 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
627 }
628 function yy_r2_54($yy_subpatterns)
629 {
631 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
632 }
633 function yy_r2_55($yy_subpatterns)
634 {
636 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
637 }
638 function yy_r2_56($yy_subpatterns)
639 {
641 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
642 }
643 function yy_r2_57($yy_subpatterns)
644 {
646 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
647 }
648 function yy_r2_58($yy_subpatterns)
649 {
651 $this->token = Smarty_Internal_Templateparser::TP_PTR;
652 }
653 function yy_r2_59($yy_subpatterns)
654 {
656 $this->token = Smarty_Internal_Templateparser::TP_APTR;
657 }
658 function yy_r2_60($yy_subpatterns)
659 {
661 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
662 }
663 function yy_r2_61($yy_subpatterns)
664 {
666 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
667 }
668 function yy_r2_63($yy_subpatterns)
669 {
671 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
672 }
673 function yy_r2_65($yy_subpatterns)
674 {
676 $this->token = Smarty_Internal_Templateparser::TP_MATH;
677 }
678 function yy_r2_67($yy_subpatterns)
679 {
681 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
682 }
683 function yy_r2_68($yy_subpatterns)
684 {
686 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
687 }
688 function yy_r2_69($yy_subpatterns)
689 {
691 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
692 }
693 function yy_r2_70($yy_subpatterns)
694 {
696 $this->token = Smarty_Internal_Templateparser::TP_COLON;
697 }
698 function yy_r2_71($yy_subpatterns)
699 {
701 $this->token = Smarty_Internal_Templateparser::TP_AT;
702 }
703 function yy_r2_72($yy_subpatterns)
704 {
706 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
707 }
708 function yy_r2_73($yy_subpatterns)
709 {
711 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
712 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
713 }
714 function yy_r2_74($yy_subpatterns)
715 {
717 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
718 $this->yypopstate();
719 }
720 function yy_r2_75($yy_subpatterns)
721 {
723 $this->token = Smarty_Internal_Templateparser::TP_VERT;
724 }
725 function yy_r2_76($yy_subpatterns)
726 {
728 $this->token = Smarty_Internal_Templateparser::TP_DOT;
729 }
730 function yy_r2_77($yy_subpatterns)
731 {
733 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
734 }
735 function yy_r2_78($yy_subpatterns)
736 {
738 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
739 }
740 function yy_r2_79($yy_subpatterns)
741 {
743 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
744 }
745 function yy_r2_80($yy_subpatterns)
746 {
748 $this->token = Smarty_Internal_Templateparser::TP_IF;
749 }
750 function yy_r2_82($yy_subpatterns)
751 {
753 $this->token = Smarty_Internal_Templateparser::TP_FOREACH;
754 }
755 function yy_r2_83($yy_subpatterns)
756 {
758 $this->token = Smarty_Internal_Templateparser::TP_FOR;
759 }
760 function yy_r2_84($yy_subpatterns)
761 {
763 $this->token = Smarty_Internal_Templateparser::TP_ID;
764 }
765 function yy_r2_85($yy_subpatterns)
766 {
768 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
769 }
770 function yy_r2_86($yy_subpatterns)
771 {
773 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
774 }
775 function yy_r2_87($yy_subpatterns)
776 {
778 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
779 }
783 function yylex3()
784 {
785 $tokenMap = array (
786 1 => 0,
787 2 => 0,
788 3 => 0,
789 4 => 0,
790 5 => 2,
791 8 => 0,
792 );
793 if ($this->counter >= strlen($this->data)) {
794 return false; // end of input
795 }
796 $yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(([\S\s]*?)(?=(".$this->ldel."\/?literal".$this->rdel."|<\\?)))|^([\S\s]+)/";
798 do {
799 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
800 $yysubmatches = $yymatches;
801 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
802 if (!count($yymatches)) {
803 throw new Exception('Error: lexing failed because a rule matched' .
804 'an empty string. Input "' . substr($this->data,
805 $this->counter, 5) . '... state LITERAL');
806 }
807 next($yymatches); // skip global match
808 $this->token = key($yymatches); // token number
809 if ($tokenMap[$this->token]) {
810 // extract sub-patterns for passing to lex function
811 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
812 $tokenMap[$this->token]);
813 } else {
814 $yysubmatches = array();
815 }
816 $this->value = current($yymatches); // token value
817 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
818 if ($r === null) {
819 $this->counter += strlen($this->value);
820 $this->line += substr_count($this->value, "\n");
821 // accept this token
822 return true;
823 } elseif ($r === true) {
824 // we have changed state
825 // process this token in the new state
826 return $this->yylex();
827 } elseif ($r === false) {
828 $this->counter += strlen($this->value);
829 $this->line += substr_count($this->value, "\n");
830 if ($this->counter >= strlen($this->data)) {
831 return false; // end of input
832 }
833 // skip this token
834 continue;
835 } } else {
836 throw new Exception('Unexpected input at line' . $this->line .
837 ': ' . $this->data[$this->counter]);
838 }
839 break;
840 } while (true);
842 } // end function
845 const LITERAL = 3;
846 function yy_r3_1($yy_subpatterns)
847 {
849 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
850 $this->yypushstate(self::LITERAL);
851 }
852 function yy_r3_2($yy_subpatterns)
853 {
855 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
856 $this->yypopstate();
857 }
858 function yy_r3_3($yy_subpatterns)
859 {
861 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
862 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
863 } else {
864 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
865 $this->value = substr($this->value, 0, 2);
866 }
867 }
868 function yy_r3_4($yy_subpatterns)
869 {
871 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
872 }
873 function yy_r3_5($yy_subpatterns)
874 {
876 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
877 }
878 function yy_r3_8($yy_subpatterns)
879 {
881 $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
882 }
885 function yylex4()
886 {
887 $tokenMap = array (
888 1 => 0,
889 2 => 0,
890 3 => 0,
891 4 => 0,
892 5 => 0,
893 6 => 0,
894 7 => 0,
895 8 => 0,
896 9 => 3,
897 13 => 0,
898 );
899 if ($this->counter >= strlen($this->data)) {
900 return false; // end of input
901 }
902 $yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)/";
904 do {
905 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
906 $yysubmatches = $yymatches;
907 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
908 if (!count($yymatches)) {
909 throw new Exception('Error: lexing failed because a rule matched' .
910 'an empty string. Input "' . substr($this->data,
911 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
912 }
913 next($yymatches); // skip global match
914 $this->token = key($yymatches); // token number
915 if ($tokenMap[$this->token]) {
916 // extract sub-patterns for passing to lex function
917 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
918 $tokenMap[$this->token]);
919 } else {
920 $yysubmatches = array();
921 }
922 $this->value = current($yymatches); // token value
923 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
924 if ($r === null) {
925 $this->counter += strlen($this->value);
926 $this->line += substr_count($this->value, "\n");
927 // accept this token
928 return true;
929 } elseif ($r === true) {
930 // we have changed state
931 // process this token in the new state
932 return $this->yylex();
933 } elseif ($r === false) {
934 $this->counter += strlen($this->value);
935 $this->line += substr_count($this->value, "\n");
936 if ($this->counter >= strlen($this->data)) {
937 return false; // end of input
938 }
939 // skip this token
940 continue;
941 } } else {
942 throw new Exception('Unexpected input at line' . $this->line .
943 ': ' . $this->data[$this->counter]);
944 }
945 break;
946 } while (true);
948 } // end function
951 const DOUBLEQUOTEDSTRING = 4;
952 function yy_r4_1($yy_subpatterns)
953 {
955 if ($this->smarty->auto_literal) {
956 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
957 } else {
958 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
959 $this->yypushstate(self::SMARTY);
960 $this->taglineno = $this->line;
961 }
962 }
963 function yy_r4_2($yy_subpatterns)
964 {
966 if ($this->smarty->auto_literal) {
967 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
968 } else {
969 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
970 $this->yypushstate(self::SMARTY);
971 $this->taglineno = $this->line;
972 }
973 }
974 function yy_r4_3($yy_subpatterns)
975 {
977 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
978 $this->yypushstate(self::SMARTY);
979 $this->taglineno = $this->line;
980 }
981 function yy_r4_4($yy_subpatterns)
982 {
984 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
985 $this->yypushstate(self::SMARTY);
986 $this->taglineno = $this->line;
987 }
988 function yy_r4_5($yy_subpatterns)
989 {
991 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
992 $this->yypopstate();
993 }
994 function yy_r4_6($yy_subpatterns)
995 {
997 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
998 $this->value = substr($this->value,0,-1);
999 $this->yypushstate(self::SMARTY);
1000 $this->taglineno = $this->line;
1001 }
1002 function yy_r4_7($yy_subpatterns)
1003 {
1005 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1006 }
1007 function yy_r4_8($yy_subpatterns)
1008 {
1010 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1011 }
1012 function yy_r4_9($yy_subpatterns)
1013 {
1015 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1016 }
1017 function yy_r4_13($yy_subpatterns)
1018 {
1020 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1021 }
1023 }
1024 ?>