- improvement remove not needed ?><?php transitions from compiled code

This commit is contained in:
Uwe Tews
2015-05-13 02:06:33 +02:00
parent cf5b5c4e1f
commit 2b858212b7
13 changed files with 425 additions and 2019 deletions

View File

@@ -1,4 +1,8 @@
 ===== 3.1.24.dev ===== (xx.xx.2015)  ===== 3.1.24.dev ===== (xx.xx.2015)
13.05.2015
- improvement remove not needed ?><?php transitions from compiled code
12.05.2015
- bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28 - bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28
- bugfix access to undefined config variable like {#undef#} did fail https://github.com/smarty-php/smarty/issues/29 - bugfix access to undefined config variable like {#undef#} did fail https://github.com/smarty-php/smarty/issues/29
- bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33 - bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.24-dev/2'; const SMARTY_VERSION = '3.1.24-dev/3';
/** /**
* define variable scopes * define variable scopes

View File

@@ -155,22 +155,23 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
} else { } else {
$tmp = ''; $tmp = '';
foreach ($compiler->prefix_code as $code) { foreach ($compiler->prefix_code as $code) {
$tmp .= $code; $tmp = $compiler->appendCode($tmp, $code);
} }
$compiler->prefix_code = array(); $compiler->prefix_code = array();
$tmp = $compiler->appendCode("<?php } else {?>", $tmp);
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
if ($condition_by_assign) { if ($condition_by_assign) {
if (is_array($parameter['if condition']['var'])) { if (is_array($parameter['if condition']['var'])) {
$_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n"; $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n");
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>"; $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
} else { } else {
$_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});"; $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});");
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>"; $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
} }
return $_output; return $_output;
} else { } else {
return "<?php } else {?>{$tmp}<?php if ({$parameter['if condition']}) {?>"; return $compiler->appendCode($tmp, "<?php if ({$parameter['if condition']}) {?>");
} }
} }
} }

View File

@@ -11,7 +11,6 @@
/** /**
* Class Smarty_Internal_Extension_CodeFrame * Class Smarty_Internal_Extension_CodeFrame
* Create code frame for compiled and cached templates * Create code frame for compiled and cached templates
*/ */
class Smarty_Internal_Extension_CodeFrame class Smarty_Internal_Extension_CodeFrame
{ {
@@ -78,11 +77,19 @@ class Smarty_Internal_Extension_CodeFrame
$output .= "?>/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/';\n"; $output .= "?>/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/';\n";
} }
} }
$output .= "?>\n" . $content; $output .= "?>\n";
$output .= "<?php }\n}\n?>"; $output = self::appendCode($output, $content);
return $output; return self::appendCode($output, "<?php }\n}\n?>");
} }
/**
* Create code frame of compiled template function
*
* @param \Smarty_Internal_Template $_template
* @param string $content
*
* @return string
*/
public static function createFunctionFrame(Smarty_Internal_Template $_template, $content = '') public static function createFunctionFrame(Smarty_Internal_Template $_template, $content = '')
{ {
if (!isset($_template->properties['unifunc'])) { if (!isset($_template->properties['unifunc'])) {
@@ -98,4 +105,23 @@ class Smarty_Internal_Extension_CodeFrame
$output .= "}\n}\n?>"; $output .= "}\n}\n?>";
return $output; return $output;
} }
/**
* Append code segments and remove unneeded ?> <?php transitions
*
* @param string $left
* @param string $right
*
* @return string
*/
public static function appendCode($left, $right)
{
if (preg_match('/\s*\?>$/', $left) && preg_match('/^<\?php\s+/', $right)) {
$left = preg_replace('/\s*\?>$/', "\n", $left);
$left .= preg_replace('/^<\?php\s+/', '', $right);
} else {
$left .= $right;
}
return $left;
}
} }

View File

