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