1<?php
2/*
3 * This file is part of Smarty.
4 *
5 * (c) 2015 Uwe Tews
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11/**
12 * Smarty_Internal_Templatelexer
13 * This is the template file lexer.
14 * It is generated from the smarty_internal_templatelexer.plex file
15 *
16 *
17 * @author Uwe Tews <uwe.tews@googlemail.com>
18 */
19class Smarty_Internal_Templatelexer
20{
21    /**
22     * Source
23     *
24     * @var string
25     */
26    public $data;
27
28    /**
29     * byte counter
30     *
31     * @var int
32     */
33    public $counter;
34
35    /**
36     * token number
37     *
38     * @var int
39     */
40    public $token;
41
42    /**
43     * token value
44     *
45     * @var string
46     */
47    public $value;
48
49    /**
50     * current line
51     *
52     * @var int
53     */
54    public $line;
55
56    /**
57     * tag start line
58     *
59     * @var
60     */
61    public $taglineno;
62
63    /**
64     * php code type
65     *
66     * @var string
67     */
68    public $phpType = '';
69
70    /**
71     * escaped left delimiter
72     *
73     * @var string
74     */
75    public $ldel = '';
76
77    /**
78     * escaped left delimiter length
79     *
80     * @var int
81     */
82    public $ldel_length = 0;
83
84    /**
85     * escaped right delimiter
86     *
87     * @var string
88     */
89    public $rdel = '';
90
91    /**
92     * escaped right delimiter length
93     *
94     * @var int
95     */
96    public $rdel_length = 0;
97
98    /**
99     * state number
100     *
101     * @var int
102     */
103    public $state = 1;
104
105    /**
106     * Smarty object
107     *
108     * @var Smarty
109     */
110    public $smarty = null;
111
112    /**
113     * compiler object
114     *
115     * @var Smarty_Internal_TemplateCompilerBase
116     */
117    public $compiler = null;
118
119    /**
120     * literal tag nesting level
121     *
122     * @var int
123     */
124    private $literal_cnt = 0;
125
126    /**
127     * PHP start tag string
128     *
129     * @var string
130     */
131
132    /**
133     * trace file
134     *
135     * @var resource
136     */
137    public $yyTraceFILE;
138
139    /**
140     * trace prompt
141     *
142     * @var string
143     */
144    public $yyTracePrompt;
145
146    /**
147     * XML flag true while processing xml
148     *
149     * @var bool
150     */
151    public $is_xml = false;
152
153    /**
154     * state names
155     *
156     * @var array
157     */
158    public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
159
160    /**
161     * storage for assembled token patterns
162     *
163     * @var string
164     */
165    private $yy_global_pattern1 = null;
166
167    private $yy_global_pattern2 = null;
168
169    private $yy_global_pattern3 = null;
170
171    private $yy_global_pattern4 = null;
172
173    private $yy_global_pattern5 = null;
174
175    /**
176     * token names
177     *
178     * @var array
179     */
180    public $smarty_token_names = array(        // Text for parser error messages
181                                               'NOT'         => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')',
182                                               'OPENB'       => '[', 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>',
183                                               'EQUAL'       => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-',
184                                               'MATH'        => '*" , "/" , "%', 'INCDEC' => '++" , "--',
185                                               'SPACE'       => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';',
186                                               'COLON'       => ':', 'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#',
187                                               'QUOTE'       => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier',
188                                               'DOT'         => '.', 'COMMA' => '","', 'QMARK' => '"?"',
189                                               'ID'          => 'id, name', 'TEXT' => 'text',
190                                               'LDELSLASH'   => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
191                                               'COMMENT'     => 'comment', 'AS' => 'as', 'TO' => 'to',
192                                               'PHP'         => '"<?php", "<%", "{php}" tag',
193                                               'LOGOP'       => '"<", "==" ... logical operator',
194                                               'TLOGOP'      => '"lt", "eq" ... logical operator; "is div by" ... if condition',
195                                               'SCOND'       => '"is even" ... if condition',);
196
197    /**
198     * constructor
199     *
200     * @param   string                             $data template source
201     * @param Smarty_Internal_TemplateCompilerBase $compiler
202     */
203    function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
204    {
205        $this->data = $data;
206        $this->counter = 0;
207        if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
208            $this->counter += strlen($match[ 0 ]);
209        }
210        $this->line = 1;
211        $this->smarty = $compiler->smarty;
212        $this->compiler = $compiler;
213        $this->ldel = preg_quote($this->smarty->left_delimiter, '~');
214        $this->ldel_length = strlen($this->smarty->left_delimiter);
215        $this->rdel = preg_quote($this->smarty->right_delimiter, '~');
216        $this->rdel_length = strlen($this->smarty->right_delimiter);
217        $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter;
218        $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter;
219    }
220
221    public function PrintTrace()
222    {
223        $this->yyTraceFILE = fopen('php://output', 'w');
224        $this->yyTracePrompt = '<br>';
225    }
226
227    /*
228     * Check if this tag is autoliteral
229     */
230    public function isAutoLiteral()
231    {
232        return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
233            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false;
234    }
235
236    private $_yy_state = 1;
237
238    private $_yy_stack = array();
239
240    public function yylex()
241    {
242        return $this->{'yylex' . $this->_yy_state}();
243    }
244
245    public function yypushstate($state)
246    {
247        if ($this->yyTraceFILE) {
248            fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
249                    isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
250                        $this->_yy_state);
251        }
252        array_push($this->_yy_stack, $this->_yy_state);
253        $this->_yy_state = $state;
254        if ($this->yyTraceFILE) {
255            fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
256                    isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
257                        $this->_yy_state);
258        }
259    }
260
261    public function yypopstate()
262    {
263        if ($this->yyTraceFILE) {
264            fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
265                    isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
266                        $this->_yy_state);
267        }
268        $this->_yy_state = array_pop($this->_yy_stack);
269        if ($this->yyTraceFILE) {
270            fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
271                    isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
272                        $this->_yy_state);
273        }
274    }
275
276    public function yybegin($state)
277    {
278        $this->_yy_state = $state;
279        if ($this->yyTraceFILE) {
280            fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
281                    isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
282                        $this->_yy_state);
283        }
284    }
285
286    public function yylex1()
287    {
288        if (!isset($this->yy_global_pattern1)) {
289            $this->yy_global_pattern1 =
290                "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" .
291                $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
292                ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
293                ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
294        }
295        if ($this->counter >= strlen($this->data)) {
296            return false; // end of input
297        }
298
299        do {
300            if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
301                $yysubmatches = $yymatches;
302                if (strlen($yysubmatches[ 0 ]) < 200) {
303                    $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
304                } else {
305                    $yymatches = array_filter($yymatches, 'strlen');
306                }
307                if (empty($yymatches)) {
308                    throw new Exception('Error: lexing failed because a rule matched' . ' an empty string.  Input "' .
309                                        substr($this->data, $this->counter, 5) . '... state TEXT');
310                }
311                next($yymatches); // skip global match
312                $this->token = key($yymatches); // token number
313                $this->value = current($yymatches); // token value
314                $r = $this->{'yy_r1_' . $this->token}();
315                if ($r === null) {
316                    $this->counter += strlen($this->value);
317                    $this->line += substr_count($this->value, "\n");
318                    // accept this token
319                    return true;
320                } elseif ($r === true) {
321                    // we have changed state
322                    // process this token in the new state
323                    return $this->yylex();
324                } elseif ($r === false) {
325                    $this->counter += strlen($this->value);
326                    $this->line += substr_count($this->value, "\n");
327                    if ($this->counter >= strlen($this->data)) {
328                        return false; // end of input
329                    }
330                    // skip this token
331                    continue;
332                }
333            } else {
334                throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
335            }
336            break;
337        } while (true);
338    } // end function
339
340    const TEXT = 1;
341
342    function yy_r1_1()
343    {
344
345        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
346    }
347
348    function yy_r1_2()
349    {
350
351        preg_match("~[*]{$this->rdel}~", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
352        if (isset($match[ 0 ][ 1 ])) {
353            $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
354        } else {
355            $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
356        }
357        $this->value = substr($this->data, $this->counter, $to - $this->counter);
358        return false;
359    }
360
361    function yy_r1_3()
362    {
363
364        $obj = new Smarty_Internal_Compile_Private_Php();
365        $obj->parsePhp($this);
366    }
367
368    function yy_r1_7()
369    {
370
371        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
372            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
373        ) {
374            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
375        } else {
376            $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
377            $this->yypushstate(self::LITERAL);
378        }
379    }
380
381    function yy_r1_8()
382    {
383
384        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
385            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
386        ) {
387            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
388        } else {
389            $this->yypushstate(self::TAG);
390            return true;
391        }
392    }
393
394    function yy_r1_9()
395    {
396
397        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
398    }
399
400    function yy_r1_10()
401    {
402
403        $obj = new Smarty_Internal_Compile_Private_Php();
404        $obj->parsePhp($this);
405    }
406
407    function yy_r1_19()
408    {
409
410        $to = strlen($this->data);
411        preg_match("~($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])~i",
412                   $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
413        if (isset($match[ 0 ][ 1 ])) {
414            $to = $match[ 0 ][ 1 ];
415        }
416        $this->value = substr($this->data, $this->counter, $to - $this->counter);
417        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
418    }
419
420    public function yylex2()
421    {
422        if (!isset($this->yy_global_pattern2)) {
423            $this->yy_global_pattern2 =
424                "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" .
425                $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel .
426                "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
427                "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel .
428                "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" .
429                $this->ldel . "\\s*)/isS";
430        }
431        if ($this->counter >= strlen($this->data)) {
432            return false; // end of input
433        }
434
435        do {
436            if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
437                $yysubmatches = $yymatches;
438                if (strlen($yysubmatches[ 0 ]) < 200) {
439                    $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
440                } else {
441                    $yymatches = array_filter($yymatches, 'strlen');
442                }
443                if (empty($yymatches)) {
444                    throw new Exception('Error: lexing failed because a rule matched' . ' an empty string.  Input "' .
445                                        substr($this->data, $this->counter, 5) . '... state TAG');
446                }
447                next($yymatches); // skip global match
448                $this->token = key($yymatches); // token number
449                $this->value = current($yymatches); // token value
450                $r = $this->{'yy_r2_' . $this->token}();
451                if ($r === null) {
452                    $this->counter += strlen($this->value);
453                    $this->line += substr_count($this->value, "\n");
454                    // accept this token
455                    return true;
456                } elseif ($r === true) {
457                    // we have changed state
458                    // process this token in the new state
459                    return $this->yylex();
460                } elseif ($r === false) {
461                    $this->counter += strlen($this->value);
462                    $this->line += substr_count($this->value, "\n");
463                    if ($this->counter >= strlen($this->data)) {
464                        return false; // end of input
465                    }
466                    // skip this token
467                    continue;
468                }
469            } else {
470                throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
471            }
472            break;
473        } while (true);
474    } // end function
475
476    const TAG = 2;
477
478    function yy_r2_1()
479    {
480
481        $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
482        $this->yybegin(self::TAGBODY);
483        $this->taglineno = $this->line;
484    }
485
486    function yy_r2_3()
487    {
488
489        $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
490        $this->yybegin(self::TAGBODY);
491        $this->taglineno = $this->line;
492    }
493
494    function yy_r2_4()
495    {
496
497        $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
498        $this->yybegin(self::TAGBODY);
499        $this->taglineno = $this->line;
500    }
501
502    function yy_r2_5()
503    {
504
505        $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
506        $this->yybegin(self::TAGBODY);
507        $this->taglineno = $this->line;
508    }
509
510    function yy_r2_6()
511    {
512
513        $this->yypopstate();
514        $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
515        $this->taglineno = $this->line;
516    }
517
518    function yy_r2_8()
519    {
520
521        $this->yypopstate();
522        $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
523        $this->taglineno = $this->line;
524    }
525
526    function yy_r2_9()
527    {
528
529        if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) {
530            $this->yypopstate();
531            $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
532            $this->taglineno = $this->line;
533        } else {
534            $this->value = $this->smarty->left_delimiter;
535            $this->token = Smarty_Internal_Templateparser::TP_LDEL;
536            $this->yybegin(self::TAGBODY);
537            $this->taglineno = $this->line;
538        }
539    }
540
541    function yy_r2_11()
542    {
543
544        $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
545        $this->yybegin(self::TAGBODY);
546        $this->taglineno = $this->line;
547    }
548
549    function yy_r2_12()
550    {
551
552        $this->token = Smarty_Internal_Templateparser::TP_LDEL;
553        $this->yybegin(self::TAGBODY);
554        $this->taglineno = $this->line;
555    }
556
557    public function yylex3()
558    {
559        if (!isset($this->yy_global_pattern3)) {
560            $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
561                "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\\s+(not\\s+)?(odd|even|div)\\s+by))\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\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(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS";
562        }
563        if ($this->counter >= strlen($this->data)) {
564            return false; // end of input
565        }
566
567        do {
568            if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
569                $yysubmatches = $yymatches;
570                if (strlen($yysubmatches[ 0 ]) < 200) {
571                    $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
572                } else {
573                    $yymatches = array_filter($yymatches, 'strlen');
574                }
575                if (empty($yymatches)) {
576                    throw new Exception('Error: lexing failed because a rule matched' . ' an empty string.  Input "' .
577                                        substr($this->data, $this->counter, 5) . '... state TAGBODY');
578                }
579                next($yymatches); // skip global match
580                $this->token = key($yymatches); // token number
581                $this->value = current($yymatches); // token value
582                $r = $this->{'yy_r3_' . $this->token}();
583                if ($r === null) {
584                    $this->counter += strlen($this->value);
585                    $this->line += substr_count($this->value, "\n");
586                    // accept this token
587                    return true;
588                } elseif ($r === true) {
589                    // we have changed state
590                    // process this token in the new state
591                    return $this->yylex();
592                } elseif ($r === false) {
593                    $this->counter += strlen($this->value);
594                    $this->line += substr_count($this->value, "\n");
595                    if ($this->counter >= strlen($this->data)) {
596                        return false; // end of input
597                    }
598                    // skip this token
599                    continue;
600                }
601            } else {
602                throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
603            }
604            break;
605        } while (true);
606    } // end function
607
608    const TAGBODY = 3;
609
610    function yy_r3_1()
611    {
612
613        $this->token = Smarty_Internal_Templateparser::TP_RDEL;
614        $this->yypopstate();
615    }
616
617    function yy_r3_2()
618    {
619
620        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
621            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
622        ) {
623            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
624        } else {
625            $this->yypushstate(self::TAG);
626            return true;
627        }
628    }
629
630    function yy_r3_3()
631    {
632
633        $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
634        $this->yypushstate(self::DOUBLEQUOTEDSTRING);
635    }
636
637    function yy_r3_4()
638    {
639
640        $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
641    }
642
643    function yy_r3_5()
644    {
645
646        $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
647        $this->taglineno = $this->line;
648    }
649
650    function yy_r3_7()
651    {
652
653        $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
654    }
655
656    function yy_r3_8()
657    {
658
659        $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
660    }
661
662    function yy_r3_9()
663    {
664
665        $this->token = Smarty_Internal_Templateparser::TP_ISIN;
666    }
667
668    function yy_r3_10()
669    {
670
671        $this->token = Smarty_Internal_Templateparser::TP_AS;
672    }
673
674    function yy_r3_11()
675    {
676
677        $this->token = Smarty_Internal_Templateparser::TP_TO;
678    }
679
680    function yy_r3_12()
681    {
682
683        $this->token = Smarty_Internal_Templateparser::TP_STEP;
684    }
685
686    function yy_r3_13()
687    {
688
689        $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
690    }
691
692    function yy_r3_14()
693    {
694
695        $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
696    }
697
698    function yy_r3_19()
699    {
700
701        $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
702    }
703
704    function yy_r3_24()
705    {
706
707        $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
708    }
709
710    function yy_r3_27()
711    {
712
713        $this->token = Smarty_Internal_Templateparser::TP_NOT;
714    }
715
716    function yy_r3_30()
717    {
718
719        $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
720    }
721
722    function yy_r3_34()
723    {
724
725        $this->token = Smarty_Internal_Templateparser::TP_OPENP;
726    }
727
728    function yy_r3_35()
729    {
730
731        $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
732    }
733
734    function yy_r3_36()
735    {
736
737        $this->token = Smarty_Internal_Templateparser::TP_OPENB;
738    }
739
740    function yy_r3_37()
741    {
742
743        $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
744    }
745
746    function yy_r3_38()
747    {
748
749        $this->token = Smarty_Internal_Templateparser::TP_PTR;
750    }
751
752    function yy_r3_39()
753    {
754
755        $this->token = Smarty_Internal_Templateparser::TP_APTR;
756    }
757
758    function yy_r3_40()
759    {
760
761        $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
762    }
763
764    function yy_r3_41()
765    {
766
767        $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
768    }
769
770    function yy_r3_43()
771    {
772
773        $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
774    }
775
776    function yy_r3_45()
777    {
778
779        $this->token = Smarty_Internal_Templateparser::TP_MATH;
780    }
781
782    function yy_r3_47()
783    {
784
785        $this->token = Smarty_Internal_Templateparser::TP_AT;
786    }
787
788    function yy_r3_48()
789    {
790
791        $this->token = Smarty_Internal_Templateparser::TP_HATCH;
792    }
793
794    function yy_r3_49()
795    {
796
797        // resolve conflicts with shorttag and right_delimiter starting with '='
798        if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
799            $this->smarty->right_delimiter
800        ) {
801            preg_match("~\s+~", $this->value, $match);
802            $this->value = $match[ 0 ];
803            $this->token = Smarty_Internal_Templateparser::TP_SPACE;
804        } else {
805            $this->token = Smarty_Internal_Templateparser::TP_ATTR;
806        }
807    }
808
809    function yy_r3_50()
810    {
811
812        $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
813    }
814
815    function yy_r3_53()
816    {
817
818        $this->token = Smarty_Internal_Templateparser::TP_ID;
819    }
820
821    function yy_r3_54()
822    {
823
824        $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
825    }
826
827    function yy_r3_55()
828    {
829
830        $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
831        $this->yypopstate();
832    }
833
834    function yy_r3_56()
835    {
836
837        $this->token = Smarty_Internal_Templateparser::TP_VERT;
838    }
839
840    function yy_r3_57()
841    {
842
843        $this->token = Smarty_Internal_Templateparser::TP_DOT;
844    }
845
846    function yy_r3_58()
847    {
848
849        $this->token = Smarty_Internal_Templateparser::TP_COMMA;
850    }
851
852    function yy_r3_59()
853    {
854
855        $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
856    }
857
858    function yy_r3_60()
859    {
860
861        $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
862    }
863
864    function yy_r3_61()
865    {
866
867        $this->token = Smarty_Internal_Templateparser::TP_COLON;
868    }
869
870    function yy_r3_62()
871    {
872
873        $this->token = Smarty_Internal_Templateparser::TP_QMARK;
874    }
875
876    function yy_r3_63()
877    {
878
879        $this->token = Smarty_Internal_Templateparser::TP_HEX;
880    }
881
882    function yy_r3_64()
883    {
884
885        $this->token = Smarty_Internal_Templateparser::TP_SPACE;
886    }
887
888    function yy_r3_65()
889    {
890
891        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
892    }
893
894    public function yylex4()
895    {
896        if (!isset($this->yy_global_pattern4)) {
897            $this->yy_global_pattern4 =
898                "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
899                $this->rdel . ")|\G([\S\s])/isS";
900        }
901        if ($this->counter >= strlen($this->data)) {
902            return false; // end of input
903        }
904
905        do {
906            if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
907                $yysubmatches = $yymatches;
908                if (strlen($yysubmatches[ 0 ]) < 200) {
909                    $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
910                } else {
911                    $yymatches = array_filter($yymatches, 'strlen');
912                }
913                if (empty($yymatches)) {
914                    throw new Exception('Error: lexing failed because a rule matched' . ' an empty string.  Input "' .
915                                        substr($this->data, $this->counter, 5) . '... state LITERAL');
916                }
917                next($yymatches); // skip global match
918                $this->token = key($yymatches); // token number
919                $this->value = current($yymatches); // token value
920                $r = $this->{'yy_r4_' . $this->token}();
921                if ($r === null) {
922                    $this->counter += strlen($this->value);
923                    $this->line += substr_count($this->value, "\n");
924                    // accept this token
925                    return true;
926                } elseif ($r === true) {
927                    // we have changed state
928                    // process this token in the new state
929                    return $this->yylex();
930                } elseif ($r === false) {
931                    $this->counter += strlen($this->value);
932                    $this->line += substr_count($this->value, "\n");
933                    if ($this->counter >= strlen($this->data)) {
934                        return false; // end of input
935                    }
936                    // skip this token
937                    continue;
938                }
939            } else {
940                throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
941            }
942            break;
943        } while (true);
944    } // end function
945
946    const LITERAL = 4;
947
948    function yy_r4_1()
949    {
950
951        $this->literal_cnt ++;
952        $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
953    }
954
955    function yy_r4_2()
956    {
957
958        if ($this->literal_cnt) {
959            $this->literal_cnt --;
960            $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
961        } else {
962            $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
963            $this->yypopstate();
964        }
965    }
966
967    function yy_r4_3()
968    {
969
970        $to = strlen($this->data);
971        preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE,
972                   $this->counter);
973        if (isset($match[ 0 ][ 1 ])) {
974            $to = $match[ 0 ][ 1 ];
975        } else {
976            $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
977        }
978        $this->value = substr($this->data, $this->counter, $to - $this->counter);
979        $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
980    }
981
982    public function yylex5()
983    {
984        if (!isset($this->yy_global_pattern5)) {
985            $this->yy_global_pattern5 =
986                "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
987                $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
988                $this->ldel .
989                "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
990                $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
991        }
992        if ($this->counter >= strlen($this->data)) {
993            return false; // end of input
994        }
995
996        do {
997            if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
998                $yysubmatches = $yymatches;
999                if (strlen($yysubmatches[ 0 ]) < 200) {
1000                    $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
1001                } else {
1002                    $yymatches = array_filter($yymatches, 'strlen');
1003                }
1004                if (empty($yymatches)) {
1005                    throw new Exception('Error: lexing failed because a rule matched' . ' an empty string.  Input "' .
1006                                        substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1007                }
1008                next($yymatches); // skip global match
1009                $this->token = key($yymatches); // token number
1010                $this->value = current($yymatches); // token value
1011                $r = $this->{'yy_r5_' . $this->token}();
1012                if ($r === null) {
1013                    $this->counter += strlen($this->value);
1014                    $this->line += substr_count($this->value, "\n");
1015                    // accept this token
1016                    return true;
1017                } elseif ($r === true) {
1018                    // we have changed state
1019                    // process this token in the new state
1020                    return $this->yylex();
1021                } elseif ($r === false) {
1022                    $this->counter += strlen($this->value);
1023                    $this->line += substr_count($this->value, "\n");
1024                    if ($this->counter >= strlen($this->data)) {
1025                        return false; // end of input
1026                    }
1027                    // skip this token
1028                    continue;
1029                }
1030            } else {
1031                throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
1032            }
1033            break;
1034        } while (true);
1035    } // end function
1036
1037    const DOUBLEQUOTEDSTRING = 5;
1038
1039    function yy_r5_1()
1040    {
1041
1042        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1043    }
1044
1045    function yy_r5_2()
1046    {
1047
1048        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1049    }
1050
1051    function yy_r5_3()
1052    {
1053
1054        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
1055            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
1056        ) {
1057            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1058        } else {
1059            $this->yypushstate(self::TAG);
1060            return true;
1061        }
1062    }
1063
1064    function yy_r5_4()
1065    {
1066
1067        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
1068            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
1069        ) {
1070            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1071        } else {
1072            $this->yypushstate(self::TAG);
1073            return true;
1074        }
1075    }
1076
1077    function yy_r5_5()
1078    {
1079
1080        if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
1081            strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
1082        ) {
1083            $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1084        } else {
1085            $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1086            $this->taglineno = $this->line;
1087            $this->yypushstate(self::TAGBODY);
1088        }
1089    }
1090
1091    function yy_r5_6()
1092    {
1093
1094        $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1095        $this->yypopstate();
1096    }
1097
1098    function yy_r5_7()
1099    {
1100
1101        $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1102        $this->value = substr($this->value, 0, - 1);
1103        $this->yypushstate(self::TAGBODY);
1104        $this->taglineno = $this->line;
1105    }
1106
1107    function yy_r5_8()
1108    {
1109
1110        $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1111    }
1112
1113    function yy_r5_9()
1114    {
1115
1116        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1117    }
1118
1119    function yy_r5_10()
1120    {
1121
1122        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1123    }
1124
1125    function yy_r5_14()
1126    {
1127
1128        $to = strlen($this->data);
1129        $this->value = substr($this->data, $this->counter, $to - $this->counter);
1130        $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1131    }
1132
1133}
1134
1135