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 private $heredoc_id_stack = Array();
24 public $smarty_token_names = array ( // Text for parser error messages
26 'NONEIDENTITY' => '!==',
29 'GREATEREQUAL' => '(>=,ge)',
30 'LESSEQUAL' => '(<=,le)',
31 'GREATERTHAN' => '(>,gt)',
32 'LESSTHAN' => '(<,lt)',
46 'UNIMATH' => '+" , "-',
47 'MATH' => '*" , "/" , "%',
48 'INCDEC' => '++" , "--',
53 'DOUBLECOLON' => '::',
65 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
66 'PHPSTARTTAG' => 'PHP start tag',
67 'PHPENDTAG' => 'PHP end tag',
68 'LITERALSTART' => 'Literal start',
69 'LITERALEND' => 'Literal end',
70 'LDELSLASH' => 'closing tag',
71 'COMMENT' => 'comment',
77 function __construct($data,$compiler)
79 // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
83 $this->smarty = $compiler->smarty;
84 $this->compiler = $compiler;
85 $this->ldel = preg_quote($this->smarty->left_delimiter,'/');
86 $this->ldel_length = strlen($this->smarty->left_delimiter);
87 $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
88 $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
89 $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
90 $this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
94 private $_yy_state = 1;
95 private $_yy_stack = array();
99 return $this->{'yylex' . $this->_yy_state}();
102 function yypushstate($state)
104 array_push($this->_yy_stack, $this->_yy_state);
105 $this->_yy_state = $state;
108 function yypopstate()
110 $this->_yy_state = array_pop($this->_yy_stack);
113 function yybegin($state)
115 $this->_yy_state = $state;
145 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
146 return false; // end of input
148 $yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
151 if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
152 $yysubmatches = $yymatches;
153 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
154 if (!count($yymatches)) {
155 throw new Exception('Error: lexing failed because a rule matched' .
156 ' an empty string. Input "' . substr($this->data,
157 $this->counter, 5) . '... state TEXT');
159 next($yymatches); // skip global match
160 $this->token = key($yymatches); // token number
161 if ($tokenMap[$this->token]) {
162 // extract sub-patterns for passing to lex function
163 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
164 $tokenMap[$this->token]);
166 $yysubmatches = array();
168 $this->value = current($yymatches); // token value
169 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
171 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
172 $this->line += substr_count($this->value, "\n");
175 } elseif ($r === true) {
176 // we have changed state
177 // process this token in the new state
178 return $this->yylex();
179 } elseif ($r === false) {
180 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
181 $this->line += substr_count($this->value, "\n");
182 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
183 return false; // end of input
188 throw new Exception('Unexpected input at line' . $this->line .
189 ': ' . $this->data[$this->counter]);
198 function yy_r1_1($yy_subpatterns)
201 $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILD;
203 function yy_r1_2($yy_subpatterns)
206 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
208 function yy_r1_3($yy_subpatterns)
211 $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
213 function yy_r1_5($yy_subpatterns)
216 $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
218 function yy_r1_6($yy_subpatterns)
221 if ($this->smarty->auto_literal) {
222 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
224 $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
227 function yy_r1_7($yy_subpatterns)
230 $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
232 function yy_r1_8($yy_subpatterns)
235 if ($this->smarty->auto_literal) {
236 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
238 $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
241 function yy_r1_9($yy_subpatterns)
244 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
245 $this->yypushstate(self::LITERAL);
247 function yy_r1_10($yy_subpatterns)
250 if ($this->smarty->auto_literal) {
251 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
253 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
254 $this->yypushstate(self::SMARTY);
255 $this->taglineno = $this->line;
258 function yy_r1_11($yy_subpatterns)
261 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
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;
269 function yy_r1_13($yy_subpatterns)
272 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
273 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
275 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
276 $this->yypushstate(self::SMARTY);
277 $this->taglineno = $this->line;
280 function yy_r1_14($yy_subpatterns)
283 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
284 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
286 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
287 $this->yypushstate(self::SMARTY);
288 $this->taglineno = $this->line;
291 function yy_r1_15($yy_subpatterns)
294 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
295 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
297 $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
298 $this->yypushstate(self::SMARTY);
299 $this->taglineno = $this->line;
302 function yy_r1_16($yy_subpatterns)
305 if ($this->smarty->auto_literal) {
306 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
308 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
309 $this->yypushstate(self::SMARTY);
310 $this->taglineno = $this->line;
313 function yy_r1_17($yy_subpatterns)
316 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
317 $this->yypushstate(self::SMARTY);
318 $this->taglineno = $this->line;
320 function yy_r1_18($yy_subpatterns)
323 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
324 $this->yypushstate(self::SMARTY);
325 $this->taglineno = $this->line;
327 function yy_r1_19($yy_subpatterns)
330 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
331 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
332 } elseif ($this->value == '<?xml') {
333 $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
335 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
336 $this->value = substr($this->value, 0, 2);
339 function yy_r1_20($yy_subpatterns)
342 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
344 function yy_r1_21($yy_subpatterns)
347 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
349 function yy_r1_22($yy_subpatterns)
352 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
354 function yy_r1_23($yy_subpatterns)
357 if ($this->mbstring_overload) {
358 $to = mb_strlen($this->data,'latin1');
360 $to = strlen($this->data);
362 preg_match("/{$this->ldel}|<\?|\?>|<%|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
363 if (isset($match[0][1])) {
366 if ($this->mbstring_overload) {
367 $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
369 $this->value = substr($this->data,$this->counter,$to-$this->counter);
371 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
447 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
448 return false; // end of input
450 $yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$this->rdel.")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s?=\\s?)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G([\S\s])/iS";
453 if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
454 $yysubmatches = $yymatches;
455 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
456 if (!count($yymatches)) {
457 throw new Exception('Error: lexing failed because a rule matched' .
458 ' an empty string. Input "' . substr($this->data,
459 $this->counter, 5) . '... state SMARTY');
461 next($yymatches); // skip global match
462 $this->token = key($yymatches); // token number
463 if ($tokenMap[$this->token]) {
464 // extract sub-patterns for passing to lex function
465 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
466 $tokenMap[$this->token]);
468 $yysubmatches = array();
470 $this->value = current($yymatches); // token value
471 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
473 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
474 $this->line += substr_count($this->value, "\n");
477 } elseif ($r === true) {
478 // we have changed state
479 // process this token in the new state
480 return $this->yylex();
481 } elseif ($r === false) {
482 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
483 $this->line += substr_count($this->value, "\n");
484 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
485 return false; // end of input
490 throw new Exception('Unexpected input at line' . $this->line .
491 ': ' . $this->data[$this->counter]);
500 function yy_r2_1($yy_subpatterns)
503 $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
505 function yy_r2_2($yy_subpatterns)
508 if ($this->smarty->auto_literal) {
509 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
511 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
512 $this->yypushstate(self::SMARTY);
513 $this->taglineno = $this->line;
516 function yy_r2_3($yy_subpatterns)
519 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
520 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
522 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
523 $this->yypushstate(self::SMARTY);
524 $this->taglineno = $this->line;
527 function yy_r2_5($yy_subpatterns)
530 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
531 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
533 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
534 $this->yypushstate(self::SMARTY);
535 $this->taglineno = $this->line;
538 function yy_r2_6($yy_subpatterns)
541 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
542 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
544 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
545 $this->yypushstate(self::SMARTY);
546 $this->taglineno = $this->line;
549 function yy_r2_7($yy_subpatterns)
552 if ($this->smarty->auto_literal) {
553 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
555 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
556 $this->yypushstate(self::SMARTY);
557 $this->taglineno = $this->line;
560 function yy_r2_8($yy_subpatterns)
563 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
566 function yy_r2_9($yy_subpatterns)
569 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
570 $this->yypushstate(self::SMARTY);
571 $this->taglineno = $this->line;
573 function yy_r2_10($yy_subpatterns)
576 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
577 $this->yypushstate(self::SMARTY);
578 $this->taglineno = $this->line;
580 function yy_r2_11($yy_subpatterns)
583 $this->token = Smarty_Internal_Templateparser::TP_RDEL;
586 function yy_r2_12($yy_subpatterns)
589 $this->token = Smarty_Internal_Templateparser::TP_ISIN;
591 function yy_r2_13($yy_subpatterns)
594 $this->token = Smarty_Internal_Templateparser::TP_AS;
596 function yy_r2_14($yy_subpatterns)
599 $this->token = Smarty_Internal_Templateparser::TP_TO;
601 function yy_r2_15($yy_subpatterns)
604 $this->token = Smarty_Internal_Templateparser::TP_STEP;
606 function yy_r2_16($yy_subpatterns)
609 $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
611 function yy_r2_17($yy_subpatterns)
614 $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
616 function yy_r2_18($yy_subpatterns)
619 $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
621 function yy_r2_19($yy_subpatterns)
624 $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
626 function yy_r2_20($yy_subpatterns)
629 $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
631 function yy_r2_22($yy_subpatterns)
634 $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
636 function yy_r2_24($yy_subpatterns)
639 $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
641 function yy_r2_26($yy_subpatterns)
644 $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
646 function yy_r2_27($yy_subpatterns)
649 $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
651 function yy_r2_28($yy_subpatterns)
654 $this->token = Smarty_Internal_Templateparser::TP_MOD;
656 function yy_r2_29($yy_subpatterns)
659 $this->token = Smarty_Internal_Templateparser::TP_NOT;
661 function yy_r2_30($yy_subpatterns)
664 $this->token = Smarty_Internal_Templateparser::TP_LAND;
666 function yy_r2_31($yy_subpatterns)
669 $this->token = Smarty_Internal_Templateparser::TP_LOR;
671 function yy_r2_32($yy_subpatterns)
674 $this->token = Smarty_Internal_Templateparser::TP_LXOR;
676 function yy_r2_33($yy_subpatterns)
679 $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
681 function yy_r2_34($yy_subpatterns)
684 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
686 function yy_r2_35($yy_subpatterns)
689 $this->token = Smarty_Internal_Templateparser::TP_ISODD;
691 function yy_r2_36($yy_subpatterns)
694 $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
696 function yy_r2_37($yy_subpatterns)
699 $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
701 function yy_r2_38($yy_subpatterns)
704 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
706 function yy_r2_39($yy_subpatterns)
709 $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
711 function yy_r2_40($yy_subpatterns)
714 $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
716 function yy_r2_41($yy_subpatterns)
719 $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
721 function yy_r2_42($yy_subpatterns)
724 $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
726 function yy_r2_43($yy_subpatterns)
729 $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
731 function yy_r2_47($yy_subpatterns)
734 $this->token = Smarty_Internal_Templateparser::TP_OPENP;
736 function yy_r2_48($yy_subpatterns)
739 $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
741 function yy_r2_49($yy_subpatterns)
744 $this->token = Smarty_Internal_Templateparser::TP_OPENB;
746 function yy_r2_50($yy_subpatterns)
749 $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
751 function yy_r2_51($yy_subpatterns)
754 $this->token = Smarty_Internal_Templateparser::TP_PTR;
756 function yy_r2_52($yy_subpatterns)
759 $this->token = Smarty_Internal_Templateparser::TP_APTR;
761 function yy_r2_53($yy_subpatterns)
764 $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
766 function yy_r2_54($yy_subpatterns)
769 $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
771 function yy_r2_55($yy_subpatterns)
774 $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
776 function yy_r2_57($yy_subpatterns)
779 $this->token = Smarty_Internal_Templateparser::TP_MATH;
781 function yy_r2_59($yy_subpatterns)
784 $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
786 function yy_r2_60($yy_subpatterns)
789 $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
791 function yy_r2_61($yy_subpatterns)
794 $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
796 function yy_r2_62($yy_subpatterns)
799 $this->token = Smarty_Internal_Templateparser::TP_COLON;
801 function yy_r2_63($yy_subpatterns)
804 $this->token = Smarty_Internal_Templateparser::TP_AT;
806 function yy_r2_64($yy_subpatterns)
809 $this->token = Smarty_Internal_Templateparser::TP_HATCH;
811 function yy_r2_65($yy_subpatterns)
814 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
815 $this->yypushstate(self::DOUBLEQUOTEDSTRING);
817 function yy_r2_66($yy_subpatterns)
820 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
823 function yy_r2_67($yy_subpatterns)
826 $this->token = Smarty_Internal_Templateparser::TP_VERT;
828 function yy_r2_68($yy_subpatterns)
831 $this->token = Smarty_Internal_Templateparser::TP_DOT;
833 function yy_r2_69($yy_subpatterns)
836 $this->token = Smarty_Internal_Templateparser::TP_COMMA;
838 function yy_r2_70($yy_subpatterns)
841 $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
843 function yy_r2_71($yy_subpatterns)
846 $this->token = Smarty_Internal_Templateparser::TP_QMARK;
848 function yy_r2_72($yy_subpatterns)
851 $this->token = Smarty_Internal_Templateparser::TP_HEX;
853 function yy_r2_73($yy_subpatterns)
856 $this->token = Smarty_Internal_Templateparser::TP_ATTR;
858 function yy_r2_74($yy_subpatterns)
861 $this->token = Smarty_Internal_Templateparser::TP_ID;
863 function yy_r2_75($yy_subpatterns)
866 $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
868 function yy_r2_76($yy_subpatterns)
871 $this->token = Smarty_Internal_Templateparser::TP_SPACE;
873 function yy_r2_77($yy_subpatterns)
876 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
892 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
893 return false; // end of input
895 $yy_global_pattern = "/\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
898 if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
899 $yysubmatches = $yymatches;
900 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
901 if (!count($yymatches)) {
902 throw new Exception('Error: lexing failed because a rule matched' .
903 ' an empty string. Input "' . substr($this->data,
904 $this->counter, 5) . '... state LITERAL');
906 next($yymatches); // skip global match
907 $this->token = key($yymatches); // token number
908 if ($tokenMap[$this->token]) {
909 // extract sub-patterns for passing to lex function
910 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
911 $tokenMap[$this->token]);
913 $yysubmatches = array();
915 $this->value = current($yymatches); // token value
916 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
918 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
919 $this->line += substr_count($this->value, "\n");
922 } elseif ($r === true) {
923 // we have changed state
924 // process this token in the new state
925 return $this->yylex();
926 } elseif ($r === false) {
927 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
928 $this->line += substr_count($this->value, "\n");
929 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
930 return false; // end of input
935 throw new Exception('Unexpected input at line' . $this->line .
936 ': ' . $this->data[$this->counter]);
945 function yy_r3_1($yy_subpatterns)
948 $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
949 $this->yypushstate(self::LITERAL);
951 function yy_r3_2($yy_subpatterns)
954 $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
957 function yy_r3_3($yy_subpatterns)
960 if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
961 $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
963 $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
964 $this->value = substr($this->value, 0, 2);
967 function yy_r3_4($yy_subpatterns)
970 $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
972 function yy_r3_5($yy_subpatterns)
975 $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
977 function yy_r3_6($yy_subpatterns)
980 $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
982 function yy_r3_7($yy_subpatterns)
985 if ($this->mbstring_overload) {
986 $to = mb_strlen($this->data,'latin1');
988 $to = strlen($this->data);
990 preg_match("/{$this->ldel}\/?literal{$this->rdel}|<\?|<%|\?>|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
991 if (isset($match[0][1])) {
994 $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
996 if ($this->mbstring_overload) {
997 $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
999 $this->value = substr($this->data,$this->counter,$to-$this->counter);
1001 $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
1022 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
1023 return false; // end of input
1025 $yy_global_pattern = "/\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|\G([\S\s])/iS";
1028 if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
1029 $yysubmatches = $yymatches;
1030 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1031 if (!count($yymatches)) {
1032 throw new Exception('Error: lexing failed because a rule matched' .
1033 ' an empty string. Input "' . substr($this->data,
1034 $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1036 next($yymatches); // skip global match
1037 $this->token = key($yymatches); // token number
1038 if ($tokenMap[$this->token]) {
1039 // extract sub-patterns for passing to lex function
1040 $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1041 $tokenMap[$this->token]);
1043 $yysubmatches = array();
1045 $this->value = current($yymatches); // token value
1046 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1048 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1049 $this->line += substr_count($this->value, "\n");
1050 // accept this token
1052 } elseif ($r === true) {
1053 // we have changed state
1054 // process this token in the new state
1055 return $this->yylex();
1056 } elseif ($r === false) {
1057 $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1058 $this->line += substr_count($this->value, "\n");
1059 if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
1060 return false; // end of input
1065 throw new Exception('Unexpected input at line' . $this->line .
1066 ': ' . $this->data[$this->counter]);
1074 const DOUBLEQUOTEDSTRING = 4;
1075 function yy_r4_1($yy_subpatterns)
1078 if ($this->smarty->auto_literal) {
1079 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1081 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1082 $this->yypushstate(self::SMARTY);
1083 $this->taglineno = $this->line;
1086 function yy_r4_2($yy_subpatterns)
1089 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1090 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1092 $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
1093 $this->yypushstate(self::SMARTY);
1094 $this->taglineno = $this->line;
1097 function yy_r4_4($yy_subpatterns)
1100 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1101 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1103 $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
1104 $this->yypushstate(self::SMARTY);
1105 $this->taglineno = $this->line;
1108 function yy_r4_5($yy_subpatterns)
1111 if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1112 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1114 $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
1115 $this->yypushstate(self::SMARTY);
1116 $this->taglineno = $this->line;
1119 function yy_r4_6($yy_subpatterns)
1122 if ($this->smarty->auto_literal) {
1123 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1125 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1126 $this->yypushstate(self::SMARTY);
1127 $this->taglineno = $this->line;
1130 function yy_r4_7($yy_subpatterns)
1133 $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
1134 $this->yypushstate(self::SMARTY);
1135 $this->taglineno = $this->line;
1137 function yy_r4_8($yy_subpatterns)
1140 $this->token = Smarty_Internal_Templateparser::TP_LDEL;
1141 $this->yypushstate(self::SMARTY);
1142 $this->taglineno = $this->line;
1144 function yy_r4_9($yy_subpatterns)
1147 $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
1148 $this->yypopstate();
1150 function yy_r4_10($yy_subpatterns)
1153 $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
1154 $this->value = substr($this->value,0,-1);
1155 $this->yypushstate(self::SMARTY);
1156 $this->taglineno = $this->line;
1158 function yy_r4_11($yy_subpatterns)
1161 $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
1163 function yy_r4_12($yy_subpatterns)
1166 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1168 function yy_r4_13($yy_subpatterns)
1171 $this->token = Smarty_Internal_Templateparser::TP_TEXT;
1173 function yy_r4_17($yy_subpatterns)
1176 if ($this->mbstring_overload) {
1177 $to = mb_strlen($this->data,'latin1');
1179 $to = strlen($this->data);
1181 if ($this->mbstring_overload) {
1182 $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
1184 $this->value = substr($this->data,$this->counter,$to-$this->counter);
1186 $this->token = Smarty_Internal_Templateparser::TP_TEXT;