Code

Updated smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_templatelexer.php
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                                 'NULL' => 'null',
77                                 'BOOLEAN' => 'boolean'
78                                 );
79                                 
80                                 
81     function __construct($data,$compiler)
82     {
83         // set instance object
84         self::instance($this); 
85 //        $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
86         $this->data = $data;
87         $this->counter = 0;
88         $this->line = 1;
89         $this->smarty = $compiler->smarty;
90         $this->compiler = $compiler;
91         $this->ldel = preg_quote($this->smarty->left_delimiter,'/'); 
92         $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
93         $this->smarty_token_names['LDEL'] =     $this->smarty->left_delimiter;
94         $this->smarty_token_names['RDEL'] =     $this->smarty->right_delimiter;
95      }
96     public static function &instance($new_instance = null)
97     {
98         static $instance = null;
99         if (isset($new_instance) && is_object($new_instance))
100             $instance = $new_instance;
101         return $instance;
102     } 
106     private $_yy_state = 1;
107     private $_yy_stack = array();
109     function yylex()
110     {
111         return $this->{'yylex' . $this->_yy_state}();
112     }
114     function yypushstate($state)
115     {
116         array_push($this->_yy_stack, $this->_yy_state);
117         $this->_yy_state = $state;
118     }
120     function yypopstate()
121     {
122         $this->_yy_state = array_pop($this->_yy_stack);
123     }
125     function yybegin($state)
126     {
127         $this->_yy_state = $state;
128     }
132     function yylex1()
133     {
134         $tokenMap = array (
135               1 => 0,
136               2 => 1,
137               4 => 0,
138               5 => 0,
139               6 => 0,
140               7 => 0,
141               8 => 0,
142               9 => 0,
143               10 => 0,
144               11 => 0,
145               12 => 0,
146               13 => 2,
147               16 => 0,
148             );
149         if ($this->counter >= strlen($this->data)) {
150             return false; // end of input
151         }
152         $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]+)/";
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_OTHER;
206     }
207     function yy_r1_2($yy_subpatterns)
208     {
210   $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
211     }
212     function yy_r1_4($yy_subpatterns)
213     {
215   if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
216     $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
217         $this->yypushstate(self::PHP);
218   } elseif ($this->value == '<?xml') {
219       $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
220   } else {
221     $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
222     $this->value = substr($this->value, 0, 2);
223   }
224      }
225     function yy_r1_5($yy_subpatterns)
226     {
228   if ($this->strip) {
229      return false;
230   } else {
231      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
232   }
233     }
234     function yy_r1_6($yy_subpatterns)
235     {
237   $this->strip = true;
238   return false;
239     }
240     function yy_r1_7($yy_subpatterns)
241     {
243   $this->strip = false;
244   return false;
245     }
246     function yy_r1_8($yy_subpatterns)
247     {
249    $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
250    $this->yypushstate(self::LITERAL);
251     }
252     function yy_r1_9($yy_subpatterns)
253     {
255   if ($this->smarty->auto_literal) {
256      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
257   } else {
258      $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
259      $this->yypushstate(self::SMARTY);
260      $this->taglineno = $this->line;
261   }
262     }
263     function yy_r1_10($yy_subpatterns)
264     {
266   if ($this->smarty->auto_literal) {
267      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
268   } else {
269      $this->token = Smarty_Internal_Templateparser::TP_LDEL;
270      $this->yypushstate(self::SMARTY);
271      $this->taglineno = $this->line;
272   }
273     }
274     function yy_r1_11($yy_subpatterns)
275     {
277   $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
278      $this->yypushstate(self::SMARTY);
279      $this->taglineno = $this->line;
280     }
281     function yy_r1_12($yy_subpatterns)
282     {
284   $this->token = Smarty_Internal_Templateparser::TP_LDEL;
285      $this->yypushstate(self::SMARTY);
286      $this->taglineno = $this->line;
287     }
288     function yy_r1_13($yy_subpatterns)
289     {
291   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
292     }
293     function yy_r1_16($yy_subpatterns)
294     {
296   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
297     }
300     function yylex2()
301     {
302         $tokenMap = array (
303               1 => 0,
304               2 => 0,
305               3 => 0,
306               4 => 0,
307               5 => 0,
308               6 => 0,
309               7 => 0,
310               8 => 0,
311               9 => 1,
312               11 => 1,
313               13 => 1,
314               15 => 0,
315               16 => 0,
316               17 => 0,
317               18 => 0,
318               19 => 0,
319               20 => 1,
320               22 => 1,
321               24 => 1,
322               26 => 1,
323               28 => 1,
324               30 => 1,
325               32 => 1,
326               34 => 1,
327               36 => 1,
328               38 => 1,
329               40 => 1,
330               42 => 0,
331               43 => 0,
332               44 => 0,
333               45 => 0,
334               46 => 0,
335               47 => 0,
336               48 => 0,
337               49 => 0,
338               50 => 0,
339               51 => 0,
340               52 => 3,
341               56 => 0,
342               57 => 0,
343               58 => 0,
344               59 => 0,
345               60 => 0,
346               61 => 0,
347               62 => 0,
348               63 => 1,
349               65 => 1,
350               67 => 1,
351               69 => 0,
352               70 => 0,
353               71 => 0,
354               72 => 0,
355               73 => 0,
356               74 => 0,
357               75 => 0,
358               76 => 0,
359               77 => 0,
360               78 => 0,
361               79 => 0,
362               80 => 0,
363               81 => 0,
364               82 => 1,
365               84 => 0,
366               85 => 0,
367               86 => 0,
368               87 => 0,
369               88 => 0,
370               89 => 0,
371             );
372         if ($this->counter >= strlen($this->data)) {
373             return false; // end of input
374         }
375         $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+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\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+)|^(.)/";
377         do {
378             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
379                 $yysubmatches = $yymatches;
380                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
381                 if (!count($yymatches)) {
382                     throw new Exception('Error: lexing failed because a rule matched' .
383                         'an empty string.  Input "' . substr($this->data,
384                         $this->counter, 5) . '... state SMARTY');
385                 }
386                 next($yymatches); // skip global match
387                 $this->token = key($yymatches); // token number
388                 if ($tokenMap[$this->token]) {
389                     // extract sub-patterns for passing to lex function
390                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
391                         $tokenMap[$this->token]);
392                 } else {
393                     $yysubmatches = array();
394                 }
395                 $this->value = current($yymatches); // token value
396                 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
397                 if ($r === null) {
398                     $this->counter += strlen($this->value);
399                     $this->line += substr_count($this->value, "\n");
400                     // accept this token
401                     return true;
402                 } elseif ($r === true) {
403                     // we have changed state
404                     // process this token in the new state
405                     return $this->yylex();
406                 } elseif ($r === false) {
407                     $this->counter += strlen($this->value);
408                     $this->line += substr_count($this->value, "\n");
409                     if ($this->counter >= strlen($this->data)) {
410                         return false; // end of input
411                     }
412                     // skip this token
413                     continue;
414                 }            } else {
415                 throw new Exception('Unexpected input at line' . $this->line .
416                     ': ' . $this->data[$this->counter]);
417             }
418             break;
419         } while (true);
421     } // end function
424     const SMARTY = 2;
425     function yy_r2_1($yy_subpatterns)
426     {
428   $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
429     }
430     function yy_r2_2($yy_subpatterns)
431     {
433   if ($this->smarty->auto_literal) {
434      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
435   } else {
436      $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
437      $this->yypushstate(self::SMARTY);
438      $this->taglineno = $this->line;
439   }
440     }
441     function yy_r2_3($yy_subpatterns)
442     {
444   if ($this->smarty->auto_literal) {
445      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
446   } else {
447      $this->token = Smarty_Internal_Templateparser::TP_LDEL;
448      $this->yypushstate(self::SMARTY);
449      $this->taglineno = $this->line;
450   }
451     }
452     function yy_r2_4($yy_subpatterns)
453     {
455   if ($this->smarty->auto_literal) {
456      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
457   } else {
458      $this->token = Smarty_Internal_Templateparser::TP_RDEL;
459      $this->yypopstate();
460   }
461     }
462     function yy_r2_5($yy_subpatterns)
463     {
465   $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
466      $this->yypushstate(self::SMARTY);
467      $this->taglineno = $this->line;
468     }
469     function yy_r2_6($yy_subpatterns)
470     {
472   $this->token = Smarty_Internal_Templateparser::TP_LDEL;
473      $this->yypushstate(self::SMARTY);
474      $this->taglineno = $this->line;
475     }
476     function yy_r2_7($yy_subpatterns)
477     {
479   $this->token = Smarty_Internal_Templateparser::TP_RDEL;
480      $this->yypopstate();
481     }
482     function yy_r2_8($yy_subpatterns)
483     {
485   $this->token = Smarty_Internal_Templateparser::TP_ISIN;
486     }
487     function yy_r2_9($yy_subpatterns)
488     {
490   $this->token = Smarty_Internal_Templateparser::TP_AS;
491     }
492     function yy_r2_11($yy_subpatterns)
493     {
495   $this->token = Smarty_Internal_Templateparser::TP_TO;
496     }
497     function yy_r2_13($yy_subpatterns)
498     {
500   $this->token = Smarty_Internal_Templateparser::TP_STEP;
501     }
502     function yy_r2_15($yy_subpatterns)
503     {
505   $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
506     }
507     function yy_r2_16($yy_subpatterns)
508     {
510   $this->token = Smarty_Internal_Templateparser::TP_BOOLEAN;
511     }
512     function yy_r2_17($yy_subpatterns)
513     {
515   $this->token = Smarty_Internal_Templateparser::TP_NULL;
516     }
517     function yy_r2_18($yy_subpatterns)
518     {
520   $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
521     }
522     function yy_r2_19($yy_subpatterns)
523     {
525   $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
526     }
527     function yy_r2_20($yy_subpatterns)
528     {
530   $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
531     }
532     function yy_r2_22($yy_subpatterns)
533     {
535   $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
536     }
537     function yy_r2_24($yy_subpatterns)
538     {
540   $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
541     }
542     function yy_r2_26($yy_subpatterns)
543     {
545   $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
546     }
547     function yy_r2_28($yy_subpatterns)
548     {
550   $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
551     }
552     function yy_r2_30($yy_subpatterns)
553     {
555   $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
556     }
557     function yy_r2_32($yy_subpatterns)
558     {
560   $this->token = Smarty_Internal_Templateparser::TP_MOD;
561     }
562     function yy_r2_34($yy_subpatterns)
563     {
565   $this->token = Smarty_Internal_Templateparser::TP_NOT;
566     }
567     function yy_r2_36($yy_subpatterns)
568     {
570   $this->token = Smarty_Internal_Templateparser::TP_LAND;
571     }
572     function yy_r2_38($yy_subpatterns)
573     {
575   $this->token = Smarty_Internal_Templateparser::TP_LOR;
576     }
577     function yy_r2_40($yy_subpatterns)
578     {
580   $this->token = Smarty_Internal_Templateparser::TP_LXOR;
581     }
582     function yy_r2_42($yy_subpatterns)
583     {
585   $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
586     }
587     function yy_r2_43($yy_subpatterns)
588     {
590   $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
591     }
592     function yy_r2_44($yy_subpatterns)
593     {
595   $this->token = Smarty_Internal_Templateparser::TP_ISODD;
596     }
597     function yy_r2_45($yy_subpatterns)
598     {
600   $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
601     }
602     function yy_r2_46($yy_subpatterns)
603     {
605   $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
606     }
607     function yy_r2_47($yy_subpatterns)
608     {
610   $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
611     }
612     function yy_r2_48($yy_subpatterns)
613     {
615   $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
616     }
617     function yy_r2_49($yy_subpatterns)
618     {
620   $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
621     }
622     function yy_r2_50($yy_subpatterns)
623     {
625   $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
626     }
627     function yy_r2_51($yy_subpatterns)
628     {
630   $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
631     }
632     function yy_r2_52($yy_subpatterns)
633     {
635   $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
636     }
637     function yy_r2_56($yy_subpatterns)
638     {
640   $this->token = Smarty_Internal_Templateparser::TP_OPENP;
641     }
642     function yy_r2_57($yy_subpatterns)
643     {
645   $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
646     }
647     function yy_r2_58($yy_subpatterns)
648     {
650   $this->token = Smarty_Internal_Templateparser::TP_OPENB;
651     }
652     function yy_r2_59($yy_subpatterns)
653     {
655   $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
656     }
657     function yy_r2_60($yy_subpatterns)
658     {
660   $this->token = Smarty_Internal_Templateparser::TP_PTR; 
661     }
662     function yy_r2_61($yy_subpatterns)
663     {
665   $this->token = Smarty_Internal_Templateparser::TP_APTR;
666     }
667     function yy_r2_62($yy_subpatterns)
668     {
670   $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
671     }
672     function yy_r2_63($yy_subpatterns)
673     {
675   $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
676     }
677     function yy_r2_65($yy_subpatterns)
678     {
680   $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
681     }
682     function yy_r2_67($yy_subpatterns)
683     {
685   $this->token = Smarty_Internal_Templateparser::TP_MATH;
686     }
687     function yy_r2_69($yy_subpatterns)
688     {
690   $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
691     }
692     function yy_r2_70($yy_subpatterns)
693     {
695   $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
696     }
697     function yy_r2_71($yy_subpatterns)
698     {
700   $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
701     }
702     function yy_r2_72($yy_subpatterns)
703     {
705   $this->token = Smarty_Internal_Templateparser::TP_COLON;
706     }
707     function yy_r2_73($yy_subpatterns)
708     {
710   $this->token = Smarty_Internal_Templateparser::TP_AT;
711     }
712     function yy_r2_74($yy_subpatterns)
713     {
715   $this->token = Smarty_Internal_Templateparser::TP_HATCH;
716     }
717     function yy_r2_75($yy_subpatterns)
718     {
720   $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
721   $this->yypushstate(self::DOUBLEQUOTEDSTRING);
722     }
723     function yy_r2_76($yy_subpatterns)
724     {
726   $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
727   $this->yypopstate();
728     }
729     function yy_r2_77($yy_subpatterns)
730     {
732   $this->token = Smarty_Internal_Templateparser::TP_VERT;
733     }
734     function yy_r2_78($yy_subpatterns)
735     {
737   $this->token = Smarty_Internal_Templateparser::TP_DOT;
738     }
739     function yy_r2_79($yy_subpatterns)
740     {
742   $this->token = Smarty_Internal_Templateparser::TP_COMMA;
743     }
744     function yy_r2_80($yy_subpatterns)
745     {
747   $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
748     }
749     function yy_r2_81($yy_subpatterns)
750     {
752   $this->token = Smarty_Internal_Templateparser::TP_QMARK;
753     }
754     function yy_r2_82($yy_subpatterns)
755     {
757   $this->token = Smarty_Internal_Templateparser::TP_IF;
758     }
759     function yy_r2_84($yy_subpatterns)
760     {
762   $this->token = Smarty_Internal_Templateparser::TP_FOREACH;
763     }
764     function yy_r2_85($yy_subpatterns)
765     {
767   $this->token = Smarty_Internal_Templateparser::TP_FOR;
768     }
769     function yy_r2_86($yy_subpatterns)
770     {
772   $this->token = Smarty_Internal_Templateparser::TP_ID;
773     }
774     function yy_r2_87($yy_subpatterns)
775     {
777   $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
778     }
779     function yy_r2_88($yy_subpatterns)
780     {
782   $this->token = Smarty_Internal_Templateparser::TP_SPACE;
783     }
784     function yy_r2_89($yy_subpatterns)
785     {
787   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
788     }
791     function yylex3()
792     {
793         $tokenMap = array (
794               1 => 0,
795               2 => 1,
796               4 => 0,
797             );
798         if ($this->counter >= strlen($this->data)) {
799             return false; // end of input
800         }
801         $yy_global_pattern = "/^(\\?>)|^([\s\S]+?(\\?>|\/\\*|'|\"|<<<\\s*'?\\w+'?\r?\n|\/\/|#))|^([\S\s]+)/";
803         do {
804             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
805                 $yysubmatches = $yymatches;
806                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
807                 if (!count($yymatches)) {
808                     throw new Exception('Error: lexing failed because a rule matched' .
809                         'an empty string.  Input "' . substr($this->data,
810                         $this->counter, 5) . '... state PHP');
811                 }
812                 next($yymatches); // skip global match
813                 $this->token = key($yymatches); // token number
814                 if ($tokenMap[$this->token]) {
815                     // extract sub-patterns for passing to lex function
816                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
817                         $tokenMap[$this->token]);
818                 } else {
819                     $yysubmatches = array();
820                 }
821                 $this->value = current($yymatches); // token value
822                 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
823                 if ($r === null) {
824                     $this->counter += strlen($this->value);
825                     $this->line += substr_count($this->value, "\n");
826                     // accept this token
827                     return true;
828                 } elseif ($r === true) {
829                     // we have changed state
830                     // process this token in the new state
831                     return $this->yylex();
832                 } elseif ($r === false) {
833                     $this->counter += strlen($this->value);
834                     $this->line += substr_count($this->value, "\n");
835                     if ($this->counter >= strlen($this->data)) {
836                         return false; // end of input
837                     }
838                     // skip this token
839                     continue;
840                 }            } else {
841                 throw new Exception('Unexpected input at line' . $this->line .
842                     ': ' . $this->data[$this->counter]);
843             }
844             break;
845         } while (true);
847     } // end function
850     const PHP = 3;
851     function yy_r3_1($yy_subpatterns)
852     {
854   $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
855   $this->yypopstate();
856     }
857     function yy_r3_2($yy_subpatterns)
858     {
860    switch ($yy_subpatterns[0]) {
861    case '?>':
862       $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
863       $this->value = substr($this->value, 0, -2);
864       break;
865    case "'":
866       $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
867       $this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
868       break;
869    case '"':
870       $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
871       $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
872       break;
873    case '/*':
874       $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
875       $this->yypushstate(self::PHP_ML_COMMENT);
876       break;
877    case '//':
878    case '#':
879       $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
880       $this->yypushstate(self::PHP_SL_COMMENT);
881       break;
882    default:
883       $res = preg_match('/\A<<<\s*\'?(\w+)(\'?)\r?\n\z/', $yy_subpatterns[0], $matches);
884       assert($res === 1);
885       $is_nowdoc = $matches[2] === "'";
886       $this->token = $is_nowdoc
887         ? Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START
888         : Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
889       $this->heredoc_id_stack[] = $matches[1];
890       $this->yypushstate($is_nowdoc ? self::PHP_NOWDOC : self::PHP_HEREDOC);
891       break;
892    }
893     }
894     function yy_r3_4($yy_subpatterns)
895     {
897   $this->compiler->trigger_template_error ("missing PHP end tag");
898     }
901     function yylex4()
902     {
903         $tokenMap = array (
904               1 => 0,
905               2 => 0,
906             );
907         if ($this->counter >= strlen($this->data)) {
908             return false; // end of input
909         }
910         $yy_global_pattern = "/^([\s\S]*\\*\/)|^([\S\s]+)/";
912         do {
913             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
914                 $yysubmatches = $yymatches;
915                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
916                 if (!count($yymatches)) {
917                     throw new Exception('Error: lexing failed because a rule matched' .
918                         'an empty string.  Input "' . substr($this->data,
919                         $this->counter, 5) . '... state PHP_ML_COMMENT');
920                 }
921                 next($yymatches); // skip global match
922                 $this->token = key($yymatches); // token number
923                 if ($tokenMap[$this->token]) {
924                     // extract sub-patterns for passing to lex function
925                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
926                         $tokenMap[$this->token]);
927                 } else {
928                     $yysubmatches = array();
929                 }
930                 $this->value = current($yymatches); // token value
931                 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
932                 if ($r === null) {
933                     $this->counter += strlen($this->value);
934                     $this->line += substr_count($this->value, "\n");
935                     // accept this token
936                     return true;
937                 } elseif ($r === true) {
938                     // we have changed state
939                     // process this token in the new state
940                     return $this->yylex();
941                 } elseif ($r === false) {
942                     $this->counter += strlen($this->value);
943                     $this->line += substr_count($this->value, "\n");
944                     if ($this->counter >= strlen($this->data)) {
945                         return false; // end of input
946                     }
947                     // skip this token
948                     continue;
949                 }            } else {
950                 throw new Exception('Unexpected input at line' . $this->line .
951                     ': ' . $this->data[$this->counter]);
952             }
953             break;
954         } while (true);
956     } // end function
959     const PHP_ML_COMMENT = 4;
960     function yy_r4_1($yy_subpatterns)
961     {
963   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;  
964   $this->yypopstate();
965     }
966     function yy_r4_2($yy_subpatterns)
967     {
969   $this->compiler->trigger_template_error("missing PHP comment end */");
970     }
973     function yylex5()
974     {
975         $tokenMap = array (
976               1 => 0,
977               2 => 0,
978             );
979         if ($this->counter >= strlen($this->data)) {
980             return false; // end of input
981         }
982         $yy_global_pattern = "/^(.+?(?=\\?>|\n))|^([\S\s]+)/";
984         do {
985             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
986                 $yysubmatches = $yymatches;
987                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
988                 if (!count($yymatches)) {
989                     throw new Exception('Error: lexing failed because a rule matched' .
990                         'an empty string.  Input "' . substr($this->data,
991                         $this->counter, 5) . '... state PHP_SL_COMMENT');
992                 }
993                 next($yymatches); // skip global match
994                 $this->token = key($yymatches); // token number
995                 if ($tokenMap[$this->token]) {
996                     // extract sub-patterns for passing to lex function
997                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
998                         $tokenMap[$this->token]);
999                 } else {
1000                     $yysubmatches = array();
1001                 }
1002                 $this->value = current($yymatches); // token value
1003                 $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
1004                 if ($r === null) {
1005                     $this->counter += strlen($this->value);
1006                     $this->line += substr_count($this->value, "\n");
1007                     // accept this token
1008                     return true;
1009                 } elseif ($r === true) {
1010                     // we have changed state
1011                     // process this token in the new state
1012                     return $this->yylex();
1013                 } elseif ($r === false) {
1014                     $this->counter += strlen($this->value);
1015                     $this->line += substr_count($this->value, "\n");
1016                     if ($this->counter >= strlen($this->data)) {
1017                         return false; // end of input
1018                     }
1019                     // skip this token
1020                     continue;
1021                 }            } else {
1022                 throw new Exception('Unexpected input at line' . $this->line .
1023                     ': ' . $this->data[$this->counter]);
1024             }
1025             break;
1026         } while (true);
1028     } // end function
1031     const PHP_SL_COMMENT = 5;
1032     function yy_r5_1($yy_subpatterns)
1033     {
1035   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;  
1036   $this->yypopstate();
1037     }
1038     function yy_r5_2($yy_subpatterns)
1039     {
1041   /* this can happen for "//?>" */
1042   $this->yypopstate();
1043   return true;
1044     }
1047     function yylex6()
1048     {
1049         $tokenMap = array (
1050               1 => 0,
1051               2 => 0,
1052             );
1053         if ($this->counter >= strlen($this->data)) {
1054             return false; // end of input
1055         }
1056         $yy_global_pattern = "/^([^\n]*\n)|^([\S\s]+)/";
1058         do {
1059             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1060                 $yysubmatches = $yymatches;
1061                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1062                 if (!count($yymatches)) {
1063                     throw new Exception('Error: lexing failed because a rule matched' .
1064                         'an empty string.  Input "' . substr($this->data,
1065                         $this->counter, 5) . '... state PHP_NOWDOC');
1066                 }
1067                 next($yymatches); // skip global match
1068                 $this->token = key($yymatches); // token number
1069                 if ($tokenMap[$this->token]) {
1070                     // extract sub-patterns for passing to lex function
1071                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1072                         $tokenMap[$this->token]);
1073                 } else {
1074                     $yysubmatches = array();
1075                 }
1076                 $this->value = current($yymatches); // token value
1077                 $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
1078                 if ($r === null) {
1079                     $this->counter += strlen($this->value);
1080                     $this->line += substr_count($this->value, "\n");
1081                     // accept this token
1082                     return true;
1083                 } elseif ($r === true) {
1084                     // we have changed state
1085                     // process this token in the new state
1086                     return $this->yylex();
1087                 } elseif ($r === false) {
1088                     $this->counter += strlen($this->value);
1089                     $this->line += substr_count($this->value, "\n");
1090                     if ($this->counter >= strlen($this->data)) {
1091                         return false; // end of input
1092                     }
1093                     // skip this token
1094                     continue;
1095                 }            } else {
1096                 throw new Exception('Unexpected input at line' . $this->line .
1097                     ': ' . $this->data[$this->counter]);
1098             }
1099             break;
1100         } while (true);
1102     } // end function
1105     const PHP_NOWDOC = 6;
1106     function yy_r6_1($yy_subpatterns)
1107     {
1109   $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
1110   if (   $this->value === $heredoc_id."\n"
1111       || $this->value === $heredoc_id."\r\n"
1112       || $this->value === $heredoc_id.";\n"
1113       || $this->value === $heredoc_id.";\r\n"
1114      ) {
1115     $this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_END;
1116     array_pop($this->heredoc_id_stack);
1117     $this->yypopstate();
1118   } else {
1119     $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
1120   }
1121     }
1122     function yy_r6_2($yy_subpatterns)
1123     {
1125   $this->compiler->trigger_template_error("missing PHP NOWDOC end");
1126     }
1129     function yylex7()
1130     {
1131         $tokenMap = array (
1132               1 => 0,
1133               2 => 0,
1134               3 => 0,
1135             );
1136         if ($this->counter >= strlen($this->data)) {
1137             return false; // end of input
1138         }
1139         $yy_global_pattern = "/^(\\{\\$|\\{\\$)|^([^\n]*\n)|^([\S\s]+)/";
1141         do {
1142             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1143                 $yysubmatches = $yymatches;
1144                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1145                 if (!count($yymatches)) {
1146                     throw new Exception('Error: lexing failed because a rule matched' .
1147                         'an empty string.  Input "' . substr($this->data,
1148                         $this->counter, 5) . '... state PHP_HEREDOC');
1149                 }
1150                 next($yymatches); // skip global match
1151                 $this->token = key($yymatches); // token number
1152                 if ($tokenMap[$this->token]) {
1153                     // extract sub-patterns for passing to lex function
1154                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1155                         $tokenMap[$this->token]);
1156                 } else {
1157                     $yysubmatches = array();
1158                 }
1159                 $this->value = current($yymatches); // token value
1160                 $r = $this->{'yy_r7_' . $this->token}($yysubmatches);
1161                 if ($r === null) {
1162                     $this->counter += strlen($this->value);
1163                     $this->line += substr_count($this->value, "\n");
1164                     // accept this token
1165                     return true;
1166                 } elseif ($r === true) {
1167                     // we have changed state
1168                     // process this token in the new state
1169                     return $this->yylex();
1170                 } elseif ($r === false) {
1171                     $this->counter += strlen($this->value);
1172                     $this->line += substr_count($this->value, "\n");
1173                     if ($this->counter >= strlen($this->data)) {
1174                         return false; // end of input
1175                     }
1176                     // skip this token
1177                     continue;
1178                 }            } else {
1179                 throw new Exception('Unexpected input at line' . $this->line .
1180                     ': ' . $this->data[$this->counter]);
1181             }
1182             break;
1183         } while (true);
1185     } // end function
1188     const PHP_HEREDOC = 7;
1189     function yy_r7_1($yy_subpatterns)
1190     {
1192   $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
1193   $this->yypushstate(self::PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED);    
1194   $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);    
1195     }
1196     function yy_r7_2($yy_subpatterns)
1197     {
1199   $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
1200   if (   $this->value === $heredoc_id."\n"
1201       || $this->value === $heredoc_id."\r\n"
1202       || $this->value === $heredoc_id.";\n"
1203       || $this->value === $heredoc_id.";\r\n"
1204      ) {
1205     $this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_END;
1206     array_pop($this->heredoc_id_stack);
1207     $this->yypopstate();
1208   } else {
1209     $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
1210     if (preg_match('/(.*?)(\{\$\|\$\{)/', $this->value, $matches)) {
1211       $this->value = $matches[1];
1212     }
1213   }
1214     }
1215     function yy_r7_3($yy_subpatterns)
1216     {
1218   $this->compiler->trigger_template_error("missing PHP HEREDOC end");
1219     }
1222     function yylex8()
1223     {
1224         $tokenMap = array (
1225               1 => 0,
1226             );
1227         if ($this->counter >= strlen($this->data)) {
1228             return false; // end of input
1229         }
1230         $yy_global_pattern = "/^([^\n]*\n)/";
1232         do {
1233             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1234                 $yysubmatches = $yymatches;
1235                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1236                 if (!count($yymatches)) {
1237                     throw new Exception('Error: lexing failed because a rule matched' .
1238                         'an empty string.  Input "' . substr($this->data,
1239                         $this->counter, 5) . '... state PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED');
1240                 }
1241                 next($yymatches); // skip global match
1242                 $this->token = key($yymatches); // token number
1243                 if ($tokenMap[$this->token]) {
1244                     // extract sub-patterns for passing to lex function
1245                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1246                         $tokenMap[$this->token]);
1247                 } else {
1248                     $yysubmatches = array();
1249                 }
1250                 $this->value = current($yymatches); // token value
1251                 $r = $this->{'yy_r8_' . $this->token}($yysubmatches);
1252                 if ($r === null) {
1253                     $this->counter += strlen($this->value);
1254                     $this->line += substr_count($this->value, "\n");
1255                     // accept this token
1256                     return true;
1257                 } elseif ($r === true) {
1258                     // we have changed state
1259                     // process this token in the new state
1260                     return $this->yylex();
1261                 } elseif ($r === false) {
1262                     $this->counter += strlen($this->value);
1263                     $this->line += substr_count($this->value, "\n");
1264                     if ($this->counter >= strlen($this->data)) {
1265                         return false; // end of input
1266                     }
1267                     // skip this token
1268                     continue;
1269                 }            } else {
1270                 throw new Exception('Unexpected input at line' . $this->line .
1271                     ': ' . $this->data[$this->counter]);
1272             }
1273             break;
1274         } while (true);
1276     } // end function
1279     const PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED = 8;
1280     function yy_r8_1($yy_subpatterns)
1281     {
1283   $this->yypopstate();
1284   $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
1285   if (   $this->value === $heredoc_id."\n"
1286       || $this->value === $heredoc_id."\r\n"
1287       || $this->value === $heredoc_id.";\n"
1288       || $this->value === $heredoc_id.";\r\n"
1289      ) {
1290     //Make sure it isn't interpreted as HEREDOC end.
1291     $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
1292   } else {
1293     return true; //retry in PHP_HEREDOC state
1294   }
1295     }
1298     function yylex9()
1299     {
1300         $tokenMap = array (
1301               1 => 0,
1302               2 => 0,
1303             );
1304         if ($this->counter >= strlen($this->data)) {
1305             return false; // end of input
1306         }
1307         $yy_global_pattern = "/^((?:[^\\\\']|\\\\.)*')|^([\S\s]+)/";
1309         do {
1310             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1311                 $yysubmatches = $yymatches;
1312                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1313                 if (!count($yymatches)) {
1314                     throw new Exception('Error: lexing failed because a rule matched' .
1315                         'an empty string.  Input "' . substr($this->data,
1316                         $this->counter, 5) . '... state PHP_SINGLE_QUOTED_STRING');
1317                 }
1318                 next($yymatches); // skip global match
1319                 $this->token = key($yymatches); // token number
1320                 if ($tokenMap[$this->token]) {
1321                     // extract sub-patterns for passing to lex function
1322                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1323                         $tokenMap[$this->token]);
1324                 } else {
1325                     $yysubmatches = array();
1326                 }
1327                 $this->value = current($yymatches); // token value
1328                 $r = $this->{'yy_r9_' . $this->token}($yysubmatches);
1329                 if ($r === null) {
1330                     $this->counter += strlen($this->value);
1331                     $this->line += substr_count($this->value, "\n");
1332                     // accept this token
1333                     return true;
1334                 } elseif ($r === true) {
1335                     // we have changed state
1336                     // process this token in the new state
1337                     return $this->yylex();
1338                 } elseif ($r === false) {
1339                     $this->counter += strlen($this->value);
1340                     $this->line += substr_count($this->value, "\n");
1341                     if ($this->counter >= strlen($this->data)) {
1342                         return false; // end of input
1343                     }
1344                     // skip this token
1345                     continue;
1346                 }            } else {
1347                 throw new Exception('Unexpected input at line' . $this->line .
1348                     ': ' . $this->data[$this->counter]);
1349             }
1350             break;
1351         } while (true);
1353     } // end function
1356     const PHP_SINGLE_QUOTED_STRING = 9;
1357     function yy_r9_1($yy_subpatterns)
1358     {
1360   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;  
1361   $this->yypopstate();
1362     }
1363     function yy_r9_2($yy_subpatterns)
1364     {
1366   $this->compiler->trigger_template_error("missing PHP single quoted string end");
1367     }
1370     function yylex10()
1371     {
1372         $tokenMap = array (
1373               1 => 0,
1374               2 => 0,
1375               3 => 0,
1376               4 => 0,
1377             );
1378         if ($this->counter >= strlen($this->data)) {
1379             return false; // end of input
1380         }
1381         $yy_global_pattern = "/^(\\{\\$|\\{\\$)|^(\")|^((?:\\\\.|[^\"\\\\])+?(?=\"|\\{\\$|\\$\\{))|^([\S\s]+)/";
1383         do {
1384             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1385                 $yysubmatches = $yymatches;
1386                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1387                 if (!count($yymatches)) {
1388                     throw new Exception('Error: lexing failed because a rule matched' .
1389                         'an empty string.  Input "' . substr($this->data,
1390                         $this->counter, 5) . '... state PHP_DOUBLE_QUOTED_STRING');
1391                 }
1392                 next($yymatches); // skip global match
1393                 $this->token = key($yymatches); // token number
1394                 if ($tokenMap[$this->token]) {
1395                     // extract sub-patterns for passing to lex function
1396                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1397                         $tokenMap[$this->token]);
1398                 } else {
1399                     $yysubmatches = array();
1400                 }
1401                 $this->value = current($yymatches); // token value
1402                 $r = $this->{'yy_r10_' . $this->token}($yysubmatches);
1403                 if ($r === null) {
1404                     $this->counter += strlen($this->value);
1405                     $this->line += substr_count($this->value, "\n");
1406                     // accept this token
1407                     return true;
1408                 } elseif ($r === true) {
1409                     // we have changed state
1410                     // process this token in the new state
1411                     return $this->yylex();
1412                 } elseif ($r === false) {
1413                     $this->counter += strlen($this->value);
1414                     $this->line += substr_count($this->value, "\n");
1415                     if ($this->counter >= strlen($this->data)) {
1416                         return false; // end of input
1417                     }
1418                     // skip this token
1419                     continue;
1420                 }            } else {
1421                 throw new Exception('Unexpected input at line' . $this->line .
1422                     ': ' . $this->data[$this->counter]);
1423             }
1424             break;
1425         } while (true);
1427     } // end function
1430     const PHP_DOUBLE_QUOTED_STRING = 10;
1431     function yy_r10_1($yy_subpatterns)
1432     {
1434   $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
1435   $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);
1436     }
1437     function yy_r10_2($yy_subpatterns)
1438     {
1440   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_DOUBLEQUOTE;
1441   $this->yypopstate();
1442     }
1443     function yy_r10_3($yy_subpatterns)
1444     {
1446   $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
1447     }
1448     function yy_r10_4($yy_subpatterns)
1449     {
1451   $this->compiler->trigger_template_error("missing PHP double quoted string end");
1452     }
1455     function yylex11()
1456     {
1457         $tokenMap = array (
1458               1 => 0,
1459               2 => 0,
1460               3 => 0,
1461               4 => 0,
1462               5 => 0,
1463               6 => 0,
1464             );
1465         if ($this->counter >= strlen($this->data)) {
1466             return false; // end of input
1467         }
1468         $yy_global_pattern = "/^(\")|^(')|^(<<<\\s*\\w+\r?\n)|^(<<<\\s*'\\w+'\r?\n)|^(\\})|^([^'\"}]+?(?='|\"|\\}|<<<\\s*'?\\w+'?\r?\n))/";
1470         do {
1471             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1472                 $yysubmatches = $yymatches;
1473                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1474                 if (!count($yymatches)) {
1475                     throw new Exception('Error: lexing failed because a rule matched' .
1476                         'an empty string.  Input "' . substr($this->data,
1477                         $this->counter, 5) . '... state PHP_DOUBLE_QUOTED_STRING_EMBEDDED');
1478                 }
1479                 next($yymatches); // skip global match
1480                 $this->token = key($yymatches); // token number
1481                 if ($tokenMap[$this->token]) {
1482                     // extract sub-patterns for passing to lex function
1483                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1484                         $tokenMap[$this->token]);
1485                 } else {
1486                     $yysubmatches = array();
1487                 }
1488                 $this->value = current($yymatches); // token value
1489                 $r = $this->{'yy_r11_' . $this->token}($yysubmatches);
1490                 if ($r === null) {
1491                     $this->counter += strlen($this->value);
1492                     $this->line += substr_count($this->value, "\n");
1493                     // accept this token
1494                     return true;
1495                 } elseif ($r === true) {
1496                     // we have changed state
1497                     // process this token in the new state
1498                     return $this->yylex();
1499                 } elseif ($r === false) {
1500                     $this->counter += strlen($this->value);
1501                     $this->line += substr_count($this->value, "\n");
1502                     if ($this->counter >= strlen($this->data)) {
1503                         return false; // end of input
1504                     }
1505                     // skip this token
1506                     continue;
1507                 }            } else {
1508                 throw new Exception('Unexpected input at line' . $this->line .
1509                     ': ' . $this->data[$this->counter]);
1510             }
1511             break;
1512         } while (true);
1514     } // end function
1517     const PHP_DOUBLE_QUOTED_STRING_EMBEDDED = 11;
1518     function yy_r11_1($yy_subpatterns)
1519     {
1521   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
1522   $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
1523     }
1524     function yy_r11_2($yy_subpatterns)
1525     {
1527   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
1528   $this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
1529     }
1530     function yy_r11_3($yy_subpatterns)
1531     {
1533   $this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
1534   $res = preg_match('/\A\<\<\<\s*(\w+)\r?\n\z/', $this->value, $matches);
1535   assert($res === 1);
1536   $this->heredoc_id_stack[] = $matches[1];
1537   $this->yypushstate(self::PHP_HEREDOC);
1538     }
1539     function yy_r11_4($yy_subpatterns)
1540     {
1542   $this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START;
1543   $res = preg_match('/\A\<\<\<\s*\'(\w+)\'\r?\n\z/', $this->value, $matches);
1544   assert($res === 1);
1545   $this->heredoc_id_stack[] = $matches[1];
1546   $this->yypushstate(self::PHP_NOWDOC);
1547     }
1548     function yy_r11_5($yy_subpatterns)
1549     {
1551   $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_END;
1552   $this->yypopstate();
1553     }
1554     function yy_r11_6($yy_subpatterns)
1555     {
1557   $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
1558     }
1562     function yylex12()
1563     {
1564         $tokenMap = array (
1565               1 => 0,
1566               2 => 0,
1567               3 => 0,
1568               4 => 0,
1569               5 => 2,
1570               8 => 0,
1571             );
1572         if ($this->counter >= strlen($this->data)) {
1573             return false; // end of input
1574         }
1575         $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]+)/";
1577         do {
1578             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1579                 $yysubmatches = $yymatches;
1580                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1581                 if (!count($yymatches)) {
1582                     throw new Exception('Error: lexing failed because a rule matched' .
1583                         'an empty string.  Input "' . substr($this->data,
1584                         $this->counter, 5) . '... state LITERAL');
1585                 }
1586                 next($yymatches); // skip global match
1587                 $this->token = key($yymatches); // token number
1588                 if ($tokenMap[$this->token]) {
1589                     // extract sub-patterns for passing to lex function
1590                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1591                         $tokenMap[$this->token]);
1592                 } else {
1593                     $yysubmatches = array();
1594                 }
1595                 $this->value = current($yymatches); // token value
1596                 $r = $this->{'yy_r12_' . $this->token}($yysubmatches);
1597                 if ($r === null) {
1598                     $this->counter += strlen($this->value);
1599                     $this->line += substr_count($this->value, "\n");
1600                     // accept this token
1601                     return true;
1602                 } elseif ($r === true) {
1603                     // we have changed state
1604                     // process this token in the new state
1605                     return $this->yylex();
1606                 } elseif ($r === false) {
1607                     $this->counter += strlen($this->value);
1608                     $this->line += substr_count($this->value, "\n");
1609                     if ($this->counter >= strlen($this->data)) {
1610                         return false; // end of input
1611                     }
1612                     // skip this token
1613                     continue;
1614                 }            } else {
1615                 throw new Exception('Unexpected input at line' . $this->line .
1616                     ': ' . $this->data[$this->counter]);
1617             }
1618             break;
1619         } while (true);
1621     } // end function
1624     const LITERAL = 12;
1625     function yy_r12_1($yy_subpatterns)
1626     {
1628   $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
1629   $this->yypushstate(self::LITERAL);
1630     }
1631     function yy_r12_2($yy_subpatterns)
1632     {
1634   $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
1635   $this->yypopstate();
1636     }
1637     function yy_r12_3($yy_subpatterns)
1638     {
1640   if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
1641     $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
1642    } else {
1643     $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
1644     $this->value = substr($this->value, 0, 2);
1645    }
1646     }
1647     function yy_r12_4($yy_subpatterns)
1648     {
1650   $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
1651     }
1652     function yy_r12_5($yy_subpatterns)
1653     {
1655   $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
1656     }
1657     function yy_r12_8($yy_subpatterns)
1658     {
1660   $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
1661     }
1664     function yylex13()
1665     {
1666         $tokenMap = array (
1667               1 => 0,
1668               2 => 0,
1669               3 => 0,
1670               4 => 0,
1671               5 => 0,
1672               6 => 0,
1673               7 => 0,
1674               8 => 0,
1675               9 => 3,
1676               13 => 0,
1677             );
1678         if ($this->counter >= strlen($this->data)) {
1679             return false; // end of input
1680         }
1681         $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]+)/";
1683         do {
1684             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1685                 $yysubmatches = $yymatches;
1686                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1687                 if (!count($yymatches)) {
1688                     throw new Exception('Error: lexing failed because a rule matched' .
1689                         'an empty string.  Input "' . substr($this->data,
1690                         $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1691                 }
1692                 next($yymatches); // skip global match
1693                 $this->token = key($yymatches); // token number
1694                 if ($tokenMap[$this->token]) {
1695                     // extract sub-patterns for passing to lex function
1696                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1697                         $tokenMap[$this->token]);
1698                 } else {
1699                     $yysubmatches = array();
1700                 }
1701                 $this->value = current($yymatches); // token value
1702                 $r = $this->{'yy_r13_' . $this->token}($yysubmatches);
1703                 if ($r === null) {
1704                     $this->counter += strlen($this->value);
1705                     $this->line += substr_count($this->value, "\n");
1706                     // accept this token
1707                     return true;
1708                 } elseif ($r === true) {
1709                     // we have changed state
1710                     // process this token in the new state
1711                     return $this->yylex();
1712                 } elseif ($r === false) {
1713                     $this->counter += strlen($this->value);
1714                     $this->line += substr_count($this->value, "\n");
1715                     if ($this->counter >= strlen($this->data)) {
1716                         return false; // end of input
1717                     }
1718                     // skip this token
1719                     continue;
1720                 }            } else {
1721                 throw new Exception('Unexpected input at line' . $this->line .
1722                     ': ' . $this->data[$this->counter]);
1723             }
1724             break;
1725         } while (true);
1727     } // end function
1730     const DOUBLEQUOTEDSTRING = 13;
1731     function yy_r13_1($yy_subpatterns)
1732     {
1734   if ($this->smarty->auto_literal) {
1735      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1736   } else {
1737      $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1738      $this->yypushstate(self::SMARTY);
1739      $this->taglineno = $this->line;
1740   }
1741     }
1742     function yy_r13_2($yy_subpatterns)
1743     {
1745   if ($this->smarty->auto_literal) {
1746      $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1747   } else {
1748      $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1749      $this->yypushstate(self::SMARTY);
1750      $this->taglineno = $this->line;
1751   }
1752     }
1753     function yy_r13_3($yy_subpatterns)
1754     {
1756   $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1757      $this->yypushstate(self::SMARTY);
1758      $this->taglineno = $this->line;
1759     }
1760     function yy_r13_4($yy_subpatterns)
1761     {
1763   $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1764      $this->yypushstate(self::SMARTY);
1765      $this->taglineno = $this->line;
1766     }
1767     function yy_r13_5($yy_subpatterns)
1768     {
1770   $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1771   $this->yypopstate();
1772     }
1773     function yy_r13_6($yy_subpatterns)
1774     {
1776   $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1777   $this->value = substr($this->value,0,-1);
1778   $this->yypushstate(self::SMARTY);
1779   $this->taglineno = $this->line;
1780     }
1781     function yy_r13_7($yy_subpatterns)
1782     {
1784   $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1785     }
1786     function yy_r13_8($yy_subpatterns)
1787     {
1789   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1790     }
1791     function yy_r13_9($yy_subpatterns)
1792     {
1794   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1795     }
1796     function yy_r13_13($yy_subpatterns)
1797     {
1799   $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1800     }
1803 ?>