refactoring: create "ExprBrackets" node

This commit is contained in:
Vadym Slizov
2020-12-28 00:02:14 +02:00
parent ad884c99df
commit e4321b5e90
15 changed files with 281 additions and 180 deletions

View File

@@ -11513,14 +11513,14 @@ func TestStmtContinue(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 26,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -11530,7 +11530,7 @@ func TestStmtContinue(t *testing.T) {
EndPos: 24,
},
},
Child: &ast.ScalarLnumber{
Expr: &ast.ScalarLnumber{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -11549,7 +11549,7 @@ func TestStmtContinue(t *testing.T) {
},
Value: []byte("3"),
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -12598,14 +12598,14 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
},
},
Exprs: []ast.Vertex{
&ast.ParserBrackets{
&ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 11,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -12615,7 +12615,7 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
EndPos: 8,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -12642,7 +12642,7 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -12694,14 +12694,14 @@ func TestStmtExpression(t *testing.T) {
StartPos: 3,
EndPos: 9,
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 3,
EndPos: 8,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -12733,14 +12733,14 @@ func TestStmtExpression(t *testing.T) {
},
},
},
Child: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
EndPos: 7,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -12750,7 +12750,7 @@ func TestStmtExpression(t *testing.T) {
EndPos: 5,
},
},
Child: &ast.ScalarLnumber{
Expr: &ast.ScalarLnumber{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -12769,7 +12769,7 @@ func TestStmtExpression(t *testing.T) {
},
Value: []byte("1"),
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -12780,7 +12780,7 @@ func TestStmtExpression(t *testing.T) {
},
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -29993,14 +29993,14 @@ func TestStmtBreak(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -30010,7 +30010,7 @@ func TestStmtBreak(t *testing.T) {
EndPos: 21,
},
},
Child: &ast.ScalarLnumber{
Expr: &ast.ScalarLnumber{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -30029,7 +30029,7 @@ func TestStmtBreak(t *testing.T) {
},
Value: []byte("3"),
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -31402,14 +31402,14 @@ func TestExprClone_Brackets(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 12,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -31419,7 +31419,7 @@ func TestExprClone_Brackets(t *testing.T) {
EndPos: 9,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -31446,7 +31446,7 @@ func TestExprClone_Brackets(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -38335,14 +38335,14 @@ func TestExprPrint(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 12,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -38352,7 +38352,7 @@ func TestExprPrint(t *testing.T) {
EndPos: 9,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -38379,7 +38379,7 @@ func TestExprPrint(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{

96
internal/php5/php5.go generated
View File

@@ -2888,9 +2888,9 @@ yydefault:
yyVAL.node = &ast.StmtIf{
Position: pos,
IfTkn: yyDollar[1].token,
OpenParenthesisTkn: yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn,
Cond: yyDollar[2].node.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: yyDollar[2].node.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn,
Stmt: yyDollar[3].node,
ElseIf: yyDollar[4].list,
Else: yyDollar[5].node,
@@ -2903,9 +2903,9 @@ yydefault:
yyVAL.node = &ast.StmtIf{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token),
IfTkn: yyDollar[1].token,
OpenParenthesisTkn: yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn,
Cond: yyDollar[2].node.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: yyDollar[2].node.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn,
ColonTkn: yyDollar[3].token,
Stmt: &ast.StmtStmtList{
Position: yylex.(*Parser).builder.NewNodeListPosition(yyDollar[4].list),
@@ -2922,9 +2922,9 @@ yydefault:
// line internal/php5/php5.y:818
{
yyDollar[3].node.(*ast.StmtWhile).WhileTkn = yyDollar[1].token
yyDollar[3].node.(*ast.StmtWhile).OpenParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn
yyDollar[3].node.(*ast.StmtWhile).Cond = yyDollar[2].node.(*ast.ParserBrackets).Child
yyDollar[3].node.(*ast.StmtWhile).CloseParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn
yyDollar[3].node.(*ast.StmtWhile).OpenParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn
yyDollar[3].node.(*ast.StmtWhile).Cond = yyDollar[2].node.(*ast.ExprBrackets).Expr
yyDollar[3].node.(*ast.StmtWhile).CloseParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn
yyDollar[3].node.(*ast.StmtWhile).Position = yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)
yyVAL.node = yyDollar[3].node
@@ -2938,9 +2938,9 @@ yydefault:
DoTkn: yyDollar[1].token,
Stmt: yyDollar[2].node,
WhileTkn: yyDollar[3].token,
OpenParenthesisTkn: yyDollar[4].node.(*ast.ParserBrackets).OpenBracketTkn,
Cond: yyDollar[4].node.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: yyDollar[4].node.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: yyDollar[4].node.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: yyDollar[4].node.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: yyDollar[4].node.(*ast.ExprBrackets).CloseParenthesisTkn,
SemiColonTkn: yyDollar[5].token,
}
}
@@ -2968,9 +2968,9 @@ yydefault:
// line internal/php5/php5.y:858
{
yyDollar[3].node.(*ast.StmtSwitch).SwitchTkn = yyDollar[1].token
yyDollar[3].node.(*ast.StmtSwitch).OpenParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn
yyDollar[3].node.(*ast.StmtSwitch).Cond = yyDollar[2].node.(*ast.ParserBrackets).Child
yyDollar[3].node.(*ast.StmtSwitch).CloseParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn
yyDollar[3].node.(*ast.StmtSwitch).OpenParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn
yyDollar[3].node.(*ast.StmtSwitch).Cond = yyDollar[2].node.(*ast.ExprBrackets).Expr
yyDollar[3].node.(*ast.StmtSwitch).CloseParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn
yyDollar[3].node.(*ast.StmtSwitch).Position = yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)
yyVAL.node = yyDollar[3].node
@@ -3891,9 +3891,9 @@ yydefault:
yyVAL.list = append(yyDollar[1].list, &ast.StmtElseIf{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node),
ElseIfTkn: yyDollar[2].token,
OpenParenthesisTkn: yyDollar[3].node.(*ast.ParserBrackets).OpenBracketTkn,
Cond: yyDollar[3].node.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: yyDollar[3].node.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: yyDollar[3].node.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: yyDollar[3].node.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: yyDollar[3].node.(*ast.ExprBrackets).CloseParenthesisTkn,
Stmt: yyDollar[4].node,
})
}
@@ -3910,9 +3910,9 @@ yydefault:
yyVAL.list = append(yyDollar[1].list, &ast.StmtElseIf{
Position: yylex.(*Parser).builder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list),
ElseIfTkn: yyDollar[2].token,
OpenParenthesisTkn: yyDollar[3].node.(*ast.ParserBrackets).OpenBracketTkn,
Cond: yyDollar[3].node.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: yyDollar[3].node.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: yyDollar[3].node.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: yyDollar[3].node.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: yyDollar[3].node.(*ast.ExprBrackets).CloseParenthesisTkn,
ColonTkn: yyDollar[4].token,
Stmt: &ast.StmtStmtList{
Position: yylex.(*Parser).builder.NewNodeListPosition(yyDollar[5].list),
@@ -5549,11 +5549,11 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php5/php5.y:3216
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
for _, n := range yyDollar[4].list {
@@ -5693,9 +5693,9 @@ yydefault:
exit.Position = yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token)
} else {
exit.Position = yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)
exit.OpenParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn
exit.Expr = yyDollar[2].node.(*ast.ParserBrackets).Child
exit.CloseParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn
exit.OpenParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn
exit.Expr = yyDollar[2].node.(*ast.ExprBrackets).Expr
exit.CloseParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn
}
yyVAL.node = exit
@@ -6329,10 +6329,10 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php5/php5.y:3918
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token),
OpenBracketTkn: yyDollar[1].token,
CloseBracketTkn: yyDollar[2].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token),
OpenParenthesisTkn: yyDollar[1].token,
CloseParenthesisTkn: yyDollar[2].token,
}
}
case 347:
@@ -6982,11 +6982,11 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:4466
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 410:
@@ -7203,22 +7203,22 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:4664
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 432:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:4673
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 433:

View File

@@ -787,9 +787,9 @@ unticked_statement:
$$ = &ast.StmtIf{
Position: pos,
IfTkn: $1,
OpenParenthesisTkn: $2.(*ast.ParserBrackets).OpenBracketTkn,
Cond: $2.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: $2.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: $2.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: $2.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: $2.(*ast.ExprBrackets).CloseParenthesisTkn,
Stmt: $3,
ElseIf: $4,
Else: $5,
@@ -800,9 +800,9 @@ unticked_statement:
$$ = &ast.StmtIf{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $8),
IfTkn: $1,
OpenParenthesisTkn: $2.(*ast.ParserBrackets).OpenBracketTkn,
Cond: $2.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: $2.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: $2.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: $2.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: $2.(*ast.ExprBrackets).CloseParenthesisTkn,
ColonTkn: $3,
Stmt: &ast.StmtStmtList{
Position: yylex.(*Parser).builder.NewNodeListPosition($4),
@@ -817,9 +817,9 @@ unticked_statement:
| T_WHILE parenthesis_expr while_statement
{
$3.(*ast.StmtWhile).WhileTkn = $1
$3.(*ast.StmtWhile).OpenParenthesisTkn = $2.(*ast.ParserBrackets).OpenBracketTkn
$3.(*ast.StmtWhile).Cond = $2.(*ast.ParserBrackets).Child
$3.(*ast.StmtWhile).CloseParenthesisTkn = $2.(*ast.ParserBrackets).CloseBracketTkn
$3.(*ast.StmtWhile).OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn
$3.(*ast.StmtWhile).Cond = $2.(*ast.ExprBrackets).Expr
$3.(*ast.StmtWhile).CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn
$3.(*ast.StmtWhile).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $3)
$$ = $3
@@ -831,9 +831,9 @@ unticked_statement:
DoTkn: $1,
Stmt: $2,
WhileTkn: $3,
OpenParenthesisTkn: $4.(*ast.ParserBrackets).OpenBracketTkn,
Cond: $4.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: $4.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: $4.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: $4.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: $4.(*ast.ExprBrackets).CloseParenthesisTkn,
SemiColonTkn: $5,
}
}
@@ -857,9 +857,9 @@ unticked_statement:
| T_SWITCH parenthesis_expr switch_case_list
{
$3.(*ast.StmtSwitch).SwitchTkn = $1
$3.(*ast.StmtSwitch).OpenParenthesisTkn = $2.(*ast.ParserBrackets).OpenBracketTkn
$3.(*ast.StmtSwitch).Cond = $2.(*ast.ParserBrackets).Child
$3.(*ast.StmtSwitch).CloseParenthesisTkn = $2.(*ast.ParserBrackets).CloseBracketTkn
$3.(*ast.StmtSwitch).OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn
$3.(*ast.StmtSwitch).Cond = $2.(*ast.ExprBrackets).Expr
$3.(*ast.StmtSwitch).CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn
$3.(*ast.StmtSwitch).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $3)
$$ = $3
@@ -1717,9 +1717,9 @@ elseif_list:
$$ = append($1, &ast.StmtElseIf{
Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $4),
ElseIfTkn: $2,
OpenParenthesisTkn: $3.(*ast.ParserBrackets).OpenBracketTkn,
Cond: $3.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: $3.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: $3.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: $3.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: $3.(*ast.ExprBrackets).CloseParenthesisTkn,
Stmt: $4,
})
}
@@ -1736,9 +1736,9 @@ new_elseif_list:
$$ = append($1, &ast.StmtElseIf{
Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $5),
ElseIfTkn: $2,
OpenParenthesisTkn: $3.(*ast.ParserBrackets).OpenBracketTkn,
Cond: $3.(*ast.ParserBrackets).Child,
CloseParenthesisTkn: $3.(*ast.ParserBrackets).CloseBracketTkn,
OpenParenthesisTkn: $3.(*ast.ExprBrackets).OpenParenthesisTkn,
Cond: $3.(*ast.ExprBrackets).Expr,
CloseParenthesisTkn: $3.(*ast.ExprBrackets).CloseParenthesisTkn,
ColonTkn: $4,
Stmt: &ast.StmtStmtList{
Position: yylex.(*Parser).builder.NewNodeListPosition($5),
@@ -3214,11 +3214,11 @@ expr_without_variable:
}
| '(' new_expr ')' instance_call
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
for _, n := range($4) {
@@ -3336,9 +3336,9 @@ expr_without_variable:
exit.Position = yylex.(*Parser).builder.NewTokenPosition($1)
} else {
exit.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2)
exit.OpenParenthesisTkn = $2.(*ast.ParserBrackets).OpenBracketTkn
exit.Expr = $2.(*ast.ParserBrackets).Child
exit.CloseParenthesisTkn = $2.(*ast.ParserBrackets).CloseBracketTkn
exit.OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn
exit.Expr = $2.(*ast.ExprBrackets).Expr
exit.CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn
}
$$ = exit
@@ -3916,10 +3916,10 @@ exit_expr:
}
| '(' ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $2),
OpenBracketTkn: $1,
CloseBracketTkn: $2,
OpenParenthesisTkn: $1,
CloseParenthesisTkn: $2,
}
}
| parenthesis_expr
@@ -4464,11 +4464,11 @@ static_operation:
}
| '(' static_scalar_value ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
;
@@ -4662,20 +4662,20 @@ expr:
parenthesis_expr:
'(' expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
| '(' yield_expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
;

