mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
- added optional nocache attribute to {block} tags in parent template
- updated <?php...?> handling supporting now heredocs and newdocs. (thanks to Thue Jnaus Kristensen)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
01/11/2010
|
||||
- added \n to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source
|
||||
- added missing support of insert plugins
|
||||
- added optional nocache attribute to {block} tags in parent template
|
||||
- updated <?php...?> handling supporting now heredocs and newdocs. (thanks to Thue Jnaus Kristensen)
|
||||
|
||||
01/09/2010
|
||||
- bugfix on nocache {block} tags in parent templates
|
||||
|
@@ -23,11 +23,17 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('assign');
|
||||
$this->optional_attributes = array('assign','nocache');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code, $this->compiler->nocache);
|
||||
$this->_open_tag('block', $save);
|
||||
if (isset($_attr['nocache'])) {
|
||||
if ($_attr['nocache'] == 'true') {
|
||||
$compiler->nocache = true;
|
||||
}
|
||||
}
|
||||
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = '';
|
||||
$compiler->has_code = false;
|
||||
@@ -91,7 +97,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
||||
$_output = $compiler->template->extracted_compiled_code;
|
||||
}
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
$compiler->nocache = $saved_data[3];
|
||||
// $_output content has already nocache code processed
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return $_output;
|
||||
|
@@ -21,6 +21,7 @@ class Smarty_Internal_Templatelexer
|
||||
public $taglineno;
|
||||
public $state = 1;
|
||||
public $strip = false;
|
||||
private $heredoc_id_stack = Array();
|
||||
public $smarty_token_names = array ( // Text for parser error messages
|
||||
'IDENTITY' => '===',
|
||||
'NONEIDENTITY' => '!==',
|
||||
@@ -805,7 +806,7 @@ class Smarty_Internal_Templatelexer
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\?>)|^(([\S\s]*?)\\?>)|^([\S\s]+)/";
|
||||
$yy_global_pattern = "/^(\\?>)|^([\s\S]+?(\\?>|\/\\*|'|\"|<<<\\s*'?\\w+'?\r?\n|\/\/|#))|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
@@ -858,14 +859,45 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r3_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
|
||||
$this->yypopstate();
|
||||
}
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r3_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->value = substr($this->value,0,-2);
|
||||
switch ($yy_subpatterns[0]) {
|
||||
case '?>':
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->value = substr($this->value, 0, -2);
|
||||
break;
|
||||
case "'":
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
|
||||
break;
|
||||
case '"':
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
|
||||
$this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
|
||||
break;
|
||||
case '/*':
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypushstate(self::PHP_ML_COMMENT);
|
||||
break;
|
||||
case '//':
|
||||
case '#':
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypushstate(self::PHP_SL_COMMENT);
|
||||
break;
|
||||
default:
|
||||
$res = preg_match('/\A<<<\s*\'?(\w+)(\'?)\r?\n\z/', $yy_subpatterns[0], $matches);
|
||||
assert($res === 1);
|
||||
$is_nowdoc = $matches[2] === "'";
|
||||
$this->token = $is_nowdoc
|
||||
? Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START
|
||||
: Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
|
||||
$this->heredoc_id_stack[] = $matches[1];
|
||||
$this->yypushstate($is_nowdoc ? self::PHP_NOWDOC : self::PHP_HEREDOC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
function yy_r3_4($yy_subpatterns)
|
||||
{
|
||||
@@ -879,15 +911,11 @@ class Smarty_Internal_Templatelexer
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 1,
|
||||
7 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^([\S\s]+?(".$this->ldel."\/?literal".$this->rdel."|<\\?))|^([\S\s]+)/";
|
||||
$yy_global_pattern = "/^([\s\S]*\\*\/)|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
@@ -896,7 +924,7 @@ class Smarty_Internal_Templatelexer
|
||||
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');
|
||||
$this->counter, 5) . '... state PHP_ML_COMMENT');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -936,54 +964,17 @@ class Smarty_Internal_Templatelexer
|
||||
} // end function
|
||||
|
||||
|
||||
const LITERAL = 4;
|
||||
const PHP_ML_COMMENT = 4;
|
||||
function yy_r4_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
|
||||
$this->yypushstate(self::LITERAL);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r4_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r4_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
|
||||
$this->value = substr($this->value, 0, 2);
|
||||
}
|
||||
}
|
||||
function yy_r4_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
}
|
||||
function yy_r4_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$lenght_literal = strlen($this->smarty->left_delimiter.$this->smarty->right_delimiter)+7;
|
||||
if (substr($this->value,-2,2) === '<?') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-2);
|
||||
} else if (substr($this->value,-$lenght_literal,$lenght_literal) === $this->smarty->left_delimiter.'literal'.$this->smarty->right_delimiter) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-$lenght_literal);
|
||||
} else {
|
||||
assert(substr($this->value,-$lenght_literal-1,$lenght_literal+1) === $this->smarty->left_delimiter.'/literal'.$this->smarty->right_delimiter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-$lenght_literal-1);
|
||||
}
|
||||
}
|
||||
function yy_r4_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
|
||||
$this->compiler->trigger_template_error("missing PHP comment end */");
|
||||
}
|
||||
|
||||
|
||||
@@ -992,19 +983,11 @@ class Smarty_Internal_Templatelexer
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 2,
|
||||
12 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$\\w+)|^(\\$)|^(([\S\s]*?)(".$this->ldel."|\\$|`\\$|\\\\\\\\|[^\\\\]\"))|^([\S\s]+)/";
|
||||
$yy_global_pattern = "/^(.+?(?=\\?>|\n))|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
@@ -1013,7 +996,7 @@ class Smarty_Internal_Templatelexer
|
||||
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');
|
||||
$this->counter, 5) . '... state PHP_SL_COMMENT');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -1053,10 +1036,720 @@ class Smarty_Internal_Templatelexer
|
||||
} // end function
|
||||
|
||||
|
||||
const DOUBLEQUOTEDSTRING = 5;
|
||||
const PHP_SL_COMMENT = 5;
|
||||
function yy_r5_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r5_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
/* this can happen for "//?>" */
|
||||
$this->yypopstate();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function yylex6()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^([^\n]*\n)|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_NOWDOC');
|
||||
}
|
||||
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);
|
||||
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
|
||||
|
||||
|
||||
const PHP_NOWDOC = 6;
|
||||
function yy_r6_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
|
||||
if ( $this->value === $heredoc_id."\n"
|
||||
|| $this->value === $heredoc_id."\r\n"
|
||||
|| $this->value === $heredoc_id.";\n"
|
||||
|| $this->value === $heredoc_id.";\r\n"
|
||||
) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_END;
|
||||
array_pop($this->heredoc_id_stack);
|
||||
$this->yypopstate();
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
|
||||
}
|
||||
}
|
||||
function yy_r6_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error("missing PHP NOWDOC end");
|
||||
}
|
||||
|
||||
|
||||
function yylex7()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\{\\$|\\{\\$)|^([^\n]*\n)|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_HEREDOC');
|
||||
}
|
||||
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);
|
||||
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
|
||||
|
||||
|
||||
const PHP_HEREDOC = 7;
|
||||
function yy_r7_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
|
||||
$this->yypushstate(self::PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED);
|
||||
$this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);
|
||||
}
|
||||
function yy_r7_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
|
||||
if ( $this->value === $heredoc_id."\n"
|
||||
|| $this->value === $heredoc_id."\r\n"
|
||||
|| $this->value === $heredoc_id.";\n"
|
||||
|| $this->value === $heredoc_id.";\r\n"
|
||||
) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_END;
|
||||
array_pop($this->heredoc_id_stack);
|
||||
$this->yypopstate();
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
|
||||
if (preg_match('/(.*?)(\{\$\|\$\{)/', $this->value, $matches)) {
|
||||
$this->value = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
function yy_r7_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error("missing PHP HEREDOC end");
|
||||
}
|
||||
|
||||
|
||||
function yylex8()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^([^\n]*\n)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED');
|
||||
}
|
||||
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_r8_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED = 8;
|
||||
function yy_r8_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->yypopstate();
|
||||
$heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
|
||||
if ( $this->value === $heredoc_id."\n"
|
||||
|| $this->value === $heredoc_id."\r\n"
|
||||
|| $this->value === $heredoc_id.";\n"
|
||||
|| $this->value === $heredoc_id.";\r\n"
|
||||
) {
|
||||
//Make sure it isn't interpreted as HEREDOC end.
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
|
||||
} else {
|
||||
return true; //retry in PHP_HEREDOC state
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function yylex9()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^((?:[^\\\\']|\\\\.)*')|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_SINGLE_QUOTED_STRING');
|
||||
}
|
||||
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_r9_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const PHP_SINGLE_QUOTED_STRING = 9;
|
||||
function yy_r9_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r9_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error("missing PHP single quoted string end");
|
||||
}
|
||||
|
||||
|
||||
function yylex10()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\{\\$|\\{\\$)|^(\")|^((?:\\\\.|[^\"\\\\])+?(?=\"|\\{\\$|\\$\\{))|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_DOUBLE_QUOTED_STRING');
|
||||
}
|
||||
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_r10_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const PHP_DOUBLE_QUOTED_STRING = 10;
|
||||
function yy_r10_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
|
||||
$this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);
|
||||
}
|
||||
function yy_r10_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_DOUBLEQUOTE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r10_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
|
||||
}
|
||||
function yy_r10_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error("missing PHP double quoted string end");
|
||||
}
|
||||
|
||||
|
||||
function yylex11()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\")|^(')|^(<<<\\s*\\w+\r?\n)|^(<<<\\s*'\\w+'\r?\n)|^(\\})|^([^'\"}]+?(?='|\"|\\}|<<<\\s*'?\\w+'?\r?\n))/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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 PHP_DOUBLE_QUOTED_STRING_EMBEDDED');
|
||||
}
|
||||
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_r11_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const PHP_DOUBLE_QUOTED_STRING_EMBEDDED = 11;
|
||||
function yy_r11_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
|
||||
$this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
|
||||
}
|
||||
function yy_r11_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
$this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
|
||||
}
|
||||
function yy_r11_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
|
||||
$res = preg_match('/\A\<\<\<\s*(\w+)\r?\n\z/', $this->value, $matches);
|
||||
assert($res === 1);
|
||||
$this->heredoc_id_stack[] = $matches[1];
|
||||
$this->yypushstate(self::PHP_HEREDOC);
|
||||
}
|
||||
function yy_r11_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START;
|
||||
$res = preg_match('/\A\<\<\<\s*\'(\w+)\'\r?\n\z/', $this->value, $matches);
|
||||
assert($res === 1);
|
||||
$this->heredoc_id_stack[] = $matches[1];
|
||||
$this->yypushstate(self::PHP_NOWDOC);
|
||||
}
|
||||
function yy_r11_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_END;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r11_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function yylex12()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 1,
|
||||
7 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^([\S\s]+?(".$this->ldel."\/?literal".$this->rdel."|<\\?))|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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');
|
||||
}
|
||||
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_r12_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const LITERAL = 12;
|
||||
function yy_r12_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
|
||||
$this->yypushstate(self::LITERAL);
|
||||
}
|
||||
function yy_r12_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r12_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
|
||||
$this->value = substr($this->value, 0, 2);
|
||||
}
|
||||
}
|
||||
function yy_r12_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
}
|
||||
function yy_r12_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$lenght_literal = strlen($this->smarty->left_delimiter.$this->smarty->right_delimiter)+7;
|
||||
if (substr($this->value,-2,2) === '<?') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-2);
|
||||
} else if (substr($this->value,-$lenght_literal,$lenght_literal) === $this->smarty->left_delimiter.'literal'.$this->smarty->right_delimiter) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-$lenght_literal);
|
||||
} else {
|
||||
assert(substr($this->value,-$lenght_literal-1,$lenght_literal+1) === $this->smarty->left_delimiter.'/literal'.$this->smarty->right_delimiter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
$this->value = substr($this->value,0,-$lenght_literal-1);
|
||||
}
|
||||
}
|
||||
function yy_r12_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
|
||||
}
|
||||
|
||||
|
||||
function yylex13()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 2,
|
||||
12 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$\\w+)|^(\\$)|^(([\S\s]*?)(".$this->ldel."|\\$|`\\$|\\\\\\\\|[^\\\\]\"))|^([\S\s]+)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
|
||||
$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');
|
||||
}
|
||||
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_r13_' . $this->token}($yysubmatches);
|
||||
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
|
||||
|
||||
|
||||
const DOUBLEQUOTEDSTRING = 13;
|
||||
function yy_r13_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
} else {
|
||||
@@ -1065,7 +1758,7 @@ class Smarty_Internal_Templatelexer
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r5_2($yy_subpatterns)
|
||||
function yy_r13_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
@@ -1076,27 +1769,27 @@ class Smarty_Internal_Templatelexer
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r5_3($yy_subpatterns)
|
||||
function yy_r13_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
function yy_r5_4($yy_subpatterns)
|
||||
function yy_r13_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
function yy_r5_5($yy_subpatterns)
|
||||
function yy_r13_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r5_6($yy_subpatterns)
|
||||
function yy_r13_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
|
||||
@@ -1104,17 +1797,17 @@ class Smarty_Internal_Templatelexer
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
function yy_r5_7($yy_subpatterns)
|
||||
function yy_r13_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
|
||||
}
|
||||
function yy_r5_8($yy_subpatterns)
|
||||
function yy_r13_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
}
|
||||
function yy_r5_9($yy_subpatterns)
|
||||
function yy_r13_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
@@ -1129,7 +1822,7 @@ class Smarty_Internal_Templatelexer
|
||||
return true; // rescan
|
||||
}
|
||||
}
|
||||
function yy_r5_12($yy_subpatterns)
|
||||
function yy_r13_12($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user