3 * Smarty Internal Plugin Templatelexer
4 * This is the lexer to break the template source into tokens
12 * Smarty Internal Plugin Templatelexer
14 class Smarty_Internal_Templatelexer
24 private $heredoc_id_stack = Array();
26 public $yyTracePrompt;
27 public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY');
28 public $smarty_token_names = array( // Text for parser error messages
30 'NONEIDENTITY' => '!==',
33 'GREATEREQUAL' => '(>=,ge)',
34 'LESSEQUAL' => '(<=,le)',
35 'GREATERTHAN' => '(>,gt)',
36 'LESSTHAN' => '(<,lt)',
50 'UNIMATH' => '+" , "-',
51 'MATH' => '*" , "/" , "%',
52 'INCDEC' => '++" , "--',
57 'DOUBLECOLON' => '::',
69 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
70 'PHPSTARTTAG' => 'PHP start tag',
71 'PHPENDTAG' => 'PHP end tag',
72 'LITERALSTART' => 'Literal start',
73 'LITERALEND' => 'Literal end',
74 'LDELSLASH' => 'closing tag',
75 'COMMENT' => 'comment',
80 function __construct($data, $compiler)
82 // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
86 $this->smarty = $compiler->smarty;
87 $this->compiler = $compiler;
88 $this->ldel = preg_quote($this->smarty->left_delimiter, '/');
89 $this->ldel_length = strlen($this->smarty->left_delimiter);
90 $this->rdel = preg_quote($this->smarty->right_delimiter, '/');
91 $this->rdel_length = strlen($this->smarty->right_delimiter);
92 $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
93 $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
96 public function PrintTrace()
98 $this->yyTraceFILE = fopen('php://output', 'w');
99 $this->yyTracePrompt = '<br>';
102 private $_yy_state = 1;
103 private $_yy_stack = array();
105 public function yylex()
107 return $this->{'yylex' . $this->_yy_state}();
110 public function yypushstate($state)
112 if ($this->yyTraceFILE) {
113 fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
115 array_push($this->_yy_stack, $this->_yy_state);
116 $this->_yy_state = $state;
117 if ($this->yyTraceFILE) {
118 fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
122 public function yypopstate()
124 if ($this->yyTraceFILE) {
125 fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
127 $this->_yy_state = array_pop($this->_yy_stack);
128 if ($this->yyTraceFILE) {
129 fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
133 public function yybegin($state)
135 $this->_yy_state = $state;
136 if ($this->yyTraceFILE) {
137 fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
141 public function yylex1()
162 if ($this->counter >= strlen($this->data)) {
163 return false; // end of input
165 $yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*" . $this->rdel . ")|\G(<%)|\G(%>)|\G([\S\s])/iS";
168 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
169 $yysubmatches = $yymatches;
170 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
171 if (!count($yymatches)) {
172 throw new Exception('Error: lexing failed because a rule matched' .
173 ' an empty string. Input "' . substr($this->data,
174 $this->counter, 5) . '... state TEXT');
176 next($yymatches); // skip global match
177 $this->token = key($yymatches); // token number
178 if ($tokenMap[$this->token]) {
179 // extract sub-patterns for passing to lex function
180 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
181 $tokenMap[$this->token]);
183 $yysubmatches = array();
185 $this->value = current($yymatches); // token value
186 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
188 $this->counter += strlen($this->value);
189 $this->line += substr_count($this->value, "\n");
192 } elseif ($r === true) {
193 // we have changed state
194 // process this token in the new state
195 return $this->yylex();
196 } elseif ($r === false) {
197 $this->counter += strlen($this->value);
198 $this->line += substr_count($this->value, "\n");
199 if ($this->counter >= strlen($this->data)) {
200 return false; // end of input
206 throw new Exception('Unexpected input at line' . $this->line .
207 ': ' . $this->data[$this->counter]);
215 function yy_r1_1($yy_subpatterns)
218 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
221 function yy_r1_2($yy_subpatterns)
224 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
227 function yy_r1_4($yy_subpatterns)
230 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
231 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
233 $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
237 function yy_r1_5($yy_subpatterns)
240 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
241 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
243 $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
247 function yy_r1_6($yy_subpatterns)
250 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
251 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
253 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
254 $this->yypushstate(self::LITERAL);
258 function yy_r1_7($yy_subpatterns)
261 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
262 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
264 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
265 $this->yypushstate(self::SMARTY);
266 $this->taglineno = $this->line;
270 function yy_r1_9($yy_subpatterns)
273 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
274 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
276 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
277 $this->yypushstate(self::SMARTY);
278 $this->taglineno = $this->line;
282 function yy_r1_10($yy_subpatterns)
285 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
286 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
288 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
289 $this->yypushstate(self::SMARTY);
290 $this->taglineno = $this->line;
294 function yy_r1_11($yy_subpatterns)
297 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
298 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
300 $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
301 $this->yypushstate(self::SMARTY);
302 $this->taglineno = $this->line;
306 function yy_r1_12($yy_subpatterns)
309 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
310 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
312 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
313 $this->yypushstate(self::SMARTY);
314 $this->taglineno = $this->line;
318 function yy_r1_13($yy_subpatterns)
321 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
322 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
324 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
325 $this->yypushstate(self::SMARTY);
326 $this->taglineno = $this->line;
330 function yy_r1_14($yy_subpatterns)
333 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
334 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
335 } elseif ($this->value == '<?xml') {
336 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
338 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
339 $this->value = substr($this->value, 0, 2);
343 function yy_r1_15($yy_subpatterns)
346 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
349 function yy_r1_16($yy_subpatterns)
352 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
355 function yy_r1_17($yy_subpatterns)
358 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
361 function yy_r1_18($yy_subpatterns)
364 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
367 function yy_r1_19($yy_subpatterns)
370 $to = strlen($this->data);
371 preg_match("/{$this->ldel}|<\?|\?>|<%|%>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
372 if (isset($match[0][1])) {
375 $this->value = substr($this->data, $this->counter, $to - $this->counter);
376 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
379 public function yylex2()
449 if ($this->counter >= strlen($this->data)) {
450 return false; // end of input
452 $yy_global_pattern = "/\G(\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G(\\$)|\G(\\s*" . $this->rdel . ")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(@)|\G(#)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*=\\s*)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/iS";
455 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
456 $yysubmatches = $yymatches;
457 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
458 if (!count($yymatches)) {
459 throw new Exception('Error: lexing failed because a rule matched' .
460 ' an empty string. Input "' . substr($this->data,
461 $this->counter, 5) . '... state SMARTY');
463 next($yymatches); // skip global match
464 $this->token = key($yymatches); // token number
465 if ($tokenMap[$this->token]) {
466 // extract sub-patterns for passing to lex function
467 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
468 $tokenMap[$this->token]);
470 $yysubmatches = array();
472 $this->value = current($yymatches); // token value
473 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
475 $this->counter += strlen($this->value);
476 $this->line += substr_count($this->value, "\n");
479 } elseif ($r === true) {
480 // we have changed state
481 // process this token in the new state
482 return $this->yylex();
483 } elseif ($r === false) {
484 $this->counter += strlen($this->value);
485 $this->line += substr_count($this->value, "\n");
486 if ($this->counter >= strlen($this->data)) {
487 return false; // end of input
493 throw new Exception('Unexpected input at line' . $this->line .
494 ': ' . $this->data[$this->counter]);
502 function yy_r2_1($yy_subpatterns)
505 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
506 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
509 function yy_r2_2($yy_subpatterns)
512 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
515 function yy_r2_3($yy_subpatterns)
518 $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
519 $this->taglineno = $this->line;
522 function yy_r2_5($yy_subpatterns)
525 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
528 function yy_r2_6($yy_subpatterns)
531 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
535 function yy_r2_7($yy_subpatterns)
538 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
541 function yy_r2_8($yy_subpatterns)
544 $this->token = Smarty_Internal_Templateparser::TP_AS;
547 function yy_r2_9($yy_subpatterns)
550 $this->token = Smarty_Internal_Templateparser::TP_TO;
553 function yy_r2_10($yy_subpatterns)
556 $this->token = Smarty_Internal_Templateparser::TP_STEP;
559 function yy_r2_11($yy_subpatterns)
562 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
565 function yy_r2_12($yy_subpatterns)
568 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
571 function yy_r2_13($yy_subpatterns)
574 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
577 function yy_r2_14($yy_subpatterns)
580 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
583 function yy_r2_15($yy_subpatterns)
586 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
589 function yy_r2_17($yy_subpatterns)
592 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
595 function yy_r2_19($yy_subpatterns)
598 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
601 function yy_r2_21($yy_subpatterns)
604 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
607 function yy_r2_22($yy_subpatterns)
610 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
613 function yy_r2_23($yy_subpatterns)
616 $this->token = Smarty_Internal_Templateparser::TP_MOD;
619 function yy_r2_24($yy_subpatterns)
622 $this->token = Smarty_Internal_Templateparser::TP_NOT;
625 function yy_r2_25($yy_subpatterns)
628 $this->token = Smarty_Internal_Templateparser::TP_LAND;
631 function yy_r2_26($yy_subpatterns)
634 $this->token = Smarty_Internal_Templateparser::TP_LOR;
637 function yy_r2_27($yy_subpatterns)
640 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
643 function yy_r2_28($yy_subpatterns)
646 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
649 function yy_r2_29($yy_subpatterns)
652 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
655 function yy_r2_30($yy_subpatterns)
658 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
661 function yy_r2_31($yy_subpatterns)
664 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
667 function yy_r2_32($yy_subpatterns)
670 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
673 function yy_r2_33($yy_subpatterns)
676 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
679 function yy_r2_34($yy_subpatterns)
682 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
685 function yy_r2_35($yy_subpatterns)
688 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
691 function yy_r2_36($yy_subpatterns)
694 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
697 function yy_r2_37($yy_subpatterns)
700 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
703 function yy_r2_38($yy_subpatterns)
706 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
709 function yy_r2_42($yy_subpatterns)
712 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
715 function yy_r2_43($yy_subpatterns)
718 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
721 function yy_r2_44($yy_subpatterns)
724 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
727 function yy_r2_45($yy_subpatterns)
730 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
733 function yy_r2_46($yy_subpatterns)
736 $this->token = Smarty_Internal_Templateparser::TP_PTR;
739 function yy_r2_47($yy_subpatterns)
742 $this->token = Smarty_Internal_Templateparser::TP_APTR;
745 function yy_r2_48($yy_subpatterns)
748 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
751 function yy_r2_49($yy_subpatterns)
754 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
757 function yy_r2_50($yy_subpatterns)
760 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
763 function yy_r2_52($yy_subpatterns)
766 $this->token = Smarty_Internal_Templateparser::TP_MATH;
769 function yy_r2_54($yy_subpatterns)
772 $this->token = Smarty_Internal_Templateparser::TP_AT;
775 function yy_r2_55($yy_subpatterns)
778 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
781 function yy_r2_56($yy_subpatterns)
784 // resolve conflicts with shorttag and right_delimiter starting with '='
785 if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
786 preg_match("/\s+/", $this->value, $match);
787 $this->value = $match[0];
788 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
790 $this->token = Smarty_Internal_Templateparser::TP_ATTR;
794 function yy_r2_57($yy_subpatterns)
797 $this->token = Smarty_Internal_Templateparser::TP_ID;
800 function yy_r2_58($yy_subpatterns)
803 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
806 function yy_r2_59($yy_subpatterns)
809 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
813 function yy_r2_60($yy_subpatterns)
816 $this->token = Smarty_Internal_Templateparser::TP_VERT;
819 function yy_r2_61($yy_subpatterns)
822 $this->token = Smarty_Internal_Templateparser::TP_DOT;
825 function yy_r2_62($yy_subpatterns)
828 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
831 function yy_r2_63($yy_subpatterns)
834 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
837 function yy_r2_64($yy_subpatterns)
840 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
843 function yy_r2_65($yy_subpatterns)
846 $this->token = Smarty_Internal_Templateparser::TP_COLON;
849 function yy_r2_66($yy_subpatterns)
852 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
855 function yy_r2_67($yy_subpatterns)
858 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
861 function yy_r2_68($yy_subpatterns)
864 $this->token = Smarty_Internal_Templateparser::TP_HEX;
867 function yy_r2_69($yy_subpatterns)
870 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
873 function yy_r2_70($yy_subpatterns)
876 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
877 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
879 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
880 $this->yypushstate(self::SMARTY);
881 $this->taglineno = $this->line;
885 function yy_r2_72($yy_subpatterns)
888 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
889 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
891 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
892 $this->yypushstate(self::SMARTY);
893 $this->taglineno = $this->line;
897 function yy_r2_73($yy_subpatterns)
900 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
901 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
903 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
904 $this->yypushstate(self::SMARTY);
905 $this->taglineno = $this->line;
909 function yy_r2_74($yy_subpatterns)
912 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
913 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
915 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
916 $this->yypushstate(self::SMARTY);
917 $this->taglineno = $this->line;
921 function yy_r2_75($yy_subpatterns)
924 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
925 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
927 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
928 $this->yypushstate(self::SMARTY);
929 $this->taglineno = $this->line;
933 function yy_r2_76($yy_subpatterns)
936 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
939 public function yylex3()
950 if ($this->counter >= strlen($this->data)) {
951 return false; // end of input
953 $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
956 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
957 $yysubmatches = $yymatches;
958 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
959 if (!count($yymatches)) {
960 throw new Exception('Error: lexing failed because a rule matched' .
961 ' an empty string. Input "' . substr($this->data,
962 $this->counter, 5) . '... state LITERAL');
964 next($yymatches); // skip global match
965 $this->token = key($yymatches); // token number
966 if ($tokenMap[$this->token]) {
967 // extract sub-patterns for passing to lex function
968 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
969 $tokenMap[$this->token]);
971 $yysubmatches = array();
973 $this->value = current($yymatches); // token value
974 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
976 $this->counter += strlen($this->value);
977 $this->line += substr_count($this->value, "\n");
980 } elseif ($r === true) {
981 // we have changed state
982 // process this token in the new state
983 return $this->yylex();
984 } elseif ($r === false) {
985 $this->counter += strlen($this->value);
986 $this->line += substr_count($this->value, "\n");
987 if ($this->counter >= strlen($this->data)) {
988 return false; // end of input
994 throw new Exception('Unexpected input at line' . $this->line .
995 ': ' . $this->data[$this->counter]);
1003 function yy_r3_1($yy_subpatterns)
1006 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1007 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1009 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
1010 $this->yypushstate(self::LITERAL);
1014 function yy_r3_2($yy_subpatterns)
1017 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1018 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1020 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
1021 $this->yypopstate();
1025 function yy_r3_3($yy_subpatterns)
1028 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
1029 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
1031 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
1032 $this->value = substr($this->value, 0, 2);
1036 function yy_r3_4($yy_subpatterns)
1039 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
1042 function yy_r3_5($yy_subpatterns)
1045 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
1048 function yy_r3_6($yy_subpatterns)
1051 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
1054 function yy_r3_7($yy_subpatterns)
1057 $to = strlen($this->data);
1058 preg_match("/{$this->ldel}\/?literal{$this->rdel}|<\?|<%|\?>|%>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
1059 if (isset($match[0][1])) {
1062 $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
1064 $this->value = substr($this->data, $this->counter, $to - $this->counter);
1065 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
1068 public function yylex4()
1083 if ($this->counter >= strlen($this->data)) {
1084 return false; // end of input
1086 $yy_global_pattern = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/iS";
1089 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
1090 $yysubmatches = $yymatches;
1091 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1092 if (!count($yymatches)) {
1093 throw new Exception('Error: lexing failed because a rule matched' .
1094 ' an empty string. Input "' . substr($this->data,
1095 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1097 next($yymatches); // skip global match
1098 $this->token = key($yymatches); // token number
1099 if ($tokenMap[$this->token]) {
1100 // extract sub-patterns for passing to lex function
1101 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1102 $tokenMap[$this->token]);
1104 $yysubmatches = array();
1106 $this->value = current($yymatches); // token value
1107 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1109 $this->counter += strlen($this->value);
1110 $this->line += substr_count($this->value, "\n");
1111 // accept this token
1113 } elseif ($r === true) {
1114 // we have changed state
1115 // process this token in the new state
1116 return $this->yylex();
1117 } elseif ($r === false) {
1118 $this->counter += strlen($this->value);
1119 $this->line += substr_count($this->value, "\n");
1120 if ($this->counter >= strlen($this->data)) {
1121 return false; // end of input
1127 throw new Exception('Unexpected input at line' . $this->line .
1128 ': ' . $this->data[$this->counter]);
1134 const DOUBLEQUOTEDSTRING = 4;
1136 function yy_r4_1($yy_subpatterns)
1139 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1140 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1142 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
1143 $this->yypushstate(self::SMARTY);
1144 $this->taglineno = $this->line;
1148 function yy_r4_3($yy_subpatterns)
1151 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1152 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1154 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
1155 $this->yypushstate(self::SMARTY);
1156 $this->taglineno = $this->line;
1160 function yy_r4_4($yy_subpatterns)
1163 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1164 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1166 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
1167 $this->yypushstate(self::SMARTY);
1168 $this->taglineno = $this->line;
1172 function yy_r4_5($yy_subpatterns)
1175 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1176 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1178 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1179 $this->yypushstate(self::SMARTY);
1180 $this->taglineno = $this->line;
1184 function yy_r4_6($yy_subpatterns)
1187 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1188 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1190 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1191 $this->yypushstate(self::SMARTY);
1192 $this->taglineno = $this->line;
1196 function yy_r4_7($yy_subpatterns)
1199 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1200 $this->yypopstate();
1203 function yy_r4_8($yy_subpatterns)
1206 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1207 $this->value = substr($this->value, 0, - 1);
1208 $this->yypushstate(self::SMARTY);
1209 $this->taglineno = $this->line;
1212 function yy_r4_9($yy_subpatterns)
1215 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1218 function yy_r4_10($yy_subpatterns)
1221 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1224 function yy_r4_11($yy_subpatterns)
1227 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1230 function yy_r4_15($yy_subpatterns)
1233 $to = strlen($this->data);
1234 $this->value = substr($this->data, $this->counter, $to - $this->counter);
1235 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1238 public function yylex5()
1246 if ($this->counter >= strlen($this->data)) {
1247 return false; // end of input
1249 $yy_global_pattern = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/iS";
1252 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
1253 $yysubmatches = $yymatches;
1254 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1255 if (!count($yymatches)) {
1256 throw new Exception('Error: lexing failed because a rule matched' .
1257 ' an empty string. Input "' . substr($this->data,
1258 $this->counter, 5) . '... state CHILDBODY');
1260 next($yymatches); // skip global match
1261 $this->token = key($yymatches); // token number
1262 if ($tokenMap[$this->token]) {
1263 // extract sub-patterns for passing to lex function
1264 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1265 $tokenMap[$this->token]);
1267 $yysubmatches = array();
1269 $this->value = current($yymatches); // token value
1270 $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
1272 $this->counter += strlen($this->value);
1273 $this->line += substr_count($this->value, "\n");
1274 // accept this token
1276 } elseif ($r === true) {
1277 // we have changed state
1278 // process this token in the new state
1279 return $this->yylex();
1280 } elseif ($r === false) {
1281 $this->counter += strlen($this->value);
1282 $this->line += substr_count($this->value, "\n");
1283 if ($this->counter >= strlen($this->data)) {
1284 return false; // end of input
1290 throw new Exception('Unexpected input at line' . $this->line .
1291 ': ' . $this->data[$this->counter]);
1297 const CHILDBODY = 5;
1299 function yy_r5_1($yy_subpatterns)
1302 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1305 $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
1309 function yy_r5_2($yy_subpatterns)
1312 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1315 $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
1319 function yy_r5_3($yy_subpatterns)
1322 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1325 $this->yypopstate();
1330 function yy_r5_4($yy_subpatterns)
1333 $to = strlen($this->data);
1334 preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
1335 if (isset($match[0][1])) {
1338 $this->value = substr($this->data, $this->counter, $to - $this->counter);
1342 public function yylex6()
1351 if ($this->counter >= strlen($this->data)) {
1352 return false; // end of input
1354 $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*\/block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/iS";
1357 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
1358 $yysubmatches = $yymatches;
1359 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1360 if (!count($yymatches)) {
1361 throw new Exception('Error: lexing failed because a rule matched' .
1362 ' an empty string. Input "' . substr($this->data,
1363 $this->counter, 5) . '... state CHILDBLOCK');
1365 next($yymatches); // skip global match
1366 $this->token = key($yymatches); // token number
1367 if ($tokenMap[$this->token]) {
1368 // extract sub-patterns for passing to lex function
1369 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1370 $tokenMap[$this->token]);
1372 $yysubmatches = array();
1374 $this->value = current($yymatches); // token value
1375 $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
1377 $this->counter += strlen($this->value);
1378 $this->line += substr_count($this->value, "\n");
1379 // accept this token
1381 } elseif ($r === true) {
1382 // we have changed state
1383 // process this token in the new state
1384 return $this->yylex();
1385 } elseif ($r === false) {
1386 $this->counter += strlen($this->value);
1387 $this->line += substr_count($this->value, "\n");
1388 if ($this->counter >= strlen($this->data)) {
1389 return false; // end of input
1395 throw new Exception('Unexpected input at line' . $this->line .
1396 ': ' . $this->data[$this->counter]);
1402 const CHILDBLOCK = 6;
1404 function yy_r6_1($yy_subpatterns)
1407 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1408 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1410 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1411 $this->yypushstate(self::CHILDLITERAL);
1415 function yy_r6_2($yy_subpatterns)
1418 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1419 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1421 $this->yypopstate();
1426 function yy_r6_3($yy_subpatterns)
1429 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1430 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1432 $this->yypopstate();
1437 function yy_r6_4($yy_subpatterns)
1440 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1441 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1443 $this->yypopstate();
1448 function yy_r6_6($yy_subpatterns)
1451 $to = strlen($this->data);
1452 preg_match("/" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|(\/)?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
1453 if (isset($match[0][1])) {
1456 $this->value = substr($this->data, $this->counter, $to - $this->counter);
1457 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1460 public function yylex7()
1467 if ($this->counter >= strlen($this->data)) {
1468 return false; // end of input
1470 $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS";
1473 if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
1474 $yysubmatches = $yymatches;
1475 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1476 if (!count($yymatches)) {
1477 throw new Exception('Error: lexing failed because a rule matched' .
1478 ' an empty string. Input "' . substr($this->data,
1479 $this->counter, 5) . '... state CHILDLITERAL');
1481 next($yymatches); // skip global match
1482 $this->token = key($yymatches); // token number
1483 if ($tokenMap[$this->token]) {
1484 // extract sub-patterns for passing to lex function
1485 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1486 $tokenMap[$this->token]);
1488 $yysubmatches = array();
1490 $this->value = current($yymatches); // token value
1491 $r = $this->{'yy_r7_' . $this->token}($yysubmatches);
1493 $this->counter += strlen($this->value);
1494 $this->line += substr_count($this->value, "\n");
1495 // accept this token
1497 } elseif ($r === true) {
1498 // we have changed state
1499 // process this token in the new state
1500 return $this->yylex();
1501 } elseif ($r === false) {
1502 $this->counter += strlen($this->value);
1503 $this->line += substr_count($this->value, "\n");
1504 if ($this->counter >= strlen($this->data)) {
1505 return false; // end of input
1511 throw new Exception('Unexpected input at line' . $this->line .
1512 ': ' . $this->data[$this->counter]);
1518 const CHILDLITERAL = 7;
1520 function yy_r7_1($yy_subpatterns)
1523 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1524 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1526 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1527 $this->yypushstate(self::CHILDLITERAL);
1531 function yy_r7_2($yy_subpatterns)
1534 if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
1535 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1537 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
1538 $this->yypopstate();
1542 function yy_r7_3($yy_subpatterns)
1545 $to = strlen($this->data);
1546 preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
1547 if (isset($match[0][1])) {
1550 $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
1552 $this->value = substr($this->data, $this->counter, $to - $this->counter);
1553 $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;