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