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