lexer/parser optimization

This commit is contained in:
Uwe Tews
2017-11-05 20:04:32 +01:00
parent dd9c076dfa
commit 3799714d53
10 changed files with 2115 additions and 2582 deletions

View File

@@ -1,4 +1,7 @@
===== 3.1.32 - dev === ===== 3.1.32 - dev ===
05.11.2017 3.1.32-dev-32
- lexer/parser optimization
26.10.2017 3.1.32-dev-28 26.10.2017 3.1.32-dev-28
- bugfix Smarty version was not filled in header comment of compiled and cached files - bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR
@@ -7,7 +10,7 @@
for backward compatibility code is moved from Smarty class to an external class and still can be for backward compatibility code is moved from Smarty class to an external class and still can be
called. called.
- correction of PHPDoc blocks - correction of PHPDoc blocks
- minor code cleanup - minor code cleanup
21.10.2017 21.10.2017
- bugfix custom delimiters could fail since modification of version 3.1.32-dev-23 - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23

View File

@@ -235,7 +235,7 @@ double_quoted_string {
$this->yypopstate(); $this->yypopstate();
} }
maybe_bool { maybe_bool {
if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) { if (!$this->configBooleanize || !in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no')) ) {
$this->yypopstate(); $this->yypopstate();
$this->yypushstate(self::NAKED_STRING_VALUE); $this->yypushstate(self::NAKED_STRING_VALUE);
return true; //reprocess in new state return true; //reprocess in new state
@@ -250,7 +250,7 @@ naked_string {
} }
newline { newline {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->value = ""; $this->value = '';
$this->yypopstate(); $this->yypopstate();
} }
@@ -308,7 +308,7 @@ text {
if (isset($match[0][1])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} else { } else {
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag"); $this->compiler->trigger_template_error ('missing or misspelled literal closing tag');
} }
$this->value = substr($this->data,$this->counter,$to-$this->counter); $this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;

View File

@@ -80,7 +80,7 @@ class Smarty_Internal_Configfileparser
* *
* @var array * @var array
*/ */
private static $escapes_single = Array('\\' => '\\', private static $escapes_single = array('\\' => '\\',
'\'' => '\''); '\'' => '\'');
/** /**
@@ -131,7 +131,7 @@ class Smarty_Internal_Configfileparser
$ss = preg_split('/(\\\\.)/', $escaped_string, - 1, PREG_SPLIT_DELIM_CAPTURE); $ss = preg_split('/(\\\\.)/', $escaped_string, - 1, PREG_SPLIT_DELIM_CAPTURE);
$str = ""; $str = '';
foreach ($ss as $s) { foreach ($ss as $s) {
if (strlen($s) === 2 && $s[0] === '\\') { if (strlen($s) === 2 && $s[0] === '\\') {
if (isset(self::$escapes_single[$s[1]])) { if (isset(self::$escapes_single[$s[1]])) {
@@ -174,10 +174,10 @@ class Smarty_Internal_Configfileparser
* @param array $var * @param array $var
* @param array $target_array * @param array $target_array
*/ */
private function set_var(Array $var, Array &$target_array) private function set_var(array $var, array &$target_array)
{ {
$key = $var["key"]; $key = $var['key'];
$value = $var["value"]; $value = $var['value'];
if ($this->configOverwrite || !isset($target_array['vars'][$key])) { if ($this->configOverwrite || !isset($target_array['vars'][$key])) {
$target_array['vars'][$key] = $value; $target_array['vars'][$key] = $value;
@@ -192,10 +192,10 @@ class Smarty_Internal_Configfileparser
* *
* @param array $vars * @param array $vars
*/ */
private function add_global_vars(Array $vars) private function add_global_vars(array $vars)
{ {
if (!isset($this->compiler->config_data['vars'])) { if (!isset($this->compiler->config_data['vars'])) {
$this->compiler->config_data['vars'] = Array(); $this->compiler->config_data['vars'] = array();
} }
foreach ($vars as $var) { foreach ($vars as $var) {
$this->set_var($var, $this->compiler->config_data); $this->set_var($var, $this->compiler->config_data);
@@ -208,10 +208,10 @@ class Smarty_Internal_Configfileparser
* @param string $section_name * @param string $section_name
* @param array $vars * @param array $vars
*/ */
private function add_section_vars($section_name, Array $vars) private function add_section_vars($section_name, array $vars)
{ {
if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) { if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) {
$this->compiler->config_data['sections'][$section_name]['vars'] = Array(); $this->compiler->config_data['sections'][$section_name]['vars'] = array();
} }
foreach ($vars as $var) { foreach ($vars as $var) {
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]); $this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
@@ -238,7 +238,7 @@ class Smarty_Internal_Configfileparser
%stack_overflow %stack_overflow
{ {
$this->internalError = true; $this->internalError = true;
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser"); $this->compiler->trigger_config_file_error('Stack overflow in configfile parser');
} }
// Complete config file // Complete config file
@@ -279,17 +279,17 @@ var_list(res) ::= var_list(vl) newline. {
} }
var_list(res) ::= var_list(vl) var(v). { var_list(res) ::= var_list(vl) var(v). {
res = array_merge(vl, Array(v)); res = array_merge(vl, array(v));
} }
var_list(res) ::= . { var_list(res) ::= . {
res = Array(); res = array();
} }
// Var // Var
var(res) ::= ID(id) EQUAL value(v). { var(res) ::= ID(id) EQUAL value(v). {
res = Array("key" => id, "value" => v); res = array('key' => id, 'value' => v);
} }

View File

@@ -306,7 +306,7 @@ class Smarty_Internal_Templatelexer
aptr = ~\s*[=][>]\s*~ aptr = ~\s*[=][>]\s*~
singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~ singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~
backtick = ~[`]~ backtick = ~[`]~
vert = ~[|]~ vert = ~[|][@]?~
qmark = ~\s*[?]\s*~ qmark = ~\s*[?]\s*~
constant = ~[_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*(?![0-9A-Z_]*[a-z])~ constant = ~[_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*(?![0-9A-Z_]*[a-z])~
attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~ attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~
@@ -344,7 +344,7 @@ class Smarty_Internal_Templatelexer
if (isset($match[0][1])) { if (isset($match[0][1])) {
$to = $match[0][1] + strlen($match[0][0]); $to = $match[0][1] + strlen($match[0][0]);
} else { } else {
$this->compiler->trigger_template_error ("missing or misspelled comment closing tag '*{$this->smarty->getRightDelimiter()}'"); $this->compiler->trigger_template_error ("missing or misspelled comment closing tag '{$this->smarty->getRightDelimiter()}'");
} }
$this->value = substr($this->data,$this->counter,$to-$this->counter); $this->value = substr($this->data,$this->counter,$to-$this->counter);
return false; return false;

View File

@@ -173,7 +173,7 @@ class Smarty_Internal_Templateparser
*/ */
public function errorRunDown() public function errorRunDown()
{ {
while ($this->yystack !== Array()) { while ($this->yystack !== array()) {
$this->yy_pop_parser_stack(); $this->yy_pop_parser_stack();
} }
if (is_resource($this->yyTraceFILE)) { if (is_resource($this->yyTraceFILE)) {
@@ -237,139 +237,103 @@ start(res) ::= template. {
res = $this->root_buffer->to_smarty_php($this); res = $this->root_buffer->to_smarty_php($this);
} }
//
// loop over template elements
//
// single template element
template ::= template_element(e). {
if (e != null) {
$this->current_buffer->append_subtree($this, e);
}
}
// loop of elements
template ::= template template_element(e). {
if (e != null) {
// because of possible code injection
$this->current_buffer->append_subtree($this, e);
}
}
// empty template
template ::= .
//
// template elements
//
// Smarty tag
template_element(res)::= smartytag(st). {
if ($this->compiler->has_code) {
res = $this->mergePrefixCode(st);
} else {
res = null;
}
$this->compiler->has_variable_string = false;
$this->block_nesting_level = count($this->compiler->_tag_stack);
}
// Literal
template_element(res) ::= literal(l). {
res = new Smarty_Internal_ParseTree_Text(l);
}
// php tags // php tags
template_element(res)::= PHP(o). { template ::= template PHP(B). {
$code = $this->compiler->compileTag('private_php',array(array('code' => o), array('type' => $this->lex->phpType )),array()); $code = $this->compiler->compileTag('private_php',array(array('code' => B), array('type' => $this->lex->phpType )),array());
if ($this->compiler->has_code && !empty($code)) { if ($this->compiler->has_code && !empty($code)) {
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array(); $tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true)); $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true)));
} else {
res = null;
} }
} }
// template text // template text
template_element(res)::= text_content(t). { template ::= template TEXT(B). {
res = $this->compiler->processText(t); $this->current_buffer->append_subtree($this, $this->compiler->processText(B));
} }
text_content(res) ::= TEXT(o). {
res = o;
}
text_content(res) ::= text_content(t) TEXT(o). {
res = t . o;
}
// strip on // strip on
template_element ::= STRIPON(d). { template ::= template STRIPON. {
$this->strip = true; $this->strip = true;
} }
// strip off // strip off
template_element ::= STRIPOFF(d). { template ::= template STRIPOFF. {
$this->strip = false; $this->strip = false;
} }
// Litteral // Literal
literal(res) ::= LITERALSTART LITERALEND. { template ::= template LITERALSTART literal_e2(B) LITERALEND. {
res = ''; $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Text(B));
} }
literal(res) ::= LITERALSTART literal_elements(l) LITERALEND. {
res = l; literal_e2(A) ::= literal_e1(B) LITERALSTART literal_e1(C) LITERALEND. {
A = B.C;
} }
literal_e2(A) ::= literal_e1(B). {
literal_elements(res) ::= literal_elements(l1) literal_element(l2). { A = B;
res = l1.l2;
} }
literal_elements(res) ::= . { literal_e1(A) ::= literal_e1(B) LITERAL(C). {
res = ''; A = B.C;
} }
literal_element(res) ::= literal(l). { literal_e1(A) ::= . {
res = l; A = '';
}
// Smarty tag
template ::= template smartytag(B). {
if ($this->compiler->has_code) {
$this->current_buffer->append_subtree($this, $this->mergePrefixCode(B));
}
$this->compiler->has_variable_string = false;
$this->block_nesting_level = count($this->compiler->_tag_stack);
} }
literal_element(res) ::= LITERAL(l). {
res = l;
}
smartytag(res) ::= tag(t) RDEL. { // empty template
res = t; template ::= .
}
// smartytag(A) ::= SIMPELOUTPUT(B). {
// output tags start here $var = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
//
smartytag(res) ::= SIMPELOUTPUT(i). {
$var = trim(substr(i, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) { if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\''))); A = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\'')));
} else { } else {
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$this->compiler->compileVariable('\''.$var.'\''))); A = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$this->compiler->compileVariable('\''.$var.'\'')));
} }
} }
// simple tag like {name}
smartytag(A)::= SIMPLETAG(B). {
$tag = trim(substr(B, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
if ($tag == 'strip') {
$this->strip = true;
A = null;;
} else {
if (defined($tag)) {
if ($this->security) {
$this->security->isTrustedConstant($tag, $this->compiler);
}
A = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag));
} else {
if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) {
A = $this->compiler->compileTag($match[1],array("'nocache'"));
} else {
A = $this->compiler->compileTag($tag,array());
}
}
}
}
smartytag(A) ::= LDEL tagbody(B) RDEL. {
A = B;
}
smartytag(A) ::= tag(B) RDEL. {
A = B;
}
// output with optional attributes // output with optional attributes
tag(res) ::= LDEL variable(e). { tagbody(A) ::= outattr(B). {
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e)); A = $this->compiler->compileTag('private_print_expression',B[1],array('value'=>B[0]));
}
tag(res) ::= LDEL variable(e) attributes(a). {
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
}
tag(res) ::= LDEL value(e). {
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
}
tag(res) ::= LDEL value(e) attributes(a). {
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
}
tag(res) ::= LDEL expr(e). {
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
}
tag(res) ::= LDEL expr(e) attributes(a). {
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
} }
// //
@@ -377,42 +341,30 @@ tag(res) ::= LDEL expr(e) attributes(a). {
// //
// assign new style // assign new style
tag(res) ::= LDEL DOLLARID(i) EQUAL value(e). { tagbody(A) ::= DOLLARID(B) eqoutattr(C). {
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\''))); A = $this->compiler->compileTag('assign',array_merge(array(array('value'=>C[0]),array('var'=>'\''.substr(B,1).'\'')),C[1]));
}
tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e). {
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')));
}
tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e) attributes(a). {
res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')),a));
}
tag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). {
res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>vi['var'])),a),array('smarty_internal_index'=>vi['smarty_internal_index']));
} }
// simple tag like {name} tagbody(A) ::= varindexed(B) eqoutattr(C). {
smartytag(res)::= SIMPLETAG(t). { A = $this->compiler->compileTag('assign',array_merge(array(array('value'=>C[0]),array('var'=>B['var'])),C[1]),array('smarty_internal_index'=>B['smarty_internal_index']));
$tag = trim(substr(t, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength())); }
if ($tag === 'strip') {
$this->strip = true; eqoutattr(A) ::= EQUAL outattr(B). {
res = null;; A = B;
} else { }
if (defined($tag)) {
if ($this->security) { outattr(A) ::= output(B) attributes(C). {
$this->security->isTrustedConstant($tag, $this->compiler); A = array(B,C);
} }
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag));
} else { output(A) ::= variable(B). {
if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) { A = B;
res = $this->compiler->compileTag($match[1],array("'nocache'")); }
} else { output(A) ::= value(B). {
res = $this->compiler->compileTag($tag,array()); A = B;
} }
} output(A) ::= expr(B). {
} A = B;
} }
// tag with optional Smarty2 style attributes // tag with optional Smarty2 style attributes
@@ -776,7 +728,7 @@ value(res) ::= function(f). {
// expression // expression
value(res) ::= OPENP expr(e) CLOSEP. { value(res) ::= OPENP expr(e) CLOSEP. {
res = "(". e .")"; res = '('. e .')';
} }
value(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). { value(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
@@ -800,9 +752,9 @@ value(res) ::= doublequoted_with_quotes(s). {
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). { value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
$prefixVar = $this->compiler->getNewPrefixVariable(); $prefixVar = $this->compiler->getNewPrefixVariable();
if (vi['var'] === '\'smarty\'') { if (vi['var'] === '\'smarty\'') {
$this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>'); $this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
} else { } else {
$this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>'); $this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>');
} }
res = $prefixVar .'::'.r[0].r[1]; res = $prefixVar .'::'.r[0].r[1];
} }
@@ -811,7 +763,7 @@ value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
value(res) ::= smartytag(st). { value(res) ::= smartytag(st). {
$prefixVar = $this->compiler->getNewPrefixVariable(); $prefixVar = $this->compiler->getNewPrefixVariable();
$tmp = $this->compiler->appendCode('<?php ob_start();?>', st); $tmp = $this->compiler->appendCode('<?php ob_start();?>', st);
$this->compiler->appendPrefixCode($this->compiler->appendCode($tmp, "<?php $prefixVar" .'=ob_get_clean();?>')); $this->compiler->appendPrefixCode($this->compiler->appendCode($tmp, "<?php {$prefixVar} = ob_get_clean();?>"));
res = $prefixVar; res = $prefixVar;
} }
@@ -882,11 +834,11 @@ variable(res) ::= object(o). {
// config variable // config variable
variable(res) ::= HATCH ID(i) HATCH. { variable(res) ::= HATCH ID(i) HATCH. {
res = $this->compiler->compileConfigVariable("'" . i . "'"); res = $this->compiler->compileConfigVariable('\'' . i . '\'');
} }
variable(res) ::= HATCH ID(i) HATCH arrayindex(a). { variable(res) ::= HATCH ID(i) HATCH arrayindex(a). {
res = '(is_array($tmp = ' . $this->compiler->compileConfigVariable("'" . i . "'") . ') ? $tmp'.a.' :null)'; res = '(is_array($tmp = ' . $this->compiler->compileConfigVariable('\'' . i . '\'') . ') ? $tmp'.a.' :null)';
} }
variable(res) ::= HATCH variable(v) HATCH. { variable(res) ::= HATCH variable(v) HATCH. {
@@ -931,7 +883,7 @@ indexdef(res) ::= DOT varvar(v) AT ID(p). {
} }
indexdef(res) ::= DOT ID(i). { indexdef(res) ::= DOT ID(i). {
res = "['". i ."']"; res = '[\''. i .'\']';
} }
indexdef(res) ::= DOT INTEGER(n). { indexdef(res) ::= DOT INTEGER(n). {
@@ -988,7 +940,7 @@ varvar(res) ::= DOLLARID(i). {
} }
// single $ // single $
varvar(res) ::= DOLLAR. { varvar(res) ::= DOLLAR. {
res = "''"; res = '\'\'';
} }
// sequence of identifier elements // sequence of identifier elements
@@ -1081,7 +1033,7 @@ method(res) ::= ID(f) OPENP params(p) CLOSEP. {
if ($this->security && substr(f,0,1) === '_') { if ($this->security && substr(f,0,1) === '_') {
$this->compiler->trigger_template_error (self::Err1); $this->compiler->trigger_template_error (self::Err1);
} }
res = f . "(". implode(',',p) .")"; res = f . '('. implode(',',p) .')';
} }
method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. { method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. {
@@ -1089,7 +1041,7 @@ method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. {
$this->compiler->trigger_template_error (self::Err2); $this->compiler->trigger_template_error (self::Err2);
} }
$prefixVar = $this->compiler->getNewPrefixVariable(); $prefixVar = $this->compiler->getNewPrefixVariable();
$this->compiler->appendPrefixCode("<?php $prefixVar" .'='.$this->compiler->compileVariable('\''.substr(f,1).'\'').';?>'); $this->compiler->appendPrefixCode("<?php {$prefixVar} = ".$this->compiler->compileVariable('\''.substr(f,1).'\'').';?>');
res = $prefixVar .'('. implode(',',p) .')'; res = $prefixVar .'('. implode(',',p) .')';
} }
@@ -1260,7 +1212,7 @@ arrayelement(res) ::= expr(e). {
// double quoted strings // double quoted strings
// //
doublequoted_with_quotes(res) ::= QUOTE QUOTE. { doublequoted_with_quotes(res) ::= QUOTE QUOTE. {
res = "''"; res = '\'\'';
} }
doublequoted_with_quotes(res) ::= QUOTE doublequoted(s) QUOTE. { doublequoted_with_quotes(res) ::= QUOTE doublequoted(s) QUOTE. {

View File

@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.32-dev-31'; const SMARTY_VERSION = '3.1.32-dev-32';
/** /**
* define variable scopes * define variable scopes
*/ */

View File

@@ -21,12 +21,12 @@
*/ */
class Smarty_Internal_Configfilelexer class Smarty_Internal_Configfilelexer
{ {
const START = 1; const START = 1;
const VALUE = 2; const VALUE = 2;
const NAKED_STRING_VALUE = 3; const NAKED_STRING_VALUE = 3;
const COMMENT = 4; const COMMENT = 4;
const SECTION = 5; const SECTION = 5;
const TRIPPLE = 6; const TRIPPLE = 6;
/** /**
* Source * Source
* *
@@ -124,13 +124,13 @@ class Smarty_Internal_Configfilelexer
private $yy_global_pattern4 = null; private $yy_global_pattern4 = null;
private $yy_global_pattern5 = null; private $yy_global_pattern5 = null;
private $yy_global_pattern6 = null; private $yy_global_pattern6 = null;
private $_yy_state = 1; private $_yy_state = 1;
private $_yy_stack = array(); private $_yy_stack = array();
/** /**
* constructor * constructor
* *
* @param string $data template source * @param string $data template source
* @param Smarty_Internal_Config_File_Compiler $compiler * @param Smarty_Internal_Config_File_Compiler $compiler
*/ */
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler) function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
@@ -139,7 +139,7 @@ class Smarty_Internal_Configfilelexer
$this->dataLength = strlen($data); $this->dataLength = strlen($data);
$this->counter = 0; $this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) { if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
$this->counter += strlen($match[0]); $this->counter += strlen($match[ 0 ]);
} }
$this->line = 1; $this->line = 1;
$this->compiler = $compiler; $this->compiler = $compiler;
@@ -147,15 +147,61 @@ class Smarty_Internal_Configfilelexer
$this->configBooleanize = $this->smarty->config_booleanize; $this->configBooleanize = $this->smarty->config_booleanize;
} }
public function replace($input)
{
return $input;
} // end function
public function PrintTrace() public function PrintTrace()
{ {
$this->yyTraceFILE = fopen('php://output', 'w'); $this->yyTraceFILE = fopen('php://output', 'w');
$this->yyTracePrompt = '<br>'; $this->yyTracePrompt = '<br>';
} // end function }
public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
}
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState push %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState pop %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
}
/**
* @param $state
*/
public function yybegin($state) public function yybegin($state)
{ {
$this->_yy_state = $state; $this->_yy_state = $state;
@@ -168,10 +214,6 @@ class Smarty_Internal_Configfilelexer
} }
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex1() public function yylex1()
{ {
if (!isset($this->yy_global_pattern1)) { if (!isset($this->yy_global_pattern1)) {
@@ -184,19 +226,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state START'); 5) . '... state START');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -221,112 +262,56 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
}
/**
* @param $input
*
* @return mixed
*/
public function replace($input)
{
return $input;
}
/**
* @return mixed
*/
public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
} }
function yy_r1_1() function yy_r1_1()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART; $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
$this->yypushstate(self::COMMENT); $this->yypushstate(self::COMMENT);
} }
/**
* @param $state
*/
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState push %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
}
function yy_r1_2() function yy_r1_2()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB; $this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
$this->yypushstate(self::SECTION); $this->yypushstate(self::SECTION);
} }
function yy_r1_3() function yy_r1_3()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB; $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
} }
function yy_r1_4() function yy_r1_4()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL; $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
$this->yypushstate(self::VALUE); $this->yypushstate(self::VALUE);
} } // end function
/**
* @return bool
*/
function yy_r1_5() function yy_r1_5()
{ {
return false; return false;
} // end function }
function yy_r1_6() function yy_r1_6()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
} }
function yy_r1_7() function yy_r1_7()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_ID; $this->token = Smarty_Internal_Configfileparser::TPC_ID;
} }
function yy_r1_8() function yy_r1_8()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER; $this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex2() public function yylex2()
{ {
if (!isset($this->yy_global_pattern2)) { if (!isset($this->yy_global_pattern2)) {
@@ -339,19 +324,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state VALUE'); 5) . '... state VALUE');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -376,85 +360,52 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
} }
/**
* @return bool
*/
function yy_r2_1() function yy_r2_1()
{ {
return false; return false;
} }
function yy_r2_2() function yy_r2_2()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_FLOAT; $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
$this->yypopstate(); $this->yypopstate();
} }
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState pop %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
}
}
function yy_r2_3() function yy_r2_3()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_INT; $this->token = Smarty_Internal_Configfileparser::TPC_INT;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r2_4() function yy_r2_4()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES; $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
$this->yypushstate(self::TRIPPLE); $this->yypushstate(self::TRIPPLE);
} }
function yy_r2_5() function yy_r2_5()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r2_6() function yy_r2_6()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
$this->yypopstate(); $this->yypopstate();
} // end function } // end function
/**
* @return bool
*/
function yy_r2_7() function yy_r2_7()
{ {
if (!$this->configBooleanize || if (!$this->configBooleanize ||
!in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) { !in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))) {
$this->yypopstate(); $this->yypopstate();
$this->yypushstate(self::NAKED_STRING_VALUE); $this->yypushstate(self::NAKED_STRING_VALUE);
return true; //reprocess in new state return true; //reprocess in new state
@@ -466,23 +417,17 @@ class Smarty_Internal_Configfilelexer
function yy_r2_8() function yy_r2_8()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r2_9() function yy_r2_9()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->value = ""; $this->value = '';
$this->yypopstate(); $this->yypopstate();
} // end function } // end function
/**
* @return bool
* @throws \Exception
*/
public function yylex3() public function yylex3()
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
@@ -494,19 +439,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state NAKED_STRING_VALUE'); 5) . '... state NAKED_STRING_VALUE');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -531,24 +475,19 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
} }
function yy_r3_1() function yy_r3_1()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate(); $this->yypopstate();
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex4() public function yylex4()
{ {
if (!isset($this->yy_global_pattern4)) { if (!isset($this->yy_global_pattern4)) {
@@ -560,19 +499,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state COMMENT'); 5) . '... state COMMENT');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -597,39 +535,29 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
} }
/**
* @return bool
*/
function yy_r4_1() function yy_r4_1()
{ {
return false; return false;
} }
function yy_r4_2() function yy_r4_2()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
} // end function } // end function
function yy_r4_3() function yy_r4_3()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
$this->yypopstate(); $this->yypopstate();
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex5() public function yylex5()
{ {
if (!isset($this->yy_global_pattern5)) { if (!isset($this->yy_global_pattern5)) {
@@ -641,19 +569,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state SECTION'); 5) . '... state SECTION');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -678,30 +605,24 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
} }
function yy_r5_1() function yy_r5_1()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_DOT; $this->token = Smarty_Internal_Configfileparser::TPC_DOT;
} }
function yy_r5_2() function yy_r5_2()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_SECTION; $this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
$this->yypopstate(); $this->yypopstate();
} // end function } // end function
/**
* @return bool
* @throws \Exception
*/
public function yylex6() public function yylex6()
{ {
if (!isset($this->yy_global_pattern6)) { if (!isset($this->yy_global_pattern6)) {
@@ -713,19 +634,18 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . throw new Exception('Error: lexing failed because a rule matched' .
substr($this->data, ' an empty string. Input "' . substr($this->data,
$this->counter, $this->counter,
5) . '... state TRIPPLE'); 5) . '... state TRIPPLE');
} }
next($yymatches); // skip global match next($yymatches); // skip global match
$this->token = key($yymatches); // token number $this->token = key($yymatches); // token number
@@ -750,16 +670,15 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } 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; break;
} while (true); } while (true);
} }
function yy_r6_1() function yy_r6_1()
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END; $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
$this->yypopstate(); $this->yypopstate();
$this->yypushstate(self::START); $this->yypushstate(self::START);
@@ -767,17 +686,14 @@ class Smarty_Internal_Configfilelexer
function yy_r6_2() function yy_r6_2()
{ {
$to = strlen($this->data); $to = strlen($this->data);
preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) { if (isset($match[ 0 ][ 1 ])) {
$to = $match[0][1]; $to = $match[ 0 ][ 1 ];
} else { } else {
$this->compiler->trigger_template_error("missing or misspelled literal closing tag"); $this->compiler->trigger_template_error('missing or misspelled literal closing tag');
} }
$this->value = substr($this->data, $this->counter, $to - $this->counter); $this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -250,17 +250,11 @@ class Smarty_Internal_Templatelexer
strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false; strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false;
} // end function } // end function
/**
* @return mixed
*/
public function yylex() public function yylex()
{ {
return $this->{'yylex' . $this->_yy_state}(); return $this->{'yylex' . $this->_yy_state}();
} }
/**
* @param $state
*/
public function yypushstate($state) public function yypushstate($state)
{ {
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
@@ -300,9 +294,6 @@ class Smarty_Internal_Templatelexer
} }
} }
/**
* @param $state
*/
public function yybegin($state) public function yybegin($state)
{ {
$this->_yy_state = $state; $this->_yy_state = $state;
@@ -315,10 +306,6 @@ class Smarty_Internal_Templatelexer
} }
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex1() public function yylex1()
{ {
if (!isset($this->yy_global_pattern1)) { if (!isset($this->yy_global_pattern1)) {
@@ -379,17 +366,13 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
/**
* @return bool
* @throws \SmartyCompilerException
*/
function yy_r1_2() function yy_r1_2()
{ {
preg_match("/[*]{$this->compiler->getRdelPreg()}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); preg_match("/[*]{$this->compiler->getRdelPreg()}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[ 0 ][ 1 ])) { if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else { } else {
$this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->getRightDelimiter()}'"); $this->compiler->trigger_template_error("missing or misspelled comment closing tag '{$this->smarty->getRightDelimiter()}'");
} }
$this->value = substr($this->data, $this->counter, $to - $this->counter); $this->value = substr($this->data, $this->counter, $to - $this->counter);
return false; return false;
@@ -417,9 +400,6 @@ class Smarty_Internal_Templatelexer
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} // end function } // end function
/**
* @return bool
*/
function yy_r1_14() function yy_r1_14()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
@@ -436,10 +416,6 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex2() public function yylex2()
{ {
if (!isset($this->yy_global_pattern2)) { if (!isset($this->yy_global_pattern2)) {
@@ -572,15 +548,11 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex3() public function yylex3()
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = $this->yy_global_pattern3 =
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\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)\\s+)|\G(\\s+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([\S\s])/isS"); $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\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)\\s+)|\G(\\s+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([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -637,9 +609,6 @@ class Smarty_Internal_Templatelexer
$this->yypopstate(); $this->yypopstate();
} }
/**
* @return bool
*/
function yy_r3_2() function yy_r3_2()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
@@ -867,10 +836,6 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
/**
* @return bool
* @throws \Exception
*/
public function yylex4() public function yylex4()
{ {
if (!isset($this->yy_global_pattern4)) { if (!isset($this->yy_global_pattern4)) {
@@ -948,10 +913,6 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function } // end function
/**
* @return bool
* @throws \Exception
*/
public function yylex5() public function yylex5()
{ {
if (!isset($this->yy_global_pattern5)) { if (!isset($this->yy_global_pattern5)) {
@@ -1022,18 +983,12 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
/**
* @return bool
*/
function yy_r5_7() function yy_r5_7()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
/**
* @return bool
*/
function yy_r5_9() function yy_r5_9()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);

File diff suppressed because it is too large Load Diff