mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-05 12:14:12 +02:00
- fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452
https://github.com/smarty-php/smarty/pull/475 https://github.com/smarty-php/smarty/pull/473 - bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472
This commit is contained in:
@@ -13,14 +13,15 @@
|
||||
* This is the template file lexer.
|
||||
* It is generated from the smarty_internal_templatelexer.plex file
|
||||
*
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Templatelexer
|
||||
{
|
||||
const TEXT = 1;
|
||||
const TAG = 2;
|
||||
const TAGBODY = 3;
|
||||
const LITERAL = 4;
|
||||
const TEXT = 1;
|
||||
const TAG = 2;
|
||||
const TAGBODY = 3;
|
||||
const LITERAL = 4;
|
||||
const DOUBLEQUOTEDSTRING = 5;
|
||||
/**
|
||||
* Source
|
||||
@@ -191,16 +192,16 @@ class Smarty_Internal_Templatelexer
|
||||
* @var null
|
||||
*/
|
||||
private $yy_global_pattern5 = null;
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $source template source
|
||||
* @param string $source template source
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*/
|
||||
function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$this->data = $source;
|
||||
$this->dataLength = strlen($this->data);
|
||||
@@ -218,6 +219,7 @@ class Smarty_Internal_Templatelexer
|
||||
|
||||
/**
|
||||
* open lexer/parser trace file
|
||||
*
|
||||
*/
|
||||
public function PrintTrace()
|
||||
{
|
||||
@@ -237,11 +239,11 @@ class Smarty_Internal_Templatelexer
|
||||
return $this->compiler->replaceDelimiter($preg);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if current value is an autoliteral left delimiter
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
/**
|
||||
* check if current value is an autoliteral left delimiter
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoLiteral()
|
||||
{
|
||||
return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ?
|
||||
@@ -256,47 +258,35 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,13 +294,10 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,14 +321,10 @@ class Smarty_Internal_Templatelexer
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
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'
|
||||
);
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter,
|
||||
5) . '... state TEXT');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -352,11 +335,11 @@ class Smarty_Internal_Templatelexer
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
// accept this token
|
||||
return true;
|
||||
} else if ($r === true) {
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} else if ($r === false) {
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
@@ -366,10 +349,8 @@ class Smarty_Internal_Templatelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]
|
||||
);
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
@@ -382,13 +363,11 @@ class Smarty_Internal_Templatelexer
|
||||
|
||||
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 {
|
||||
@@ -456,14 +435,10 @@ class Smarty_Internal_Templatelexer
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
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'
|
||||
);
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter,
|
||||
5) . '... state TAG');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -474,11 +449,11 @@ class Smarty_Internal_Templatelexer
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
// accept this token
|
||||
return true;
|
||||
} else if ($r === true) {
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} else if ($r === false) {
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
@@ -488,10 +463,8 @@ class Smarty_Internal_Templatelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]
|
||||
);
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
@@ -601,14 +574,10 @@ class Smarty_Internal_Templatelexer
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
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'
|
||||
);
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter,
|
||||
5) . '... state TAGBODY');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
@@ -619,11 +588,11 @@ class Smarty_Internal_Templatelexer
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
// accept this token
|
||||
return true;
|
||||
} else if ($r === true) {
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} else if ($r === false) {
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
@@ -633,10 +602,8 @@ class Smarty_Internal_Templatelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]
|
||||
);
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
@@ -794,8 +761,8 @@ class Smarty_Internal_Templatelexer
|
||||
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()) === $this->smarty->getRightDelimiter()
|
||||
) {
|
||||
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
|
||||
$this->smarty->getRightDelimiter()) {
|
||||
preg_match('/\s+/', $this->value, $match);
|
||||
$this->value = $match[ 0 ];
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
|
||||
@@ -895,14 +862,10 @@ class Smarty_Internal_Templatelexer
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
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'
|
||||
);
|
||||
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
|
||||
@@ -913,11 +876,11 @@ class Smarty_Internal_Templatelexer
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
// accept this token
|
||||
return true;
|
||||
} else if ($r === true) {
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} else if ($r === false) {
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
@@ -927,10 +890,8 @@ class Smarty_Internal_Templatelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]
|
||||
);
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
@@ -978,14 +939,10 @@ class Smarty_Internal_Templatelexer
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
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'
|
||||
);
|
||||
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
|
||||
@@ -996,11 +953,11 @@ class Smarty_Internal_Templatelexer
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
// accept this token
|
||||
return true;
|
||||
} else if ($r === true) {
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} else if ($r === false) {
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
@@ -1010,10 +967,8 @@ class Smarty_Internal_Templatelexer
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]
|
||||
);
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[ $this->counter ]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
@@ -1083,4 +1038,4 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user