mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- improvement reduce number of lexer tokens on operators and if conditions
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
===== 3.1.24.dev ===== (xx.xx.2015)
|
===== 3.1.24.dev ===== (xx.xx.2015)
|
||||||
|
16.05.2015
|
||||||
|
- bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33
|
||||||
|
- improvement remove not needed ?><?php transitions from compiled code
|
||||||
|
- improvement reduce number of lexer tokens on operators and if conditions
|
||||||
|
|
||||||
13.05.2015
|
13.05.2015
|
||||||
- improvement remove not needed ?><?php transitions from compiled code
|
- improvement remove not needed ?><?php transitions from compiled code
|
||||||
- improvement of debugging:
|
- improvement of debugging:
|
||||||
@@ -7,7 +12,6 @@
|
|||||||
- display Smarty version number
|
- display Smarty version number
|
||||||
- Truncate lenght of Origin display and extend strin value display to 80 character
|
- Truncate lenght of Origin display and extend strin value display to 80 character
|
||||||
- bugfix in Smarty_Security 'nl2br' should be a trusted modifier, not PHP function (code.google issue 223)
|
- bugfix in Smarty_Security 'nl2br' should be a trusted modifier, not PHP function (code.google issue 223)
|
||||||
- bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33
|
|
||||||
|
|
||||||
12.05.2015
|
12.05.2015
|
||||||
- bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28
|
- bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28
|
||||||
|
@@ -245,7 +245,7 @@ class Smarty_Internal_Templatelexer
|
|||||||
smartyblockchildparent = /[\$]smarty\.block\.(child|parent)/
|
smartyblockchildparent = /[\$]smarty\.block\.(child|parent)/
|
||||||
integer = /\d+/
|
integer = /\d+/
|
||||||
hex = /0[xX][0-9a-fA-F]+/
|
hex = /0[xX][0-9a-fA-F]+/
|
||||||
math = /\s*(\*|\/|\%)\s*/
|
math = /\s*([*]{1,2}|[%\/^&]|[<>]{2})\s*/
|
||||||
comment = /SMARTYldel\*([\S\s]*?)\*SMARTYrdel/
|
comment = /SMARTYldel\*([\S\s]*?)\*SMARTYrdel/
|
||||||
incdec = /\+\+|\-\-/
|
incdec = /\+\+|\-\-/
|
||||||
unimath = /\s*(\+|\-)\s*/
|
unimath = /\s*(\+|\-)\s*/
|
||||||
@@ -276,25 +276,9 @@ class Smarty_Internal_Templatelexer
|
|||||||
id = /[0-9]*[a-zA-Z_]\w*/
|
id = /[0-9]*[a-zA-Z_]\w*/
|
||||||
literal = /literal/
|
literal = /literal/
|
||||||
strip = /strip/
|
strip = /strip/
|
||||||
equals = /\s*==\s*|\s+eq\s+/
|
lop = /\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*/
|
||||||
notequals = /\s*!=\s*|\s*<>\s*|\s+(ne|neq)\s+/
|
tlop = /\s+(eq|ne|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+/
|
||||||
greaterthan = /\s*>\s*|\s+gt\s+/
|
scond = /\s+is\s+(not\s+)?(odd|even)/
|
||||||
lessthan = /\s*<\s*|\s+lt\s+/
|
|
||||||
greaterequal = /\s*>=\s*|\s+(ge|gte)\s+/
|
|
||||||
lessequal = /\s*<=\s*|\s+(le|lte)\s+/
|
|
||||||
mod = /\s+mod\s+/
|
|
||||||
identity = /\s*===\s*/
|
|
||||||
noneidentity = /\s*!==\s*/
|
|
||||||
isoddby = /\s+is\s+odd\s+by\s+/
|
|
||||||
isnotoddby = /\s+is\s+not\s+odd\s+by\s+/
|
|
||||||
isodd = /\s+is\s+odd/
|
|
||||||
isnotodd = /\s+is\s+not\s+odd/
|
|
||||||
isevenby = /\s+is\s+even\s+by\s+/
|
|
||||||
isnotevenby = /\s+is\s+not\s+even\s+by\s+/
|
|
||||||
iseven = /\s+is\s+even/
|
|
||||||
isnoteven = /\s+is\s+not\s+even/
|
|
||||||
isdivby = /\s+is\s+div\s+by\s+/
|
|
||||||
isnotdivby = /\s+is\s+not\s+div\s+by\s+/
|
|
||||||
isin = /\s+is\s+in\s+/
|
isin = /\s+is\s+in\s+/
|
||||||
as = /\s+as\s+/
|
as = /\s+as\s+/
|
||||||
to = /\s+to\s+/
|
to = /\s+to\s+/
|
||||||
@@ -306,9 +290,6 @@ class Smarty_Internal_Templatelexer
|
|||||||
setfilter = /setfilter\s+/
|
setfilter = /setfilter\s+/
|
||||||
instanceof = /\s+instanceof\s+/
|
instanceof = /\s+instanceof\s+/
|
||||||
not = /!\s*|not\s+/
|
not = /!\s*|not\s+/
|
||||||
land = /\s*\&\&\s*|\s*and\s+/
|
|
||||||
lor = /\s*\|\|\s*|\s*or\s+/
|
|
||||||
lxor = /\s*xor\s+/
|
|
||||||
typecast = /\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\)\s*/
|
typecast = /\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\)\s*/
|
||||||
double_quote = /"/
|
double_quote = /"/
|
||||||
single_quote = /'/
|
single_quote = /'/
|
||||||
@@ -480,76 +461,18 @@ class Smarty_Internal_Templatelexer
|
|||||||
instanceof {
|
instanceof {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
|
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
|
||||||
}
|
}
|
||||||
identity{
|
lop {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
|
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
|
||||||
}
|
}
|
||||||
noneidentity{
|
tlop {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
|
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
|
||||||
}
|
}
|
||||||
equals{
|
scond {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_EQUALS;
|
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
|
||||||
}
|
|
||||||
notequals{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
|
|
||||||
}
|
|
||||||
greaterequal{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
|
|
||||||
}
|
|
||||||
lessequal{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
|
|
||||||
}
|
|
||||||
greaterthan{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
|
|
||||||
}
|
|
||||||
lessthan{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
|
|
||||||
}
|
|
||||||
mod{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_MOD;
|
|
||||||
}
|
}
|
||||||
not{
|
not{
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_NOT;
|
$this->token = Smarty_Internal_Templateparser::TP_NOT;
|
||||||
}
|
}
|
||||||
land {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_LAND;
|
|
||||||
}
|
|
||||||
lor {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_LOR;
|
|
||||||
}
|
|
||||||
lxor {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_LXOR;
|
|
||||||
}
|
|
||||||
isoddby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
|
|
||||||
}
|
|
||||||
isnotoddby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
|
|
||||||
}
|
|
||||||
|
|
||||||
isodd {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISODD;
|
|
||||||
}
|
|
||||||
isnotodd {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
|
|
||||||
}
|
|
||||||
isevenby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
|
|
||||||
}
|
|
||||||
isnotevenby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
|
|
||||||
}
|
|
||||||
iseven{
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
|
|
||||||
}
|
|
||||||
isnoteven {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
|
|
||||||
}
|
|
||||||
isdivby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
|
|
||||||
}
|
|
||||||
isnotdivby {
|
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
|
|
||||||
}
|
|
||||||
typecast {
|
typecast {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
|
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
|
||||||
}
|
}
|
||||||
@@ -562,7 +485,6 @@ class Smarty_Internal_Templatelexer
|
|||||||
openB {
|
openB {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
|
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeB {
|
closeB {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
|
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
|
||||||
}
|
}
|
||||||
|
@@ -660,8 +660,11 @@ expr(res) ::= expr(e) modifierlist(l). {
|
|||||||
|
|
||||||
// if expression
|
// if expression
|
||||||
// simple expression
|
// simple expression
|
||||||
expr(res) ::= expr(e1) ifcond(c) expr(e2). {
|
expr(res) ::= expr(e1) lop(c) expr(e2). {
|
||||||
res = e1.c.e2;
|
res = (isset(c['pre']) ? c['pre'] : '') . e1.c['op'].e2 . (isset(c['pre']) ? ')' : '');
|
||||||
|
}
|
||||||
|
expr(res) ::= expr(e1) scond(c). {
|
||||||
|
res = c . e1 . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISIN array(a). {
|
expr(res) ::= expr(e1) ISIN array(a). {
|
||||||
@@ -672,53 +675,9 @@ expr(res) ::= expr(e1) ISIN value(v). {
|
|||||||
res = 'in_array('.e1.',(array)'.v.')';
|
res = 'in_array('.e1.',(array)'.v.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
expr(res) ::= expr(e1) lop(o) expr(e2). {
|
|
||||||
res = e1.o.e2;
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISDIVBY expr(e2). {
|
|
||||||
res = '!('.e1.' % '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISNOTDIVBY expr(e2). {
|
|
||||||
res = '('.e1.' % '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISEVEN. {
|
|
||||||
res = '!(1 & '.e1.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISNOTEVEN. {
|
|
||||||
res = '(1 & '.e1.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISEVENBY expr(e2). {
|
|
||||||
res = '!(1 & '.e1.' / '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISNOTEVENBY expr(e2). {
|
|
||||||
res = '(1 & '.e1.' / '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISODD. {
|
|
||||||
res = '(1 & '.e1.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISNOTODD. {
|
|
||||||
res = '!(1 & '.e1.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISODDBY expr(e2). {
|
|
||||||
res = '(1 & '.e1.' / '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= expr(e1) ISNOTODDBY expr(e2). {
|
|
||||||
res = '!(1 & '.e1.' / '.e2.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
|
expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
|
||||||
res = v1.i.v2;
|
res = v1.i.v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1199,52 +1158,45 @@ static_class_access(res) ::= DOLLAR ID(v) arrayindex(a) objectchain(oc). {
|
|||||||
|
|
||||||
|
|
||||||
// if conditions and operators
|
// if conditions and operators
|
||||||
ifcond(res) ::= EQUALS. {
|
lop(res) ::= LOGOP(o). {
|
||||||
res = '==';
|
res['op'] = ' '. trim(o) . ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
ifcond(res) ::= NOTEQUALS. {
|
lop(res) ::= TLOGOP(o). {
|
||||||
res = '!=';
|
static $lops = array(
|
||||||
|
'eq' => array('op' => ' == ', 'pre' => null),
|
||||||
|
'ne' => array('op' => ' != ', 'pre' => null),
|
||||||
|
'neq' => array('op' => ' != ', 'pre' => null),
|
||||||
|
'gt' => array('op' => ' > ', 'pre' => null),
|
||||||
|
'ge' => array('op' => ' >= ', 'pre' => null),
|
||||||
|
'gte' => array('op' => ' >= ', 'pre' => null),
|
||||||
|
'lt' => array('op' => ' < ', 'pre' => null),
|
||||||
|
'le' => array('op' => ' <= ', 'pre' => null),
|
||||||
|
'lte' => array('op' => ' <= ', 'pre' => null),
|
||||||
|
'mod' => array('op' => ' % ', 'pre' => null),
|
||||||
|
'and' => array('op' => ' && ', 'pre' => null),
|
||||||
|
'or' => array('op' => ' || ', 'pre' => null),
|
||||||
|
'xor' => array('op' => ' xor ', 'pre' => null),
|
||||||
|
'isdivby' => array('op' => ' % ', 'pre' => '!('),
|
||||||
|
'isnotdivby' => array('op' => ' % ', 'pre' => '('),
|
||||||
|
'isevenby' => array('op' => ' / ', 'pre' => '!(1 & '),
|
||||||
|
'isnotevenby' => array('op' => ' / ', 'pre' => '(1 & '),
|
||||||
|
'isoddby' => array('op' => ' / ', 'pre' => '(1 & '),
|
||||||
|
'isnotoddby' => array('op' => ' / ', 'pre' => '!(1 & '),
|
||||||
|
);
|
||||||
|
$op = strtolower(str_replace(' ', '', o));
|
||||||
|
res = $lops[$op];
|
||||||
}
|
}
|
||||||
|
|
||||||
ifcond(res) ::= GREATERTHAN. {
|
scond(res) ::= SINGLECOND(o). {
|
||||||
res = '>';
|
static $scond = array (
|
||||||
}
|
'iseven' => '!(1 & ',
|
||||||
|
'isnoteven' => '(1 & ',
|
||||||
ifcond(res) ::= LESSTHAN. {
|
'isodd' => '(1 & ',
|
||||||
res = '<';
|
'isnotodd' => '!(1 & ',
|
||||||
}
|
);
|
||||||
|
$op = strtolower(str_replace(' ', '', o));
|
||||||
ifcond(res) ::= GREATEREQUAL. {
|
res = $scond[$op];
|
||||||
res = '>=';
|
|
||||||
}
|
|
||||||
|
|
||||||
ifcond(res) ::= LESSEQUAL. {
|
|
||||||
res = '<=';
|
|
||||||
}
|
|
||||||
|
|
||||||
ifcond(res) ::= IDENTITY. {
|
|
||||||
res = '===';
|
|
||||||
}
|
|
||||||
|
|
||||||
ifcond(res) ::= NONEIDENTITY. {
|
|
||||||
res = '!==';
|
|
||||||
}
|
|
||||||
|
|
||||||
ifcond(res) ::= MOD. {
|
|
||||||
res = '%';
|
|
||||||
}
|
|
||||||
|
|
||||||
lop(res) ::= LAND. {
|
|
||||||
res = '&&';
|
|
||||||
}
|
|
||||||
|
|
||||||
lop(res) ::= LOR. {
|
|
||||||
res = '||';
|
|
||||||
}
|
|
||||||
|
|
||||||
lop(res) ::= LXOR. {
|
|
||||||
res = ' XOR ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user