diff options
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php | 1206 |
1 files changed, 511 insertions, 695 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php b/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php index 4de8a9c06..abf81d087 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php @@ -9,91 +9,212 @@ */ /** - * Smarty Internal Plugin Templatelexer + * Smarty_Internal_Templatelexer + * This is the template file lexer. + * It is generated from the smarty_internal_templatelexer.plex file + * + * @package Smarty + * @subpackage Compiler + * @author Uwe Tews */ class Smarty_Internal_Templatelexer { + /** + * Source + * + * @var string + */ public $data; + + /** + * byte counter + * + * @var int + */ public $counter; + + /** + * token number + * + * @var int + */ public $token; + + /** + * token value + * + * @var string + */ public $value; - public $node; + + /** + * current line + * + * @var int + */ public $line; + + /** + * tag start line + * + * @var + */ public $taglineno; - public $is_phpScript = false; + + /** + * php code type + * + * @var string + */ + public $phpType = ''; + + /** + * escaped left delimiter + * + * @var string + */ + public $ldel = ''; + + /** + * escaped left delimiter length + * + * @var int + */ + public $ldel_length = 0; + + /** + * escaped right delimiter + * + * @var string + */ + public $rdel = ''; + + /** + * escaped right delimiter length + * + * @var int + */ + public $rdel_length = 0; + + /** + * state number + * + * @var int + */ public $state = 1; - public $smarty; - public $literal_cnt = 0; - private $heredoc_id_stack = Array(); + + /** + * Smarty object + * + * @var Smarty + */ + public $smarty = null; + + /** + * compiler object + * + * @var Smarty_Internal_TemplateCompilerBase + */ + public $compiler = null; + + /** + * literal tag nesting level + * + * @var int + */ + private $literal_cnt = 0; + + /** + * PHP start tag string + * + * @var string + */ + + /** + * trace file + * + * @var resource + */ public $yyTraceFILE; + + /** + * trace prompt + * + * @var string + */ public $yyTracePrompt; - public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY'); + + /** + * XML flag true while processing xml + * + * @var bool + */ + public $is_xml = false; + + /** + * state names + * + * @var array + */ + public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING', + 6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL'); + + /** + * storage for assembled token patterns + * + * @var string + */ + private $yy_global_pattern1 = null; + + private $yy_global_pattern2 = null; + + private $yy_global_pattern3 = null; + + private $yy_global_pattern4 = null; + + private $yy_global_pattern5 = null; + + private $yy_global_pattern6 = null; + + private $yy_global_pattern7 = null; + + private $yy_global_pattern8 = null; + + /** + * token names + * + * @var array + */ public $smarty_token_names = array( // Text for parser error messages - 'IDENTITY' => '===', - 'NONEIDENTITY' => '!==', - 'EQUALS' => '==', - 'NOTEQUALS' => '!=', - 'GREATEREQUAL' => '(>=,ge)', - 'LESSEQUAL' => '(<=,le)', - 'GREATERTHAN' => '(>,gt)', - 'LESSTHAN' => '(<,lt)', - 'MOD' => '(%,mod)', - 'NOT' => '(!,not)', - 'LAND' => '(&&,and)', - 'LOR' => '(||,or)', - 'LXOR' => 'xor', - 'OPENP' => '(', - 'CLOSEP' => ')', - 'OPENB' => '[', - 'CLOSEB' => ']', - 'PTR' => '->', - 'APTR' => '=>', - 'EQUAL' => '=', - 'NUMBER' => 'number', - 'UNIMATH' => '+" , "-', - 'MATH' => '*" , "/" , "%', - 'INCDEC' => '++" , "--', - 'SPACE' => ' ', - 'DOLLAR' => '$', - 'SEMICOLON' => ';', - 'COLON' => ':', - 'DOUBLECOLON' => '::', - 'AT' => '@', - 'HATCH' => '#', - 'QUOTE' => '"', - 'BACKTICK' => '`', - 'VERT' => '|', - 'DOT' => '.', - 'COMMA' => '","', - 'ANDSYM' => '"&"', - 'QMARK' => '"?"', - 'ID' => 'identifier', - 'TEXT' => 'text', - 'FAKEPHPSTARTTAG' => 'Fake PHP start tag', - 'PHPSTARTTAG' => 'PHP start tag', - 'PHPENDTAG' => 'PHP end tag', - 'LITERALSTART' => 'Literal start', - 'LITERALEND' => 'Literal end', - 'LDELSLASH' => 'closing tag', - 'COMMENT' => 'comment', - 'AS' => 'as', - 'TO' => 'to', - ); - - function __construct($data, $compiler) - { - // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data); + 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', 'CLOSEB' => ']', 'PTR' => '->', + 'APTR' => '=>', 'EQUAL' => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%', + 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';', 'COLON' => ':', + 'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier', + 'DOT' => '.', 'COMMA' => '","', 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text', + 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', 'COMMENT' => 'comment', 'AS' => 'as', + 'TO' => 'to', 'PHP' => '"<?php", "<%", "{php}" tag', 'LOGOP' => '"<", "==" ... logical operator', + 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', + 'SCOND' => '"is even" ... if condition',); + + /** + * constructor + * + * @param string $data template source + * @param Smarty_Internal_TemplateCompilerBase $compiler + */ + function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler) + { $this->data = $data; $this->counter = 0; - if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) { + if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) { $this->counter += strlen($match[0]); } $this->line = 1; $this->smarty = $compiler->smarty; $this->compiler = $compiler; - $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); + $this->ldel = preg_quote($this->smarty->left_delimiter, '~'); $this->ldel_length = strlen($this->smarty->left_delimiter); - $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); + $this->rdel = preg_quote($this->smarty->right_delimiter, '~'); $this->rdel_length = strlen($this->smarty->right_delimiter); $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; @@ -105,7 +226,16 @@ class Smarty_Internal_Templatelexer $this->yyTracePrompt = '<br>'; } + /* + * Check if this tag is autoliteral + */ + public function isAutoLiteral() + { + return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false; + } + private $_yy_state = 1; + private $_yy_stack = array(); public function yylex() @@ -146,51 +276,28 @@ class Smarty_Internal_Templatelexer public function yylex1() { - $tokenMap = array( - 1 => 0, - 2 => 1, - 4 => 0, - 5 => 0, - 6 => 0, - 7 => 1, - 9 => 0, - 10 => 0, - 11 => 0, - 12 => 0, - 13 => 0, - 14 => 2, - 17 => 0, - 18 => 0, - 19 => 0, - 20 => 0, - 21 => 0, - 22 => 0, - ); + if (!isset($this->yy_global_pattern1)) { + $this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>])|(" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G([\S\s])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $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((<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|(<\\?(?:php\\w+|=|[a-zA-Z]+)?))|\G(\\?>)|\G(<\/script>)|\G(\\s*" . $this->rdel . ")|\G(<%)|\G(%>)|\G([\S\s])/iS"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state TEXT'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TEXT'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r1_' . $this->token}($yysubmatches); + $r = $this->{'yy_r1_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -210,8 +317,7 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); @@ -219,39 +325,33 @@ class Smarty_Internal_Templatelexer const TEXT = 1; - function yy_r1_1($yy_subpatterns) + function yy_r1_1() { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r1_2($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_COMMENT; - } - - function yy_r1_4($yy_subpatterns) + function yy_r1_2() { - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + preg_match("~[*]{$this->rdel}~", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + if (isset($match[0][1])) { + $to = $match[0][1] + strlen($match[0][0]); } else { - $this->token = Smarty_Internal_Templateparser::TP_STRIPON; + $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'"); } + $this->value = substr($this->data, $this->counter, $to - $this->counter); + return false; } - function yy_r1_5($yy_subpatterns) + function yy_r1_3() { - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF; - } + $obj = new Smarty_Internal_Compile_Private_Php(); + $obj->parsePhp($this); } - function yy_r1_6($yy_subpatterns) + function yy_r1_15() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -262,130 +362,28 @@ class Smarty_Internal_Templatelexer } } - function yy_r1_7($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_9($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_10($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_11($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_12($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_13($yy_subpatterns) + function yy_r1_16() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } else { - $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r1_14($yy_subpatterns) - { - - if (($script = strpos($this->value, '<s') === 0) || in_array($this->value, Array('<?', '<?=', '<?php'))) { - if ($script) { - $this->is_phpScript = true; - } - $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG; - } elseif ($this->value == '<?xml') { - $this->token = Smarty_Internal_Templateparser::TP_XMLTAG; - } else { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - //$this->value = substr($this->value, 0, 2); + $this->yypushstate(self::TAG); + return true; } } - function yy_r1_17($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG; - } - - function yy_r1_18($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_PHPENDSCRIPT; - } - - function yy_r1_19($yy_subpatterns) + function yy_r1_17() { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r1_20($yy_subpatterns) + function yy_r1_18() { - $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG; - } - - function yy_r1_21($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG; - } - - function yy_r1_22($yy_subpatterns) - { - - $phpEndScript = $this->is_phpScript ? '|<\\/script>' : ''; $to = strlen($this->data); - preg_match("/{$this->ldel}|<\?|<%|\?>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>{$phpEndScript}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } @@ -395,99 +393,28 @@ class Smarty_Internal_Templatelexer public function yylex2() { - $tokenMap = array( - 1 => 0, - 2 => 0, - 3 => 1, - 5 => 0, - 6 => 0, - 7 => 0, - 8 => 0, - 9 => 0, - 10 => 0, - 11 => 0, - 12 => 0, - 13 => 0, - 14 => 0, - 15 => 1, - 17 => 1, - 19 => 1, - 21 => 0, - 22 => 0, - 23 => 0, - 24 => 0, - 25 => 0, - 26 => 0, - 27 => 0, - 28 => 0, - 29 => 0, - 30 => 0, - 31 => 0, - 32 => 0, - 33 => 0, - 34 => 0, - 35 => 0, - 36 => 0, - 37 => 0, - 38 => 3, - 42 => 0, - 43 => 0, - 44 => 0, - 45 => 0, - 46 => 0, - 47 => 0, - 48 => 0, - 49 => 0, - 50 => 1, - 52 => 1, - 54 => 0, - 55 => 0, - 56 => 0, - 57 => 0, - 58 => 0, - 59 => 0, - 60 => 0, - 61 => 0, - 62 => 0, - 63 => 0, - 64 => 0, - 65 => 0, - 66 => 0, - 67 => 0, - 68 => 0, - 69 => 0, - 70 => 1, - 72 => 0, - 73 => 0, - 74 => 0, - 75 => 0, - 76 => 0, - ); + if (!isset($this->yy_global_pattern2)) { + $this->yy_global_pattern2 = "/\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*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $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"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state SMARTY'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAG'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r2_' . $this->token}($yysubmatches); + $r = $this->{'yy_r2_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -507,300 +434,321 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const SMARTY = 2; + const TAG = 2; - function yy_r2_1($yy_subpatterns) + function yy_r2_1() { - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; - $this->yypushstate(self::DOUBLEQUOTEDSTRING); + $this->token = Smarty_Internal_Templateparser::TP_LDELIF; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; } - function yy_r2_2($yy_subpatterns) + function yy_r2_3() { - $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; + $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; } - function yy_r2_3($yy_subpatterns) + function yy_r2_4() { - $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; + $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; + $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } - function yy_r2_5($yy_subpatterns) + function yy_r2_5() { - $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; + $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; } - function yy_r2_6($yy_subpatterns) + function yy_r2_6() { - $this->token = Smarty_Internal_Templateparser::TP_RDEL; $this->yypopstate(); + $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; + $this->taglineno = $this->line; } - function yy_r2_7($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_ISIN; - } - - function yy_r2_8($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_AS; - } - - function yy_r2_9($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_TO; - } - - function yy_r2_10($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_STEP; - } - - function yy_r2_11($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; - } - - function yy_r2_12($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_IDENTITY; - } - - function yy_r2_13($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY; - } - - function yy_r2_14($yy_subpatterns) + function yy_r2_8() { - $this->token = Smarty_Internal_Templateparser::TP_EQUALS; + $this->yypopstate(); + $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; + $this->taglineno = $this->line; } - function yy_r2_15($yy_subpatterns) + function yy_r2_9() { - $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS; + if ($this->_yy_stack[count($this->_yy_stack) - 1] == self::TEXT) { + $this->yypopstate(); + $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT; + $this->taglineno = $this->line; + } else { + $this->value = $this->smarty->left_delimiter; + $this->token = Smarty_Internal_Templateparser::TP_LDEL; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; + } } - function yy_r2_17($yy_subpatterns) + function yy_r2_11() { - $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL; + $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; } - function yy_r2_19($yy_subpatterns) + function yy_r2_12() { - $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL; + $this->token = Smarty_Internal_Templateparser::TP_LDEL; + $this->yybegin(self::TAGBODY); + $this->taglineno = $this->line; } - function yy_r2_21($yy_subpatterns) + public function yylex3() { + if (!isset($this->yy_global_pattern3)) { + $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\\s+(not\\s+)?(odd|even|div)\\s+by))\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/isS"; + } + if ($this->counter >= strlen($this->data)) { + return false; // end of input + } - $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN; - } - - function yy_r2_22($yy_subpatterns) - { + do { + if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { + $yysubmatches = $yymatches; + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAGBODY '); + } + next($yymatches); // skip global match + $this->token = key($yymatches); // token number + $this->value = current($yymatches); // token value + $r = $this->{'yy_r3_' . $this->token}(); + if ($r === null) { + $this->counter += strlen($this->value); + $this->line += substr_count($this->value, "\n"); + // accept this token + return true; + } elseif ($r === true) { + // we have changed state + // process this token in the new state + return $this->yylex(); + } elseif ($r === false) { + $this->counter += strlen($this->value); + $this->line += substr_count($this->value, "\n"); + if ($this->counter >= strlen($this->data)) { + return false; // end of input + } + // skip this token + continue; + } + } else { + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); + } + break; + } while (true); + } // end function - $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN; - } + const TAGBODY = 3; - function yy_r2_23($yy_subpatterns) + function yy_r3_1() { - $this->token = Smarty_Internal_Templateparser::TP_MOD; + $this->token = Smarty_Internal_Templateparser::TP_RDEL; + $this->yypopstate(); } - function yy_r2_24($yy_subpatterns) + function yy_r3_2() { - $this->token = Smarty_Internal_Templateparser::TP_NOT; + $this->token = Smarty_Internal_Templateparser::TP_QUOTE; + $this->yypushstate(self::DOUBLEQUOTEDSTRING); } - function yy_r2_25($yy_subpatterns) + function yy_r3_3() { - $this->token = Smarty_Internal_Templateparser::TP_LAND; + $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; } - function yy_r2_26($yy_subpatterns) + function yy_r3_4() { - $this->token = Smarty_Internal_Templateparser::TP_LOR; + $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; + $this->taglineno = $this->line; } - function yy_r2_27($yy_subpatterns) + function yy_r3_6() { - $this->token = Smarty_Internal_Templateparser::TP_LXOR; + $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; } - function yy_r2_28($yy_subpatterns) + function yy_r3_7() { - $this->token = Smarty_Internal_Templateparser::TP_ISODDBY; + $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; } - function yy_r2_29($yy_subpatterns) + function yy_r3_8() { - $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY; + $this->token = Smarty_Internal_Templateparser::TP_ISIN; } - function yy_r2_30($yy_subpatterns) + function yy_r3_9() { - $this->token = Smarty_Internal_Templateparser::TP_ISODD; + $this->token = Smarty_Internal_Templateparser::TP_AS; } - function yy_r2_31($yy_subpatterns) + function yy_r3_10() { - $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD; + $this->token = Smarty_Internal_Templateparser::TP_TO; } - function yy_r2_32($yy_subpatterns) + function yy_r3_11() { - $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY; + $this->token = Smarty_Internal_Templateparser::TP_STEP; } - function yy_r2_33($yy_subpatterns) + function yy_r3_12() { - $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY; + $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; } - function yy_r2_34($yy_subpatterns) + function yy_r3_13() { - $this->token = Smarty_Internal_Templateparser::TP_ISEVEN; + $this->token = Smarty_Internal_Templateparser::TP_LOGOP; } - function yy_r2_35($yy_subpatterns) + function yy_r3_18() { - $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN; + $this->token = Smarty_Internal_Templateparser::TP_TLOGOP; } - function yy_r2_36($yy_subpatterns) + function yy_r3_23() { - $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY; + $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; } - function yy_r2_37($yy_subpatterns) + function yy_r3_26() { - $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY; + $this->token = Smarty_Internal_Templateparser::TP_NOT; } - function yy_r2_38($yy_subpatterns) + function yy_r3_29() { $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; } - function yy_r2_42($yy_subpatterns) + function yy_r3_33() { $this->token = Smarty_Internal_Templateparser::TP_OPENP; } - function yy_r2_43($yy_subpatterns) + function yy_r3_34() { $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; } - function yy_r2_44($yy_subpatterns) + function yy_r3_35() { $this->token = Smarty_Internal_Templateparser::TP_OPENB; } - function yy_r2_45($yy_subpatterns) + function yy_r3_36() { $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; } - function yy_r2_46($yy_subpatterns) + function yy_r3_37() { $this->token = Smarty_Internal_Templateparser::TP_PTR; } - function yy_r2_47($yy_subpatterns) + function yy_r3_38() { $this->token = Smarty_Internal_Templateparser::TP_APTR; } - function yy_r2_48($yy_subpatterns) + function yy_r3_39() { $this->token = Smarty_Internal_Templateparser::TP_EQUAL; } - function yy_r2_49($yy_subpatterns) + function yy_r3_40() { $this->token = Smarty_Internal_Templateparser::TP_INCDEC; } - function yy_r2_50($yy_subpatterns) + function yy_r3_42() { $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; } - function yy_r2_52($yy_subpatterns) + function yy_r3_44() { $this->token = Smarty_Internal_Templateparser::TP_MATH; } - function yy_r2_54($yy_subpatterns) + function yy_r3_46() { $this->token = Smarty_Internal_Templateparser::TP_AT; } - function yy_r2_55($yy_subpatterns) + function yy_r3_47() { $this->token = Smarty_Internal_Templateparser::TP_HATCH; } - function yy_r2_56($yy_subpatterns) + function yy_r3_48() { // resolve conflicts with shorttag and right_delimiter starting with '=' if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) { - preg_match("/\s+/", $this->value, $match); + preg_match("~\s+~", $this->value, $match); $this->value = $match[0]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; } else { @@ -808,183 +756,126 @@ class Smarty_Internal_Templatelexer } } - function yy_r2_57($yy_subpatterns) + function yy_r3_49() + { + + $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; + } + + function yy_r3_52() { $this->token = Smarty_Internal_Templateparser::TP_ID; } - function yy_r2_58($yy_subpatterns) + function yy_r3_53() { $this->token = Smarty_Internal_Templateparser::TP_INTEGER; } - function yy_r2_59($yy_subpatterns) + function yy_r3_54() { $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->yypopstate(); } - function yy_r2_60($yy_subpatterns) + function yy_r3_55() { $this->token = Smarty_Internal_Templateparser::TP_VERT; } - function yy_r2_61($yy_subpatterns) + function yy_r3_56() { $this->token = Smarty_Internal_Templateparser::TP_DOT; } - function yy_r2_62($yy_subpatterns) + function yy_r3_57() { $this->token = Smarty_Internal_Templateparser::TP_COMMA; } - function yy_r2_63($yy_subpatterns) + function yy_r3_58() { $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; } - function yy_r2_64($yy_subpatterns) + function yy_r3_59() { $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; } - function yy_r2_65($yy_subpatterns) + function yy_r3_60() { $this->token = Smarty_Internal_Templateparser::TP_COLON; } - function yy_r2_66($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_ANDSYM; - } - - function yy_r2_67($yy_subpatterns) + function yy_r3_61() { $this->token = Smarty_Internal_Templateparser::TP_QMARK; } - function yy_r2_68($yy_subpatterns) + function yy_r3_62() { $this->token = Smarty_Internal_Templateparser::TP_HEX; } - function yy_r2_69($yy_subpatterns) + function yy_r3_63() { $this->token = Smarty_Internal_Templateparser::TP_SPACE; } - function yy_r2_70($yy_subpatterns) + function yy_r3_64() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r2_72($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r2_73($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r2_74($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } - } - - function yy_r2_75($yy_subpatterns) - { - - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; + $this->yypushstate(self::TAG); + return true; } } - function yy_r2_76($yy_subpatterns) + function yy_r3_65() { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - public function yylex3() + public function yylex4() { - $tokenMap = array( - 1 => 0, - 2 => 0, - 3 => 0, - ); + if (!isset($this->yy_global_pattern4)) { + $this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state LITERAL'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state LITERAL'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r3_' . $this->token}($yysubmatches); + $r = $this->{'yy_r4_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -1004,23 +895,22 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const LITERAL = 3; + const LITERAL = 4; - function yy_r3_1($yy_subpatterns) + function yy_r4_1() { $this->literal_cnt ++; $this->token = Smarty_Internal_Templateparser::TP_LITERAL; } - function yy_r3_2($yy_subpatterns) + function yy_r4_2() { if ($this->literal_cnt) { @@ -1032,11 +922,11 @@ class Smarty_Internal_Templatelexer } } - function yy_r3_3($yy_subpatterns) + function yy_r4_3() { $to = strlen($this->data); - preg_match("/{$this->ldel}\/?literal{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } else { @@ -1046,48 +936,30 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_LITERAL; } - public function yylex4() + public function yylex5() { - $tokenMap = array( - 1 => 1, - 3 => 0, - 4 => 0, - 5 => 0, - 6 => 0, - 7 => 0, - 8 => 0, - 9 => 0, - 10 => 0, - 11 => 0, - 12 => 0, - 13 => 3, - 17 => 0, - ); + if (!isset($this->yy_global_pattern5)) { + $this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $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*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\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"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r4_' . $this->token}($yysubmatches); + $r = $this->{'yy_r5_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -1107,122 +979,95 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const DOUBLEQUOTEDSTRING = 4; + const DOUBLEQUOTEDSTRING = 5; - function yy_r4_1($yy_subpatterns) + function yy_r5_1() { - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } + $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r4_3($yy_subpatterns) + function yy_r5_2() { - if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; - } + $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r4_4($yy_subpatterns) + function yy_r5_3() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; + $this->yypushstate(self::TAG); + return true; } } - function yy_r4_5($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - - function yy_r4_6($yy_subpatterns) - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - - function yy_r4_7($yy_subpatterns) + function yy_r5_4() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } else { - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; - $this->yypushstate(self::SMARTY); - $this->taglineno = $this->line; + $this->yypushstate(self::TAG); + return true; } } - function yy_r4_8($yy_subpatterns) + function yy_r5_5() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } else { $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->yypushstate(self::SMARTY); $this->taglineno = $this->line; + $this->yypushstate(self::TAGBODY); } } - function yy_r4_9($yy_subpatterns) + function yy_r5_6() { $this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->yypopstate(); } - function yy_r4_10($yy_subpatterns) + function yy_r5_7() { $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->value = substr($this->value, 0, - 1); - $this->yypushstate(self::SMARTY); + $this->yypushstate(self::TAGBODY); $this->taglineno = $this->line; } - function yy_r4_11($yy_subpatterns) + function yy_r5_8() { $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; } - function yy_r4_12($yy_subpatterns) + function yy_r5_9() { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r4_13($yy_subpatterns) + function yy_r5_10() { $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - function yy_r4_17($yy_subpatterns) + function yy_r5_14() { $to = strlen($this->data); @@ -1230,39 +1075,30 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_TEXT; } - public function yylex5() + public function yylex6() { - $tokenMap = array( - 1 => 0, - 2 => 0, - 3 => 0, - 4 => 0, - ); + if (!isset($this->yy_global_pattern6)) { + $this->yy_global_pattern6 = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $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"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state CHILDBODY'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBODY'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r5_' . $this->token}($yysubmatches); + $r = $this->{'yy_r6_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -1282,16 +1118,15 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const CHILDBODY = 5; + const CHILDBODY = 6; - function yy_r5_1($yy_subpatterns) + function yy_r6_1() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1301,7 +1136,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r5_2($yy_subpatterns) + function yy_r6_2() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1311,7 +1146,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r5_3($yy_subpatterns) + function yy_r6_3() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1322,11 +1157,11 @@ class Smarty_Internal_Templatelexer } } - function yy_r5_4($yy_subpatterns) + function yy_r6_4() { $to = strlen($this->data); - preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("~" . $this->ldel . "\s*(([/])?strip\s*" . $this->rdel . "|block\s+)~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } @@ -1334,40 +1169,30 @@ class Smarty_Internal_Templatelexer return false; } - public function yylex6() + public function yylex7() { - $tokenMap = array( - 1 => 0, - 2 => 0, - 3 => 0, - 4 => 1, - 6 => 0, - ); + if (!isset($this->yy_global_pattern7)) { + $this->yy_global_pattern7 = "/\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])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $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"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern7, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state CHILDBLOCK'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBLOCK'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r6_' . $this->token}($yysubmatches); + $r = $this->{'yy_r7_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -1387,16 +1212,15 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const CHILDBLOCK = 6; + const CHILDBLOCK = 7; - function yy_r6_1($yy_subpatterns) + function yy_r7_1() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1407,7 +1231,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r6_2($yy_subpatterns) + function yy_r7_2() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1418,7 +1242,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r6_3($yy_subpatterns) + function yy_r7_3() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1429,7 +1253,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r6_4($yy_subpatterns) + function yy_r7_4() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1440,11 +1264,11 @@ class Smarty_Internal_Templatelexer } } - function yy_r6_6($yy_subpatterns) + function yy_r7_6() { $to = strlen($this->data); - 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); + preg_match("~" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|([/])?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } @@ -1452,38 +1276,30 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; } - public function yylex7() + public function yylex8() { - $tokenMap = array( - 1 => 0, - 2 => 0, - 3 => 0, - ); + if (!isset($this->yy_global_pattern8)) { + $this->yy_global_pattern8 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS"; + } if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS"; do { - if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) { + if (preg_match($this->yy_global_pattern8, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns - if (!count($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr($this->data, - $this->counter, 5) . '... state CHILDLITERAL'); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } + if (empty($yymatches)) { + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDLITERAL'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number - if ($tokenMap[$this->token]) { - // extract sub-patterns for passing to lex function - $yysubmatches = array_slice($yysubmatches, $this->token + 1, - $tokenMap[$this->token]); - } else { - $yysubmatches = array(); - } $this->value = current($yymatches); // token value - $r = $this->{'yy_r7_' . $this->token}($yysubmatches); + $r = $this->{'yy_r8_' . $this->token}(); if ($r === null) { $this->counter += strlen($this->value); $this->line += substr_count($this->value, "\n"); @@ -1503,16 +1319,15 @@ class Smarty_Internal_Templatelexer continue; } } else { - throw new Exception('Unexpected input at line' . $this->line . - ': ' . $this->data[$this->counter]); + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); } break; } while (true); } // end function - const CHILDLITERAL = 7; + const CHILDLITERAL = 8; - function yy_r7_1($yy_subpatterns) + function yy_r8_1() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1523,7 +1338,7 @@ class Smarty_Internal_Templatelexer } } - function yy_r7_2($yy_subpatterns) + function yy_r8_2() { if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) { @@ -1534,11 +1349,11 @@ class Smarty_Internal_Templatelexer } } - function yy_r7_3($yy_subpatterns) + function yy_r8_3() { $to = strlen($this->data); - preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } else { @@ -1547,6 +1362,7 @@ class Smarty_Internal_Templatelexer $this->value = substr($this->data, $this->counter, $to - $this->counter); $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE; } + }
\ No newline at end of file |