Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PHP 8s nullsafe operator. #860

Open
wants to merge 1 commit into
base: smarty5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 30 additions & 24 deletions src/Lexer/TemplateLexer.php
Expand Up @@ -131,6 +131,7 @@ class TemplateLexer
'OPENB' => '[',
'CLOSEB' => ']',
'PTR' => '->',
'NSPTR' => '?->',
'APTR' => '=>',
'EQUAL' => '=',
'NUMBER' => 'number',
Expand Down Expand Up @@ -567,7 +568,7 @@ public function yy_r2_23()
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
$this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[?][-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
Expand Down Expand Up @@ -737,44 +738,49 @@ public function yy_r3_32()
public function yy_r3_33()
{

$this->token = \Smarty\Parser\TemplateParser::TP_APTR;
$this->token = \Smarty\Parser\TemplateParser::TP_NSPTR;
}
public function yy_r3_34()
{

$this->token = \Smarty\Parser\TemplateParser::TP_EQUAL;
$this->token = \Smarty\Parser\TemplateParser::TP_APTR;
}
public function yy_r3_35()
{

$this->token = \Smarty\Parser\TemplateParser::TP_EQUAL;
}
public function yy_r3_36()
{

$this->token = \Smarty\Parser\TemplateParser::TP_INCDEC;
}
public function yy_r3_37()
public function yy_r3_38()
{

$this->token = \Smarty\Parser\TemplateParser::TP_UNIMATH;
}
public function yy_r3_39()
public function yy_r3_40()
{

$this->token = \Smarty\Parser\TemplateParser::TP_MATH;
}
public function yy_r3_41()
public function yy_r3_42()
{

$this->token = \Smarty\Parser\TemplateParser::TP_AT;
}
public function yy_r3_42()
public function yy_r3_43()
{

$this->token = \Smarty\Parser\TemplateParser::TP_ARRAYOPEN;
}
public function yy_r3_43()
public function yy_r3_44()
{

$this->token = \Smarty\Parser\TemplateParser::TP_HATCH;
}
public function yy_r3_44()
public function yy_r3_45()
{

// resolve conflicts with shorttag and right_delimiter starting with '='
Expand All @@ -786,73 +792,73 @@ public function yy_r3_44()
$this->token = \Smarty\Parser\TemplateParser::TP_ATTR;
}
}
public function yy_r3_45()
public function yy_r3_46()
{

$this->token = \Smarty\Parser\TemplateParser::TP_NAMESPACE;
}
public function yy_r3_48()
public function yy_r3_49()
{

$this->token = \Smarty\Parser\TemplateParser::TP_ID;
}
public function yy_r3_49()
public function yy_r3_50()
{

$this->token = \Smarty\Parser\TemplateParser::TP_INTEGER;
}
public function yy_r3_50()
public function yy_r3_51()
{

$this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK;
$this->yypopstate();
}
public function yy_r3_51()
public function yy_r3_52()
{

$this->token = \Smarty\Parser\TemplateParser::TP_VERT;
}
public function yy_r3_52()
public function yy_r3_53()
{

$this->token = \Smarty\Parser\TemplateParser::TP_DOT;
}
public function yy_r3_53()
public function yy_r3_54()
{

$this->token = \Smarty\Parser\TemplateParser::TP_COMMA;
}
public function yy_r3_54()
public function yy_r3_55()
{

$this->token = \Smarty\Parser\TemplateParser::TP_SEMICOLON;
}
public function yy_r3_55()
public function yy_r3_56()
{

$this->token = \Smarty\Parser\TemplateParser::TP_DOUBLECOLON;
}
public function yy_r3_56()
public function yy_r3_57()
{

$this->token = \Smarty\Parser\TemplateParser::TP_COLON;
}
public function yy_r3_57()
public function yy_r3_58()
{

$this->token = \Smarty\Parser\TemplateParser::TP_QMARK;
}
public function yy_r3_58()
public function yy_r3_59()
{

$this->token = \Smarty\Parser\TemplateParser::TP_HEX;
}
public function yy_r3_59()
public function yy_r3_60()
{

$this->token = \Smarty\Parser\TemplateParser::TP_SPACE;
}
public function yy_r3_60()
public function yy_r3_61()
{

$this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
Expand Down Expand Up @@ -1080,4 +1086,4 @@ public function yy_r5_22()

}



7 changes: 6 additions & 1 deletion src/Lexer/TemplateLexer.plex
Expand Up @@ -131,6 +131,7 @@ class TemplateLexer
'OPENB' => '[',
'CLOSEB' => ']',
'PTR' => '->',
'NSPTR' => '?->',
'APTR' => '=>',
'EQUAL' => '=',
'NUMBER' => 'number',
Expand Down Expand Up @@ -310,6 +311,7 @@ class TemplateLexer
equal = ~\s*[=]\s*~
space = ~\s+~
ptr = ~\s*[-][>]\s*~
nsptr = ~\s*[?][-][>]\s*~
aptr = ~\s*[=][>]\s*~
singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~
backtick = ~[`]~
Expand Down Expand Up @@ -514,6 +516,9 @@ class TemplateLexer
ptr {
$this->token = \Smarty\Parser\TemplateParser::TP_PTR;
}
nsptr {
$this->token = \Smarty\Parser\TemplateParser::TP_NSPTR;
}
aptr {
$this->token = \Smarty\Parser\TemplateParser::TP_APTR;
}
Expand Down Expand Up @@ -674,4 +679,4 @@ class TemplateLexer
*/
}