- PSR-2 code style fixes for config and template file Lexer/Parser generated with

the Smarty Lexer/Parser generator from https://github.com/smarty-php/smarty-lexer
    https://github.com/smarty-php/smarty/pull/483
This commit is contained in:
uwetews
2018-08-31 02:37:47 +02:00
parent 3a78a21f14
commit 7a8607fe17
8 changed files with 629 additions and 595 deletions

View File

@@ -1,4 +1,9 @@
===== 3.1.33-dev-7 =====
===== 3.1.33-dev-8 =====
31.08.2018
- PSR-2 code style fixes for config and template file Lexer/Parser generated with
the Smarty Lexer/Parser generator from https://github.com/smarty-php/smarty-lexer
https://github.com/smarty-php/smarty/pull/483
26.08.2018
- bugfix/enhancement {capture} allow variable as capture block name in Smarty special variable
like $smarty.capture.$foo https://github.com/smarty-php/smarty/issues/478 https://github.com/smarty-php/smarty/pull/481

View File

@@ -308,7 +308,7 @@ text {
if (isset($match[0][1])) {
$to = $match[0][1];
} else {
$this->compiler->trigger_template_error ('missing or misspelled literal closing tag');
$this->compiler->trigger_config_file_error ('missing or misspelled literal closing tag');
}
$this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;

View File

@@ -61,7 +61,7 @@ class Smarty_Internal_Templateparser
/**
* root parse tree buffer
*
* @var Smarty_Internal_ParseTree
* @var Smarty_Internal_ParseTree_Template
*/
public $root_buffer;

View File

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

View File

@@ -27,73 +27,86 @@ class Smarty_Internal_Configfilelexer
const COMMENT = 4;
const SECTION = 5;
const TRIPPLE = 6;
/**
* Source
*
* @var string
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLength = null;
/**
* byte counter
*
* @var int
*/
public $counter;
/**
* token number
*
* @var int
*/
public $token;
/**
* token value
*
* @var string
*/
public $value;
/**
* current line
*
* @var int
*/
public $line;
/**
* state number
*
* @var int
*/
public $state = 1;
/**
* Smarty object
*
* @var Smarty
*/
public $smarty = null;
/**
* trace file
*
* @var resource
*/
public $yyTraceFILE;
/**
* trace prompt
*
* @var string
*/
public $yyTracePrompt;
/**
* state names
*
* @var array
*/
public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION',
6 => 'TRIPPLE');
public $state_name = array(
1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE'
);
/**
* token names
*
@@ -101,30 +114,40 @@ class Smarty_Internal_Configfilelexer
*/
public $smarty_token_names = array( // Text for parser error messages
);
/**
* compiler object
*
* @var Smarty_Internal_Config_File_Compiler
*/
private $compiler = null;
/**
* copy of config_booleanize
*
* @var bool
*/
private $configBooleanize = false;
/**
* storage for assembled token patterns
*
* @var string
*/
private $yy_global_pattern1 = null;
private $yy_global_pattern2 = null;
private $yy_global_pattern3 = null;
private $yy_global_pattern4 = null;
private $yy_global_pattern5 = null;
private $yy_global_pattern6 = null;
private $_yy_state = 1;
private $_yy_stack = array();
/**
@@ -166,35 +189,27 @@ class Smarty_Internal_Configfilelexer
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);
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);
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);
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);
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);
}
}
@@ -202,10 +217,8 @@ class Smarty_Internal_Configfilelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState set %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -231,8 +244,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state START');
$this->counter, 5) . '... state START');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -264,45 +276,45 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r1_1()
public function yy_r1_1()
{
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
$this->yypushstate(self::COMMENT);
}
function yy_r1_2()
public function yy_r1_2()
{
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
$this->yypushstate(self::SECTION);
}
function yy_r1_3()
public function yy_r1_3()
{
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
}
function yy_r1_4()
public function yy_r1_4()
{
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
$this->yypushstate(self::VALUE);
} // end function
function yy_r1_5()
public function yy_r1_5()
{
return false;
}
function yy_r1_6()
public function yy_r1_6()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
}
function yy_r1_7()
public function yy_r1_7()
{
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
}
function yy_r1_8()
public function yy_r1_8()
{
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
}
@@ -329,8 +341,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state VALUE');
$this->counter, 5) . '... state VALUE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -362,42 +373,42 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r2_1()
public function yy_r2_1()
{
return false;
}
function yy_r2_2()
public function yy_r2_2()
{
$this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
$this->yypopstate();
}
function yy_r2_3()
public function yy_r2_3()
{
$this->token = Smarty_Internal_Configfileparser::TPC_INT;
$this->yypopstate();
}
function yy_r2_4()
public function yy_r2_4()
{
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
$this->yypushstate(self::TRIPPLE);
}
function yy_r2_5()
public function yy_r2_5()
{
$this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
$this->yypopstate();
}
function yy_r2_6()
public function yy_r2_6()
{
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
$this->yypopstate();
} // end function
function yy_r2_7()
public function yy_r2_7()
{
if (!$this->configBooleanize ||
!in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))) {
@@ -410,13 +421,13 @@ class Smarty_Internal_Configfilelexer
}
}
function yy_r2_8()
public function yy_r2_8()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate();
}
function yy_r2_9()
public function yy_r2_9()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->value = '';
@@ -444,8 +455,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state NAKED_STRING_VALUE');
$this->counter, 5) . '... state NAKED_STRING_VALUE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -477,7 +487,7 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r3_1()
public function yy_r3_1()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate();
@@ -504,8 +514,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state COMMENT');
$this->counter, 5) . '... state COMMENT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -537,17 +546,17 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r4_1()
public function yy_r4_1()
{
return false;
}
function yy_r4_2()
public function yy_r4_2()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
} // end function
function yy_r4_3()
public function yy_r4_3()
{
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
$this->yypopstate();
@@ -574,8 +583,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state SECTION');
$this->counter, 5) . '... state SECTION');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -607,12 +615,12 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r5_1()
public function yy_r5_1()
{
$this->token = Smarty_Internal_Configfileparser::TPC_DOT;
}
function yy_r5_2()
public function yy_r5_2()
{
$this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
$this->yypopstate();
@@ -639,8 +647,7 @@ class Smarty_Internal_Configfilelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state TRIPPLE');
$this->counter, 5) . '... state TRIPPLE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -672,21 +679,21 @@ class Smarty_Internal_Configfilelexer
} while (true);
}
function yy_r6_1()
public function yy_r6_1()
{
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
$this->yypopstate();
$this->yypushstate(self::START);
}
function yy_r6_2()
public function yy_r6_2()
{
$to = strlen($this->data);
preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ];
} else {
$this->compiler->trigger_template_error('missing or misspelled literal closing tag');
$this->compiler->trigger_config_file_error('missing or misspelled literal closing tag');
}
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;

View File

@@ -57,27 +57,32 @@ class Smarty_Internal_Configfileparser
const YYERRORSYMBOL = 19;
const YYERRSYMDT = 'yy0';
const YYFALLBACK = 0;
static public $yy_action = array(
public static $yy_action = array(
32, 31, 30, 29, 35, 13, 19, 3, 24, 26,
59, 9, 14, 1, 16, 25, 11, 28, 25, 11,
17, 27, 34, 20, 18, 15, 23, 5, 6, 22,
10, 8, 4, 12, 2, 33, 7, 21,
);
static public $yy_lookahead = array(
public static $yy_lookahead = array(
7, 8, 9, 10, 11, 12, 5, 23, 15, 16,
20, 21, 2, 23, 4, 17, 18, 14, 17, 18,
13, 14, 25, 26, 15, 2, 17, 3, 3, 17,
25, 25, 6, 1, 23, 27, 22, 24,
);
static public $yy_shift_ofst = array(
public static $yy_shift_ofst = array(
-8, 1, 1, 1, -7, -2, -2, 32, -8, -8,
-8, 9, 10, 7, 25, 24, 23, 3, 12, 26,
);
static public $yy_reduce_ofst = array(
public static $yy_reduce_ofst = array(
-10, -3, -3, -3, 8, 6, 5, 13, 11, 14,
-16,
);
static public $yyExpectedTokens = array(
public static $yyExpectedTokens = array(
array(),
array(5, 17, 18,),
array(5, 17, 18,),
@@ -115,13 +120,16 @@ class Smarty_Internal_Configfileparser
array(),
array(),
);
static public $yy_default = array(
public static $yy_default = array(
44, 37, 41, 40, 58, 58, 58, 36, 44, 39,
44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
43, 38, 57, 56, 53, 55, 54, 52, 51, 49,
48, 47, 46, 45, 42, 50,
);
public static $yyFallback = array();
public static $yyRuleName = array(
'start ::= global_vars sections',
'global_vars ::= var_list',
@@ -146,6 +154,7 @@ class Smarty_Internal_Configfileparser
'newline ::= COMMENTSTART NEWLINE',
'newline ::= COMMENTSTART NAKED_STRING NEWLINE',
);
public static $yyRuleInfo = array(
array(0 => 20, 1 => 2),
array(0 => 21, 1 => 1),
@@ -170,6 +179,7 @@ class Smarty_Internal_Configfileparser
array(0 => 25, 1 => 2),
array(0 => 25, 1 => 3),
);
public static $yyReduceMap = array(
0 => 0,
2 => 0,
@@ -194,46 +204,60 @@ class Smarty_Internal_Configfileparser
17 => 17,
18 => 17,
);
/**
* helper map
*
* @var array
*/
private static $escapes_single = array('\\' => '\\',
'\'' => '\'');
private static $escapes_single = array(
'\\' => '\\',
'\'' => '\''
);
/**
* result status
*
* @var bool
*/
public $successful = true;
/**
* return value
*
* @var mixed
*/
public $retvalue = 0;
/**
* @var
*/
public $yymajor;
/**
* compiler object
*
* @var Smarty_Internal_Config_File_Compiler
*/
public $compiler = null;
/**
* smarty object
*
* @var Smarty
*/
public $smarty = null;
public $yyTraceFILE;
public $yyTracePrompt;
public $yyidx;
public $yyerrcnt;
public $yystack = array();
public $yyTokenName = array(
'$', 'OPENB', 'SECTION', 'CLOSEB',
'DOT', 'ID', 'EQUAL', 'FLOAT',
@@ -243,30 +267,35 @@ class Smarty_Internal_Configfileparser
'start', 'global_vars', 'sections', 'var_list',
'section', 'newline', 'var', 'value',
);
/**
* lexer object
*
* @var Smarty_Internal_Configfilelexer
*/
private $lex;
/**
* internal error flag
*
* @var bool
*/
private $internalError = false;
/**
* copy of config_overwrite property
*
* @var bool
*/
private $configOverwrite = false;
/**
* copy of config_read_hidden property
*
* @var bool
*/
private $configReadHidden = false;
private $_retvalue;
/**
@@ -376,8 +405,8 @@ class Smarty_Internal_Configfileparser
$yytos = array_pop($this->yystack);
if ($this->yyTraceFILE && $this->yyidx >= 0) {
fwrite($this->yyTraceFILE,
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
"\n");
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
"\n");
}
$yymajor = $yytos->major;
self::yy_destructor($yymajor, $yytos->minor);
@@ -588,10 +617,9 @@ class Smarty_Internal_Configfileparser
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
&& ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0) {
if ($this->yyTraceFILE) {
fwrite($this->yyTraceFILE,
$this->yyTracePrompt . 'FALLBACK ' .
$this->yyTokenName[ $iLookAhead ] . ' => ' .
$this->yyTokenName[ $iFallback ] . "\n");
fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'FALLBACK ' .
$this->yyTokenName[ $iLookAhead ] . ' => ' .
$this->yyTokenName[ $iFallback ] . "\n");
}
return $this->yy_find_shift_action($iFallback);
}
@@ -645,118 +673,117 @@ class Smarty_Internal_Configfileparser
$yytos->minor = $yypMinor;
$this->yystack[] = $yytos;
if ($this->yyTraceFILE && $this->yyidx > 0) {
fprintf($this->yyTraceFILE,
"%sShift %d\n",
$this->yyTracePrompt,
$yyNewState);
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt,
$yyNewState);
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
for ($i = 1; $i <= $this->yyidx; $i++) {
fprintf($this->yyTraceFILE,
" %s",
$this->yyTokenName[ $this->yystack[ $i ]->major ]);
fprintf($this->yyTraceFILE, " %s",
$this->yyTokenName[ $this->yystack[ $i ]->major ]);
}
fwrite($this->yyTraceFILE, "\n");
}
}
function yy_r0()
public function yy_r0()
{
$this->_retvalue = null;
}
function yy_r1()
public function yy_r1()
{
$this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor);
$this->_retvalue = null;
}
function yy_r4()
public function yy_r4()
{
$this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor);
$this->_retvalue = null;
}
// line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r5()
public function yy_r5()
{
if ($this->configReadHidden) {
$this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor,
$this->yystack[ $this->yyidx + 0 ]->minor);
$this->yystack[ $this->yyidx + 0 ]->minor);
}
$this->_retvalue = null;
}
// line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r6()
public function yy_r6()
{
$this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor;
}
// line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r7()
public function yy_r7()
{
$this->_retvalue =
array_merge($this->yystack[ $this->yyidx + -1 ]->minor, array($this->yystack[ $this->yyidx + 0 ]->minor));
}
// line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r8()
public function yy_r8()
{
$this->_retvalue = array();
}
// line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r9()
public function yy_r9()
{
$this->_retvalue =
array('key' => $this->yystack[ $this->yyidx + -2 ]->minor,
'value' => $this->yystack[ $this->yyidx + 0 ]->minor);
array(
'key' => $this->yystack[ $this->yyidx + -2 ]->minor,
'value' => $this->yystack[ $this->yyidx + 0 ]->minor
);
}
// line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r10()
public function yy_r10()
{
$this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor;
}
// line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r11()
public function yy_r11()
{
$this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor;
}
// line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r12()
public function yy_r12()
{
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
}
// line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r13()
public function yy_r13()
{
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
// line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r14()
public function yy_r14()
{
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
// line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r15()
public function yy_r15()
{
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor);
}
// line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r16()
public function yy_r16()
{
$this->_retvalue = '';
}
// line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r17()
public function yy_r17()
{
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
}
@@ -766,11 +793,9 @@ class Smarty_Internal_Configfileparser
{
if ($this->yyTraceFILE && $yyruleno >= 0
&& $yyruleno < count(self::$yyRuleName)) {
fprintf($this->yyTraceFILE,
"%sReduce (%d) [%s].\n",
$this->yyTracePrompt,
$yyruleno,
self::$yyRuleName[ $yyruleno ]);
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n",
$this->yyTracePrompt, $yyruleno,
self::$yyRuleName[ $yyruleno ]);
}
$this->_retvalue = $yy_lefthand_side = null;
if (isset(self::$yyReduceMap[ $yyruleno ])) {
@@ -851,10 +876,8 @@ class Smarty_Internal_Configfileparser
}
$yyendofinput = ($yymajor == 0);
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sInput %s\n",
$this->yyTracePrompt,
$this->yyTokenName[ $yymajor ]);
fprintf($this->yyTraceFILE, "%sInput %s\n",
$this->yyTracePrompt, $this->yyTokenName[ $yymajor ]);
}
do {
$yyact = $this->yy_find_shift_action($yymajor);
@@ -875,9 +898,8 @@ class Smarty_Internal_Configfileparser
$this->yy_reduce($yyact - self::YYNSTATE);
} elseif ($yyact === self::YY_ERROR_ACTION) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sSyntax Error!\n",
$this->yyTracePrompt);
fprintf($this->yyTraceFILE, "%sSyntax Error!\n",
$this->yyTracePrompt);
}
if (self::YYERRORSYMBOL) {
if ($this->yyerrcnt < 0) {
@@ -886,10 +908,8 @@ class Smarty_Internal_Configfileparser
$yymx = $this->yystack[ $this->yyidx ]->major;
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sDiscard input token %s\n",
$this->yyTracePrompt,
$this->yyTokenName[ $yymajor ]);
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n",
$this->yyTracePrompt, $this->yyTokenName[ $yymajor ]);
}
$this->yy_destructor($yymajor, $yytokenvalue);
$yymajor = self::YYNOCODE;

View File

@@ -23,96 +23,112 @@ class Smarty_Internal_Templatelexer
const TAGBODY = 3;
const LITERAL = 4;
const DOUBLEQUOTEDSTRING = 5;
/**
* Source
*
* @var string
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLength = null;
/**
* byte counter
*
* @var int
*/
public $counter;
/**
* token number
*
* @var int
*/
public $token;
/**
* token value
*
* @var string
*/
public $value;
/**
* current line
*
* @var int
*/
public $line;
/**
* tag start line
*
* @var
*/
public $taglineno;
/**
* php code type
*
* @var string
*/
public $phpType = '';
/**
* state number
*
* @var int
*/
public $state = 1;
/**
* Smarty object
*
* @var Smarty
*/
public $smarty = null;
/**
* compiler object
*
* @var Smarty_Internal_TemplateCompilerBase
*/
public $compiler = null;
/**
* trace file
*
* @var resource
*/
public $yyTraceFILE;
/**
* trace prompt
*
* @var string
*/
public $yyTracePrompt;
/**
* XML flag true while processing xml
*
* @var bool
*/
public $is_xml = false;
/**
* state names
*
* @var array
*/
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
/**
* token names
*
@@ -156,43 +172,51 @@ class Smarty_Internal_Templatelexer
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
'SCOND' => '"is even" ... if condition',
);
/**
* literal tag nesting level
*
* @var int
*/
private $literal_cnt = 0;
/**
* preg token pattern for state TEXT
*
* @var string
*/
private $yy_global_pattern1 = null;
/**
* preg token pattern for state TAG
*
* @var string
*/
private $yy_global_pattern2 = null;
/**
* preg token pattern for state TAGBODY
*
* @var string
*/
private $yy_global_pattern3 = null;
/**
* preg token pattern for state LITERAL
*
* @var string
*/
private $yy_global_pattern4 = null;
/**
* preg token pattern for state DOUBLEQUOTEDSTRING
*
* @var null
*/
private $yy_global_pattern5 = null;
private $_yy_state = 1;
private $_yy_stack = array();
/**
@@ -258,35 +282,27 @@ class Smarty_Internal_Templatelexer
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);
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);
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);
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);
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);
}
}
@@ -294,10 +310,8 @@ class Smarty_Internal_Templatelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState set %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -323,8 +337,7 @@ class Smarty_Internal_Templatelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state TEXT');
$this->counter, 5) . '... state TEXT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -356,18 +369,15 @@ class Smarty_Internal_Templatelexer
} while (true);
}
function yy_r1_1()
public function yy_r1_1()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r1_2()
public function yy_r1_2()
{
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",
$this->data,
$match,
PREG_OFFSET_CAPTURE,
$this->counter);
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", $this->data, $match, PREG_OFFSET_CAPTURE,
$this->counter);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else {
@@ -377,40 +387,40 @@ class Smarty_Internal_Templatelexer
return false;
}
function yy_r1_4()
public function yy_r1_4()
{
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
function yy_r1_8()
public function yy_r1_8()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r1_10()
public function yy_r1_10()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL);
}
function yy_r1_12()
public function yy_r1_12()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL);
} // end function
function yy_r1_14()
public function yy_r1_14()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r1_16()
public function yy_r1_16()
{
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
function yy_r1_19()
public function yy_r1_19()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
@@ -437,8 +447,7 @@ class Smarty_Internal_Templatelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state TAG');
$this->counter, 5) . '... state TAG');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -470,63 +479,63 @@ class Smarty_Internal_Templatelexer
} while (true);
}
function yy_r2_1()
public function yy_r2_1()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_4()
public function yy_r2_4()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_6()
public function yy_r2_6()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_8()
public function yy_r2_8()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_10()
public function yy_r2_10()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_12()
public function yy_r2_12()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
$this->taglineno = $this->line;
}
function yy_r2_15()
public function yy_r2_15()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line;
}
function yy_r2_18()
public function yy_r2_18()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line;
}
function yy_r2_20()
public function yy_r2_20()
{
if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] === self::TEXT) {
$this->yypopstate();
@@ -540,14 +549,14 @@ class Smarty_Internal_Templatelexer
}
} // end function
function yy_r2_23()
public function yy_r2_23()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_25()
public function yy_r2_25()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY);
@@ -576,8 +585,7 @@ class Smarty_Internal_Templatelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state TAGBODY');
$this->counter, 5) . '... state TAGBODY');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -609,156 +617,156 @@ class Smarty_Internal_Templatelexer
} while (true);
}
function yy_r3_1()
public function yy_r3_1()
{
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate();
}
function yy_r3_2()
public function yy_r3_2()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r3_4()
public function yy_r3_4()
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote();
}
function yy_r3_5()
public function yy_r3_5()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
}
function yy_r3_6()
public function yy_r3_6()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
function yy_r3_7()
public function yy_r3_7()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
}
function yy_r3_8()
public function yy_r3_8()
{
$this->token = Smarty_Internal_Templateparser::TP_ISIN;
}
function yy_r3_9()
public function yy_r3_9()
{
$this->token = Smarty_Internal_Templateparser::TP_AS;
}
function yy_r3_10()
public function yy_r3_10()
{
$this->token = Smarty_Internal_Templateparser::TP_TO;
}
function yy_r3_11()
public function yy_r3_11()
{
$this->token = Smarty_Internal_Templateparser::TP_STEP;
}
function yy_r3_12()
public function yy_r3_12()
{
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
}
function yy_r3_13()
public function yy_r3_13()
{
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
}
function yy_r3_15()
public function yy_r3_15()
{
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
}
function yy_r3_17()
public function yy_r3_17()
{
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
}
function yy_r3_20()
public function yy_r3_20()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
}
function yy_r3_23()
public function yy_r3_23()
{
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
function yy_r3_24()
public function yy_r3_24()
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
function yy_r3_28()
public function yy_r3_28()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
function yy_r3_29()
public function yy_r3_29()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
function yy_r3_30()
public function yy_r3_30()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
function yy_r3_31()
public function yy_r3_31()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
function yy_r3_32()
public function yy_r3_32()
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
function yy_r3_33()
public function yy_r3_33()
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
function yy_r3_34()
public function yy_r3_34()
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
function yy_r3_35()
public function yy_r3_35()
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
function yy_r3_37()
public function yy_r3_37()
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
function yy_r3_39()
public function yy_r3_39()
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
function yy_r3_41()
public function yy_r3_41()
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
function yy_r3_42()
public function yy_r3_42()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
function yy_r3_43()
public function yy_r3_43()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
@@ -771,73 +779,73 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r3_44()
public function yy_r3_44()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}
function yy_r3_47()
public function yy_r3_47()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
function yy_r3_48()
public function yy_r3_48()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
function yy_r3_49()
public function yy_r3_49()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
function yy_r3_50()
public function yy_r3_50()
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r3_51()
public function yy_r3_51()
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r3_52()
public function yy_r3_52()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r3_53()
public function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r3_54()
public function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r3_55()
public function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r3_56()
public function yy_r3_56()
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r3_57()
public function yy_r3_57()
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r3_58()
public function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function
function yy_r3_59()
public function yy_r3_59()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
@@ -864,8 +872,7 @@ class Smarty_Internal_Templatelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state LITERAL');
$this->counter, 5) . '... state LITERAL');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -897,13 +904,13 @@ class Smarty_Internal_Templatelexer
} while (true);
}
function yy_r4_1()
public function yy_r4_1()
{
$this->literal_cnt++;
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
function yy_r4_3()
public function yy_r4_3()
{
if ($this->literal_cnt) {
$this->literal_cnt--;
@@ -914,7 +921,7 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r4_5()
public function yy_r4_5()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function
@@ -941,8 +948,7 @@ class Smarty_Internal_Templatelexer
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter,
5) . '... state DOUBLEQUOTEDSTRING');
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -974,47 +980,47 @@ class Smarty_Internal_Templatelexer
} while (true);
}
function yy_r5_1()
public function yy_r5_1()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_3()
public function yy_r5_3()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_5()
public function yy_r5_5()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_7()
public function yy_r5_7()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_9()
public function yy_r5_9()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_11()
public function yy_r5_11()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->taglineno = $this->line;
$this->yypushstate(self::TAGBODY);
}
function yy_r5_13()
public function yy_r5_13()
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate();
}
function yy_r5_14()
public function yy_r5_14()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->value = substr($this->value, 0, -1);
@@ -1022,17 +1028,17 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
function yy_r5_15()
public function yy_r5_15()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
function yy_r5_16()
public function yy_r5_16()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_17()
public function yy_r5_17()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}

File diff suppressed because it is too large Load Diff