3 * Smarty Internal Plugin Templatelexer
5 * This is the lexer to break the template source into tokens
11 * Smarty Internal Plugin Templatelexer
13 class Smarty_Internal_Templatelexer
23 public $strip = false;
24 private $heredoc_id_stack = Array();
25 public $smarty_token_names = array ( // Text for parser error messages
27 'NONEIDENTITY' => '!==',
30 'GREATEREQUAL' => '(>=,ge)',
31 'LESSEQUAL' => '(<=,le)',
32 'GREATERTHAN' => '(>,gt)',
33 'LESSTHAN' => '(<,lt)',
47 'UNIMATH' => '+" , "-',
48 'MATH' => '*" , "/" , "%',
49 'INCDEC' => '++" , "--',
54 'DOUBLECOLON' => '::',
66 'LINEBREAK' => 'newline',
67 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
68 'PHPSTARTTAG' => 'PHP start tag',
69 'PHPENDTAG' => 'PHP end tag',
70 'LITERALSTART' => 'Literal start',
71 'LITERALEND' => 'Literal end',
72 'LDELSLASH' => 'closing tag',
73 'COMMENT' => 'comment',
74 'LITERALEND' => 'literal close',
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->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
92 $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
96 private $_yy_state = 1;
97 private $_yy_stack = array();
101 return $this->{'yylex' . $this->_yy_state}();
104 function yypushstate($state)
106 array_push($this->_yy_stack, $this->_yy_state);
107 $this->_yy_state = $state;
110 function yypopstate()
112 $this->_yy_state = array_pop($this->_yy_stack);
115 function yybegin($state)
117 $this->_yy_state = $state;
149 if ($this->counter >= strlen($this->data)) {
150 return false; // end of input
152 $yy_global_pattern = "/^(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)|^(.)/iS";
155 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
156 $yysubmatches = $yymatches;
157 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
158 if (!count($yymatches)) {
159 throw new Exception('Error: lexing failed because a rule matched' .
160 'an empty string. Input "' . substr($this->data,
161 $this->counter, 5) . '... state TEXT');
163 next($yymatches); // skip global match
164 $this->token = key($yymatches); // token number
165 if ($tokenMap[$this->token]) {
166 // extract sub-patterns for passing to lex function
167 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
168 $tokenMap[$this->token]);
170 $yysubmatches = array();
172 $this->value = current($yymatches); // token value
173 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
175 $this->counter += strlen($this->value);
176 $this->line += substr_count($this->value, "\n");
179 } elseif ($r === true) {
180 // we have changed state
181 // process this token in the new state
182 return $this->yylex();
183 } elseif ($r === false) {
184 $this->counter += strlen($this->value);
185 $this->line += substr_count($this->value, "\n");
186 if ($this->counter >= strlen($this->data)) {
187 return false; // end of input
192 throw new Exception('Unexpected input at line' . $this->line .
193 ': ' . $this->data[$this->counter]);
202 function yy_r1_1($yy_subpatterns)
205 $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILD;
207 function yy_r1_2($yy_subpatterns)
210 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
212 function yy_r1_3($yy_subpatterns)
215 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
217 function yy_r1_5($yy_subpatterns)
223 $this->token = Smarty_Internal_Templateparser::TP_LINEBREAK;
226 function yy_r1_6($yy_subpatterns)
232 function yy_r1_7($yy_subpatterns)
235 if ($this->smarty->auto_literal) {
236 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
242 function yy_r1_8($yy_subpatterns)
245 $this->strip = false;
248 function yy_r1_9($yy_subpatterns)
251 if ($this->smarty->auto_literal) {
252 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
254 $this->strip = false;
258 function yy_r1_10($yy_subpatterns)
261 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
262 $this->yypushstate(self::LITERAL);
264 function yy_r1_11($yy_subpatterns)
267 if ($this->smarty->auto_literal) {
268 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
270 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
271 $this->yypushstate(self::SMARTY);
272 $this->taglineno = $this->line;
275 function yy_r1_12($yy_subpatterns)
278 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
279 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
281 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
282 $this->yypushstate(self::SMARTY);
283 $this->taglineno = $this->line;
286 function yy_r1_14($yy_subpatterns)
289 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
290 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
292 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
293 $this->yypushstate(self::SMARTY);
294 $this->taglineno = $this->line;
297 function yy_r1_15($yy_subpatterns)
300 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
301 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
303 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
304 $this->yypushstate(self::SMARTY);
305 $this->taglineno = $this->line;
308 function yy_r1_16($yy_subpatterns)
311 if ($this->smarty->auto_literal) {
312 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
314 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
315 $this->yypushstate(self::SMARTY);
316 $this->taglineno = $this->line;
319 function yy_r1_17($yy_subpatterns)
322 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
323 $this->yypushstate(self::SMARTY);
324 $this->taglineno = $this->line;
326 function yy_r1_18($yy_subpatterns)
329 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
330 $this->yypushstate(self::SMARTY);
331 $this->taglineno = $this->line;
333 function yy_r1_19($yy_subpatterns)
336 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
337 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
338 } elseif ($this->value == '<?xml') {
339 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
341 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
342 $this->value = substr($this->value, 0, 2);
345 function yy_r1_20($yy_subpatterns)
348 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
350 function yy_r1_21($yy_subpatterns)
353 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
355 function yy_r1_22($yy_subpatterns)
358 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
360 function yy_r1_23($yy_subpatterns)
363 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
365 function yy_r1_26($yy_subpatterns)
368 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
370 function yy_r1_27($yy_subpatterns)
373 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
448 if ($this->counter >= strlen($this->data)) {
449 return false; // end of input
451 $yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+as\\s+)|^(\\s+to\\s+)|^(\\s+step\\s+)|^(\\s+instanceof\\s+)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+eq\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(le|lte)\\s+)|^(\\s*>\\s*|\\s+gt\\s+)|^(\\s*<\\s*|\\s+lt\\s+)|^(\\s+mod\\s+)|^(!\\s*|not\\s+)|^(\\s*&&\\s*|\\s*and\\s+)|^(\\s*\\|\\|\\s*|\\s*or\\s+)|^(\\s*xor\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\+\\+|--)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^(0[xX][0-9a-fA-F]+)|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/iS";
454 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
455 $yysubmatches = $yymatches;
456 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
457 if (!count($yymatches)) {
458 throw new Exception('Error: lexing failed because a rule matched' .
459 'an empty string. Input "' . substr($this->data,
460 $this->counter, 5) . '... state SMARTY');
462 next($yymatches); // skip global match
463 $this->token = key($yymatches); // token number
464 if ($tokenMap[$this->token]) {
465 // extract sub-patterns for passing to lex function
466 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
467 $tokenMap[$this->token]);
469 $yysubmatches = array();
471 $this->value = current($yymatches); // token value
472 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
474 $this->counter += strlen($this->value);
475 $this->line += substr_count($this->value, "\n");
478 } elseif ($r === true) {
479 // we have changed state
480 // process this token in the new state
481 return $this->yylex();
482 } elseif ($r === false) {
483 $this->counter += strlen($this->value);
484 $this->line += substr_count($this->value, "\n");
485 if ($this->counter >= strlen($this->data)) {
486 return false; // end of input
491 throw new Exception('Unexpected input at line' . $this->line .
492 ': ' . $this->data[$this->counter]);
501 function yy_r2_1($yy_subpatterns)
504 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
506 function yy_r2_2($yy_subpatterns)
509 if ($this->smarty->auto_literal) {
510 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
512 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
513 $this->yypushstate(self::SMARTY);
514 $this->taglineno = $this->line;
517 function yy_r2_3($yy_subpatterns)
520 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
521 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
523 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
524 $this->yypushstate(self::SMARTY);
525 $this->taglineno = $this->line;
528 function yy_r2_5($yy_subpatterns)
531 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
532 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
534 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
535 $this->yypushstate(self::SMARTY);
536 $this->taglineno = $this->line;
539 function yy_r2_6($yy_subpatterns)
542 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
543 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
545 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
546 $this->yypushstate(self::SMARTY);
547 $this->taglineno = $this->line;
550 function yy_r2_7($yy_subpatterns)
553 if ($this->smarty->auto_literal) {
554 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
556 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
557 $this->yypushstate(self::SMARTY);
558 $this->taglineno = $this->line;
561 function yy_r2_8($yy_subpatterns)
564 if ($this->smarty->auto_literal) {
565 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
567 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
571 function yy_r2_9($yy_subpatterns)
574 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
575 $this->yypushstate(self::SMARTY);
576 $this->taglineno = $this->line;
578 function yy_r2_10($yy_subpatterns)
581 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
582 $this->yypushstate(self::SMARTY);
583 $this->taglineno = $this->line;
585 function yy_r2_11($yy_subpatterns)
588 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
591 function yy_r2_12($yy_subpatterns)
594 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
596 function yy_r2_13($yy_subpatterns)
599 $this->token = Smarty_Internal_Templateparser::TP_AS;
601 function yy_r2_14($yy_subpatterns)
604 $this->token = Smarty_Internal_Templateparser::TP_TO;
606 function yy_r2_15($yy_subpatterns)
609 $this->token = Smarty_Internal_Templateparser::TP_STEP;
611 function yy_r2_16($yy_subpatterns)
614 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
616 function yy_r2_17($yy_subpatterns)
619 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
621 function yy_r2_18($yy_subpatterns)
624 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
626 function yy_r2_19($yy_subpatterns)
629 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
631 function yy_r2_20($yy_subpatterns)
634 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
636 function yy_r2_22($yy_subpatterns)
639 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
641 function yy_r2_24($yy_subpatterns)
644 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
646 function yy_r2_26($yy_subpatterns)
649 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
651 function yy_r2_27($yy_subpatterns)
654 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
656 function yy_r2_28($yy_subpatterns)
659 $this->token = Smarty_Internal_Templateparser::TP_MOD;
661 function yy_r2_29($yy_subpatterns)
664 $this->token = Smarty_Internal_Templateparser::TP_NOT;
666 function yy_r2_30($yy_subpatterns)
669 $this->token = Smarty_Internal_Templateparser::TP_LAND;
671 function yy_r2_31($yy_subpatterns)
674 $this->token = Smarty_Internal_Templateparser::TP_LOR;
676 function yy_r2_32($yy_subpatterns)
679 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
681 function yy_r2_33($yy_subpatterns)
684 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
686 function yy_r2_34($yy_subpatterns)
689 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
691 function yy_r2_35($yy_subpatterns)
694 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
696 function yy_r2_36($yy_subpatterns)
699 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
701 function yy_r2_37($yy_subpatterns)
704 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
706 function yy_r2_38($yy_subpatterns)
709 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
711 function yy_r2_39($yy_subpatterns)
714 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
716 function yy_r2_40($yy_subpatterns)
719 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
721 function yy_r2_41($yy_subpatterns)
724 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
726 function yy_r2_42($yy_subpatterns)
729 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
731 function yy_r2_43($yy_subpatterns)
734 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
736 function yy_r2_47($yy_subpatterns)
739 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
741 function yy_r2_48($yy_subpatterns)
744 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
746 function yy_r2_49($yy_subpatterns)
749 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
751 function yy_r2_50($yy_subpatterns)
754 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
756 function yy_r2_51($yy_subpatterns)
759 $this->token = Smarty_Internal_Templateparser::TP_PTR;
761 function yy_r2_52($yy_subpatterns)
764 $this->token = Smarty_Internal_Templateparser::TP_APTR;
766 function yy_r2_53($yy_subpatterns)
769 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
771 function yy_r2_54($yy_subpatterns)
774 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
776 function yy_r2_55($yy_subpatterns)
779 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
781 function yy_r2_57($yy_subpatterns)
784 $this->token = Smarty_Internal_Templateparser::TP_MATH;
786 function yy_r2_59($yy_subpatterns)
789 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
791 function yy_r2_60($yy_subpatterns)
794 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
796 function yy_r2_61($yy_subpatterns)
799 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
801 function yy_r2_62($yy_subpatterns)
804 $this->token = Smarty_Internal_Templateparser::TP_COLON;
806 function yy_r2_63($yy_subpatterns)
809 $this->token = Smarty_Internal_Templateparser::TP_AT;
811 function yy_r2_64($yy_subpatterns)
814 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
816 function yy_r2_65($yy_subpatterns)
819 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
820 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
822 function yy_r2_66($yy_subpatterns)
825 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
828 function yy_r2_67($yy_subpatterns)
831 $this->token = Smarty_Internal_Templateparser::TP_VERT;
833 function yy_r2_68($yy_subpatterns)
836 $this->token = Smarty_Internal_Templateparser::TP_DOT;
838 function yy_r2_69($yy_subpatterns)
841 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
843 function yy_r2_70($yy_subpatterns)
846 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
848 function yy_r2_71($yy_subpatterns)
851 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
853 function yy_r2_72($yy_subpatterns)
856 $this->token = Smarty_Internal_Templateparser::TP_HEX;
858 function yy_r2_73($yy_subpatterns)
861 $this->token = Smarty_Internal_Templateparser::TP_ID;
863 function yy_r2_74($yy_subpatterns)
866 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
868 function yy_r2_75($yy_subpatterns)
871 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
873 function yy_r2_76($yy_subpatterns)
876 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
894 if ($this->counter >= strlen($this->data)) {
895 return false; // end of input
897 $yy_global_pattern = "/^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^(.)/iS";
900 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
901 $yysubmatches = $yymatches;
902 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
903 if (!count($yymatches)) {
904 throw new Exception('Error: lexing failed because a rule matched' .
905 'an empty string. Input "' . substr($this->data,
906 $this->counter, 5) . '... state LITERAL');
908 next($yymatches); // skip global match
909 $this->token = key($yymatches); // token number
910 if ($tokenMap[$this->token]) {
911 // extract sub-patterns for passing to lex function
912 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
913 $tokenMap[$this->token]);
915 $yysubmatches = array();
917 $this->value = current($yymatches); // token value
918 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
920 $this->counter += strlen($this->value);
921 $this->line += substr_count($this->value, "\n");
924 } elseif ($r === true) {
925 // we have changed state
926 // process this token in the new state
927 return $this->yylex();
928 } elseif ($r === false) {
929 $this->counter += strlen($this->value);
930 $this->line += substr_count($this->value, "\n");
931 if ($this->counter >= strlen($this->data)) {
932 return false; // end of input
937 throw new Exception('Unexpected input at line' . $this->line .
938 ': ' . $this->data[$this->counter]);
947 function yy_r3_1($yy_subpatterns)
950 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
951 $this->yypushstate(self::LITERAL);
953 function yy_r3_2($yy_subpatterns)
956 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
959 function yy_r3_3($yy_subpatterns)
962 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
964 function yy_r3_4($yy_subpatterns)
967 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
968 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
970 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
971 $this->value = substr($this->value, 0, 2);
974 function yy_r3_5($yy_subpatterns)
977 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
979 function yy_r3_6($yy_subpatterns)
982 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
984 function yy_r3_7($yy_subpatterns)
987 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
989 function yy_r3_8($yy_subpatterns)
992 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
994 function yy_r3_11($yy_subpatterns)
997 $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
1019 if ($this->counter >= strlen($this->data)) {
1020 return false; // end of input
1022 $yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)|^(.)/iS";
1025 if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
1026 $yysubmatches = $yymatches;
1027 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1028 if (!count($yymatches)) {
1029 throw new Exception('Error: lexing failed because a rule matched' .
1030 'an empty string. Input "' . substr($this->data,
1031 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1033 next($yymatches); // skip global match
1034 $this->token = key($yymatches); // token number
1035 if ($tokenMap[$this->token]) {
1036 // extract sub-patterns for passing to lex function
1037 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1038 $tokenMap[$this->token]);
1040 $yysubmatches = array();
1042 $this->value = current($yymatches); // token value
1043 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1045 $this->counter += strlen($this->value);
1046 $this->line += substr_count($this->value, "\n");
1047 // accept this token
1049 } elseif ($r === true) {
1050 // we have changed state
1051 // process this token in the new state
1052 return $this->yylex();
1053 } elseif ($r === false) {
1054 $this->counter += strlen($this->value);
1055 $this->line += substr_count($this->value, "\n");
1056 if ($this->counter >= strlen($this->data)) {
1057 return false; // end of input
1062 throw new Exception('Unexpected input at line' . $this->line .
1063 ': ' . $this->data[$this->counter]);
1071 const DOUBLEQUOTEDSTRING = 4;
1072 function yy_r4_1($yy_subpatterns)
1075 if ($this->smarty->auto_literal) {
1076 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1078 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1079 $this->yypushstate(self::SMARTY);
1080 $this->taglineno = $this->line;
1083 function yy_r4_2($yy_subpatterns)
1086 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1087 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1089 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
1090 $this->yypushstate(self::SMARTY);
1091 $this->taglineno = $this->line;
1094 function yy_r4_4($yy_subpatterns)
1097 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1098 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1100 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
1101 $this->yypushstate(self::SMARTY);
1102 $this->taglineno = $this->line;
1105 function yy_r4_5($yy_subpatterns)
1108 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1109 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1111 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
1112 $this->yypushstate(self::SMARTY);
1113 $this->taglineno = $this->line;
1116 function yy_r4_6($yy_subpatterns)
1119 if ($this->smarty->auto_literal) {
1120 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1122 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1123 $this->yypushstate(self::SMARTY);
1124 $this->taglineno = $this->line;
1127 function yy_r4_7($yy_subpatterns)
1130 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1131 $this->yypushstate(self::SMARTY);
1132 $this->taglineno = $this->line;
1134 function yy_r4_8($yy_subpatterns)
1137 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1138 $this->yypushstate(self::SMARTY);
1139 $this->taglineno = $this->line;
1141 function yy_r4_9($yy_subpatterns)
1144 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1145 $this->yypopstate();
1147 function yy_r4_10($yy_subpatterns)
1150 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1151 $this->value = substr($this->value,0,-1);
1152 $this->yypushstate(self::SMARTY);
1153 $this->taglineno = $this->line;
1155 function yy_r4_11($yy_subpatterns)
1158 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1160 function yy_r4_12($yy_subpatterns)
1163 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1165 function yy_r4_13($yy_subpatterns)
1168 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1170 function yy_r4_17($yy_subpatterns)
1173 $this->token = Smarty_Internal_Templateparser::TP_OTHER;
1175 function yy_r4_18($yy_subpatterns)
1178 $this->token = Smarty_Internal_Templateparser::TP_OTHER;