#56: now, __halt_compiler(); terminates parsing process

This commit is contained in:
z7zmey
2018-07-24 21:49:26 +03:00
parent 1a495d615b
commit 623a90a418
9 changed files with 1011 additions and 969 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -373,6 +373,8 @@ top_statement:
yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
yylex.(*Parser).Begin(scanner.HALT_COMPILER)
}
| T_NAMESPACE namespace_name ';'
{

View File

@@ -120,7 +120,6 @@ func TestPhp5(t *testing.T) {
function foo() {}
function foo() {
__halt_compiler();
function bar() {}
class Baz {}
return $a;
@@ -132,7 +131,6 @@ func TestPhp5(t *testing.T) {
global $a, $b, $$c, ${foo()};
a:
goto a;
__halt_compiler();
if ($a) {}
if ($a) {} elseif ($b) {}
if ($a) {} else {}
@@ -411,6 +409,10 @@ func TestPhp5(t *testing.T) {
${$a};
$foo::{$bar}();
$foo::bar;
__halt_compiler();
parsing process must be terminated
`
expectedParams := []node.Node{
@@ -1093,7 +1095,6 @@ func TestPhp5(t *testing.T) {
PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{
&stmt.HaltCompiler{},
&stmt.Function{
ReturnsRef: false,
PhpDocComment: "",
@@ -1171,7 +1172,6 @@ func TestPhp5(t *testing.T) {
&stmt.Goto{
Label: &node.Identifier{Value: "a"},
},
&stmt.HaltCompiler{},
&stmt.If{
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Stmt: &stmt.StmtList{Stmts: []node.Node{}},
@@ -3634,6 +3634,7 @@ func TestPhp5(t *testing.T) {
ConstantName: &node.Identifier{Value: "bar"},
},
},
&stmt.HaltCompiler{},
},
}