View File

@@ -13048,14 +13048,14 @@ func TestStmtContinue(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 26,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -13065,7 +13065,7 @@ func TestStmtContinue(t *testing.T) {
EndPos: 24,
},
},
Child: &ast.ScalarLnumber{
Expr: &ast.ScalarLnumber{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -13084,7 +13084,7 @@ func TestStmtContinue(t *testing.T) {
},
Value: []byte("3"),
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -14133,14 +14133,14 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
},
},
Exprs: []ast.Vertex{
&ast.ParserBrackets{
&ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
EndPos: 11,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -14150,7 +14150,7 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
EndPos: 8,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -14177,7 +14177,7 @@ func TestStmtEcho_Parenthesis(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -33925,14 +33925,14 @@ func TestStmtBreak(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -33942,7 +33942,7 @@ func TestStmtBreak(t *testing.T) {
EndPos: 21,
},
},
Child: &ast.ScalarLnumber{
Expr: &ast.ScalarLnumber{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -33961,7 +33961,7 @@ func TestStmtBreak(t *testing.T) {
},
Value: []byte("3"),
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -35900,14 +35900,14 @@ func TestExprClone_Brackets(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 12,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -35917,7 +35917,7 @@ func TestExprClone_Brackets(t *testing.T) {
EndPos: 9,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -35944,7 +35944,7 @@ func TestExprClone_Brackets(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
@@ -43295,14 +43295,14 @@ func TestExprPrint(t *testing.T) {
},
},
},
Expr: &ast.ParserBrackets{
Expr: &ast.ExprBrackets{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
EndPos: 12,
},
OpenBracketTkn: &token.Token{
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
@@ -43312,7 +43312,7 @@ func TestExprPrint(t *testing.T) {
EndPos: 9,
},
},
Child: &ast.ExprVariable{
Expr: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@@ -43339,7 +43339,7 @@ func TestExprPrint(t *testing.T) {
Value: []byte("$a"),
},
},
CloseBracketTkn: &token.Token{
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{

46
internal/php7/php7.go generated
View File

@@ -5534,11 +5534,11 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:2992
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 350:
@@ -5671,9 +5671,9 @@ yydefault:
exit.Position = yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token)
} else {
exit.Position = yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)
exit.OpenParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).OpenBracketTkn
exit.Expr = yyDollar[2].node.(*ast.ParserBrackets).Child
exit.CloseParenthesisTkn = yyDollar[2].node.(*ast.ParserBrackets).CloseBracketTkn
exit.OpenParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).OpenParenthesisTkn
exit.Expr = yyDollar[2].node.(*ast.ExprBrackets).Expr
exit.CloseParenthesisTkn = yyDollar[2].node.(*ast.ExprBrackets).CloseParenthesisTkn
}
yyVAL.node = exit
@@ -6006,11 +6006,11 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3409
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 394:
@@ -6324,11 +6324,11 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3686
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 428:
@@ -6347,11 +6347,11 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3706
{
yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenBracketTkn: yyDollar[1].token,
Child: yyDollar[2].node,
CloseBracketTkn: yyDollar[3].token,
yyVAL.node = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
OpenParenthesisTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
CloseParenthesisTkn: yyDollar[3].token,
}
}
case 431:

View File

@@ -2990,11 +2990,11 @@ expr_without_variable:
}
| '(' expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
| new_expr
@@ -3101,9 +3101,9 @@ expr_without_variable:
exit.Position = yylex.(*Parser).builder.NewTokenPosition($1)
} else {
exit.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2)
exit.OpenParenthesisTkn = $2.(*ast.ParserBrackets).OpenBracketTkn
exit.Expr = $2.(*ast.ParserBrackets).Child
exit.CloseParenthesisTkn = $2.(*ast.ParserBrackets).CloseBracketTkn
exit.OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn
exit.Expr = $2.(*ast.ExprBrackets).Expr
exit.CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn
}
$$ = exit
@@ -3407,11 +3407,11 @@ exit_expr:
}
| '(' optional_expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
;
@@ -3684,11 +3684,11 @@ dereferencable:
}
| '(' expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
| dereferencable_scalar
@@ -3704,11 +3704,11 @@ callable_expr:
}
| '(' expr ')'
{
$$ = &ast.ParserBrackets{
$$ = &ast.ExprBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
OpenBracketTkn: $1,
Child: $2,
CloseBracketTkn: $3,
OpenParenthesisTkn: $1,
Expr: $2,
CloseParenthesisTkn: $3,
}
}
| dereferencable_scalar