@@ -16,12 +16,14 @@
*/ */
abstract class Smarty_Internal_ParseTree abstract class Smarty_Internal_ParseTree
{ {
/** /**
* Parser object * Parser object
* *
* @var object * @var object
*/ */
public $parser; public $parser;
/** /**
* Buffer content * Buffer content
* *

View File

@@ -1,6 +1,6 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parse Tree
* These are classes to build parse trees in the template parser * These are classes to build parse trees in the template parser
* *
* @package Smarty * @package Smarty

View File

@@ -7,6 +7,7 @@
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
/** /**
* Double quoted string inside a tag. * Double quoted string inside a tag.
* *
@@ -41,11 +42,11 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
$last_subtree = count($this->subtrees) - 1; $last_subtree = count($this->subtrees) - 1;
if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) { if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
if ($subtree instanceof Smarty_Internal_ParseTree_Code) { if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
$this->subtrees[$last_subtree]->data .= '<?php echo ' . $subtree->data . ';?>'; $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
} elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) { } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
$this->subtrees[$last_subtree]->data .= '<?php echo "' . $subtree->data . '";?>'; $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
} else { } else {
$this->subtrees[$last_subtree]->data .= $subtree->data; $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
} }
} else { } else {
$this->subtrees[] = $subtree; $this->subtrees[] = $subtree;

View File

@@ -1,7 +1,7 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parse Tree
* These are classes to build parsetrees in the template parser * These are classes to build parse tree in the template parser
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
@@ -9,7 +9,6 @@
* @author Uwe Tews * @author Uwe Tews
*/ */
/** /**
* Raw chars as part of a double quoted string. * Raw chars as part of a double quoted string.
* *

View File

@@ -1,7 +1,7 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parse Tree
* These are classes to build parsetrees in the template parser * These are classes to build parse tree in the template parser
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
@@ -18,6 +18,7 @@
*/ */
class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
{ {
/** /**
* Saved block nesting level * Saved block nesting level
* *
@@ -56,7 +57,9 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
public function assign_to_var() public function assign_to_var()
{ {
$var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number); $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number);
$this->parser->compiler->prefix_code[] = sprintf("<?php ob_start();?>%s<?php %s=ob_get_clean();?>", $this->data, $var); $tmp = $this->parser->compiler->appendCode('<?php ob_start();?>', $this->data);
$tmp = $this->parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
$this->parser->compiler->prefix_code[] = sprintf("%s", $tmp);
return $var; return $var;
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parse Tree
* These are classes to build parsetrees in the template parser * These are classes to build parse tree in the template parser
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
@@ -18,6 +18,7 @@
*/ */
class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
{ {
/** /**
* Array of template elements * Array of template elements
* *
@@ -44,10 +45,12 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
{ {
if (!empty($subtree->subtrees)) { if (!empty($subtree->subtrees)) {
$this->subtrees = array_merge($this->subtrees, $subtree->subtrees); $this->subtrees = array_merge($this->subtrees, $subtree->subtrees);
} else if ($subtree->data !== '') { } else {
if ($subtree->data !== '') {
$this->subtrees[] = $subtree; $this->subtrees[] = $subtree;
} }
} }
}
/** /**
* Sanitize and merge subtree buffers together * Sanitize and merge subtree buffers together
@@ -80,13 +83,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
if ($this->subtrees[$key]->data == '') { if ($this->subtrees[$key]->data == '') {
continue; continue;
} }
$newCode = $this->subtrees[$key]->to_smarty_php(); $subtree = $this->parser->compiler->appendCode($subtree, $this->subtrees[$key]->to_smarty_php());
if ((preg_match('/^\s*<\?php\s+/', $newCode) && preg_match('/\s*\?>\s*$/', $subtree))) {
$subtree = preg_replace('/\s*\?>\s*$/', "\n", $subtree);
$subtree .= preg_replace('/^\s*<\?php\s+/', '', $newCode);
} else {
$subtree .= $newCode;
}
} }
if ($subtree == '') { if ($subtree == '') {
continue; continue;

View File

@@ -1,8 +1,8 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parse Tree
* These are classes to build parsetrees in the template parser * These are classes to build parse tree in the template parser
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler

View File

@@ -19,176 +19,147 @@
*/ */
class Smarty_Internal_Templatelexer class Smarty_Internal_Templatelexer
{ {
/** /**
* Source * Source
* *
* @var string * @var string
*/ */
public $data; public $data;
/** /**
* byte counter * byte counter
* *
* @var int * @var int
*/ */
public $counter; public $counter;
/** /**
* token number * token number
* *
* @var int * @var int
*/ */
public $token; public $token;
/** /**
* token value * token value
* *
* @var string * @var string
*/ */
public $value; public $value;
/** /**
* current line * current line
* *
* @var int * @var int
*/ */
public $line; public $line;
/** /**
* tag start line * tag start line
* *
* @var * @var
*/ */
public $taglineno; public $taglineno;
/** /**
* flag if parsing php script * flag if parsing php script
* *
* @var bool * @var bool
*/ */
public $is_phpScript = false; public $is_phpScript = false;
/** /**
* php code type * php code type
* *
* @var string * @var string
*/ */
public $phpType = ''; public $phpType = '';
/** /**
* escaped left delimiter * escaped left delimiter
* *
* @var string * @var string
*/ */
public $ldel = ''; public $ldel = '';
/** /**
* escaped left delimiter length * escaped left delimiter length
* *
* @var int * @var int
*/ */
public $ldel_length = 0; public $ldel_length = 0;
/** /**
* escaped right delimiter * escaped right delimiter
* *
* @var string * @var string
*/ */
public $rdel = ''; public $rdel = '';
/** /**
* escaped right delimiter length * escaped right delimiter length
* *
* @var int * @var int
*/ */
public $rdel_length = 0; public $rdel_length = 0;
/** /**
* state number * state number
* *
* @var int * @var int
*/ */
public $state = 1; public $state = 1;
/** /**
* Smarty object * Smarty object
* *
* @var Smarty * @var Smarty
*/ */
public $smarty = null; public $smarty = null;
/** /**
* compiler object * compiler object
* *
* @var Smarty_Internal_TemplateCompilerBase * @var Smarty_Internal_TemplateCompilerBase
*/ */
private $compiler = null; private $compiler = null;
/** /**
* literal tag nesting level * literal tag nesting level
* *
* @var int * @var int
*/ */
private $literal_cnt = 0; private $literal_cnt = 0;
/** /**
* trace file * trace file
* *
* @var resource * @var resource
*/ */
public $yyTraceFILE; public $yyTraceFILE;
/** /**
* trace prompt * trace prompt
* *
* @var string * @var string
*/ */
public $yyTracePrompt; public $yyTracePrompt;
/** /**
* state names * state names
* *
* @var array * @var array
*/ */
public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY'); public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY');
/** /**
* token names * token names
* *
* @var array * @var array
*/ */
public $smarty_token_names = array( // Text for parser error messages public $smarty_token_names = array( // Text for parser error messages
'IDENTITY' => '===', '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',);
'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',
);
/** /**
* constructor * constructor
@@ -221,6 +192,7 @@ class Smarty_Internal_Templatelexer
} }
private $_yy_state = 1; private $_yy_state = 1;
private $_yy_stack = array(); private $_yy_stack = array();
public function yylex() public function yylex()
@@ -261,27 +233,7 @@ class Smarty_Internal_Templatelexer
public function yylex1() public function yylex1()
{ {
$tokenMap = array( $tokenMap = array(1 => 0, 2 => 1, 4 => 0, 5 => 0, 6 => 0, 7 => 1, 9 => 0, 10 => 0, 11 => 0, 12 => 6, 19 => 0, 20 => 0, 21 => 0, 22 => 1, 24 => 6, 31 => 7, 39 => 6, 46 => 3, 50 => 0,);
1 => 0,
2 => 1,
4 => 0,
5 => 0,
6 => 0,
7 => 1,
9 => 0,
10 => 0,
11 => 0,
12 => 6,
19 => 0,
20 => 0,
21 => 0,
22 => 1,
24 => 6,
31 => 7,
39 => 6,
46 => 3,
50 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -292,16 +244,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TEXT');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TEXT');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -326,8 +275,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -521,75 +469,7 @@ class Smarty_Internal_Templatelexer
public function yylex2() public function yylex2()
{ {
$tokenMap = array( $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 => 2, 60 => 0, 61 => 0, 62 => 0, 63 => 0, 64 => 0, 65 => 0, 66 => 0, 67 => 0, 68 => 0, 69 => 0, 70 => 0, 71 => 0, 72 => 0, 73 => 1, 75 => 0, 76 => 0, 77 => 0, 78 => 0, 79 => 0,);
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 => 2,
60 => 0,
61 => 0,
62 => 0,
63 => 0,
64 => 0,
65 => 0,
66 => 0,
67 => 0,
68 => 0,
69 => 0,
70 => 0,
71 => 0,
72 => 0,
73 => 1,
75 => 0,
76 => 0,
77 => 0,
78 => 0,
79 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -600,16 +480,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state SMARTY');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state SMARTY');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -634,8 +511,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -1088,11 +964,7 @@ class Smarty_Internal_Templatelexer
public function yylex3() public function yylex3()
{ {
$tokenMap = array( $tokenMap = array(1 => 0, 2 => 0, 3 => 0,);
1 => 0,
2 => 0,
3 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -1103,16 +975,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state LITERAL');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state LITERAL');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -1137,8 +1006,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -1181,21 +1049,7 @@ class Smarty_Internal_Templatelexer
public function yylex4() public function yylex4()
{ {
$tokenMap = array( $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,);
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 ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -1206,16 +1060,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -1240,8 +1091,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -1365,12 +1215,7 @@ class Smarty_Internal_Templatelexer
public function yylex5() public function yylex5()
{ {
$tokenMap = array( $tokenMap = array(1 => 0, 2 => 0, 3 => 0, 4 => 0,);
1 => 0,
2 => 0,
3 => 0,
4 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -1381,16 +1226,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBODY');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state CHILDBODY');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -1415,8 +1257,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -1469,13 +1310,7 @@ class Smarty_Internal_Templatelexer
public function yylex6() public function yylex6()
{ {
$tokenMap = array( $tokenMap = array(1 => 0, 2 => 0, 3 => 0, 4 => 1, 6 => 0,);
1 => 0,
2 => 0,
3 => 0,
4 => 1,
6 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -1486,16 +1321,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBLOCK');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state CHILDBLOCK');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -1520,8 +1352,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
@@ -1587,11 +1418,7 @@ class Smarty_Internal_Templatelexer
public function yylex7() public function yylex7()
{ {
$tokenMap = array( $tokenMap = array(1 => 0, 2 => 0, 3 => 0,);
1 => 0,
2 => 0,
3 => 0,
);
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
@@ -1602,16 +1429,13 @@ class Smarty_Internal_Templatelexer
$yysubmatches = $yymatches; $yysubmatches = $yymatches;
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches); $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!count($yymatches)) { if (!count($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDLITERAL');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state CHILDLITERAL');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) { if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function // extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1, $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]);
$tokenMap[$this->token]);
} else { } else {
$yysubmatches = array(); $yysubmatches = array();
} }
@@ -1636,8 +1460,7 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);

File diff suppressed because one or more lines are too long