refactoring: update ast structure of "Closure" and "ClosureUse" nodes

This commit is contained in:
Vadym Slizov 2020-12-26 18:20:10 +02:00
parent 03c7979ccd
commit b85bae2ec1
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
14 changed files with 1092 additions and 1017 deletions

View File

@ -31917,13 +31917,6 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
ClosureUse: &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
},
UseTkn: &token.Token{ UseTkn: &token.Token{
ID: token.T_USE, ID: token.T_USE,
Value: []byte("use"), Value: []byte("use"),
@ -31946,7 +31939,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
OpenParenthesisTkn: &token.Token{ UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40), ID: token.ID(40),
Value: []byte("("), Value: []byte("("),
Position: &position.Position{ Position: &position.Position{
@ -31968,8 +31961,15 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
Uses: []ast.Vertex{ Use: []ast.Vertex{
&ast.ExprVariable{ &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 27,
},
Var: &ast.ExprVariable{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -31996,7 +31996,8 @@ func TestExprClosure_Use(t *testing.T) {
Value: []byte("$c"), Value: []byte("$c"),
}, },
}, },
&ast.ExprReference{ },
&ast.ExprClosureUse{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -32054,7 +32055,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
SeparatorTkns: []*token.Token{ UseSeparatorTkns: []*token.Token{
{ {
ID: token.ID(44), ID: token.ID(44),
Value: []byte(","), Value: []byte(","),
@ -32066,7 +32067,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
CloseParenthesisTkn: &token.Token{ UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41), ID: token.ID(41),
Value: []byte(")"), Value: []byte(")"),
Position: &position.Position{ Position: &position.Position{
@ -32076,7 +32077,6 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 33, EndPos: 33,
}, },
}, },
},
OpenCurlyBracketTkn: &token.Token{ OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123), ID: token.ID(123),
Value: []byte("{"), Value: []byte("{"),
@ -32123,7 +32123,8 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
EndTkn: &token.Token{}, EndTkn: &token.Token{
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", nil) lexer := scanner.NewLexer([]byte(src), "5.6", nil)
@ -32306,13 +32307,6 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
ClosureUse: &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
},
UseTkn: &token.Token{ UseTkn: &token.Token{
ID: token.T_USE, ID: token.T_USE,
Value: []byte("use"), Value: []byte("use"),
@ -32335,7 +32329,7 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
OpenParenthesisTkn: &token.Token{ UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40), ID: token.ID(40),
Value: []byte("("), Value: []byte("("),
Position: &position.Position{ Position: &position.Position{
@ -32357,8 +32351,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
Uses: []ast.Vertex{ Use: []ast.Vertex{
&ast.ExprReference{ &ast.ExprClosureUse{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -32403,7 +32397,14 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
&ast.ExprVariable{ &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
Var: &ast.ExprVariable{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -32443,7 +32444,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
SeparatorTkns: []*token.Token{ },
UseSeparatorTkns: []*token.Token{
{ {
ID: token.ID(44), ID: token.ID(44),
Value: []byte(","), Value: []byte(","),
@ -32455,7 +32457,7 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
CloseParenthesisTkn: &token.Token{ UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41), ID: token.ID(41),
Value: []byte(")"), Value: []byte(")"),
Position: &position.Position{ Position: &position.Position{
@ -32465,7 +32467,6 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 33, EndPos: 33,
}, },
}, },
},
OpenCurlyBracketTkn: &token.Token{ OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123), ID: token.ID(123),
Value: []byte("{"), Value: []byte("{"),
@ -32512,7 +32513,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
EndTkn: &token.Token{}, EndTkn: &token.Token{
},
} }
lexer := scanner.NewLexer([]byte(src), "5.6", nil) lexer := scanner.NewLexer([]byte(src), "5.6", nil)

533
internal/php5/php5.go generated

File diff suppressed because it is too large Load Diff

View File

@ -3367,36 +3367,38 @@ expr_without_variable:
} }
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' | function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
{ {
$$ = &ast.ExprClosure{ closure := $6.(*ast.ExprClosure)
Position: yylex.(*Parser).builder.NewTokensPosition($1, $9),
FunctionTkn: $1, closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $9)
AmpersandTkn: $2, closure.FunctionTkn = $1
OpenParenthesisTkn: $3, closure.AmpersandTkn = $2
Params: $4.(*ast.ParserSeparatedList).Items, closure.OpenParenthesisTkn = $3
SeparatorTkns: $4.(*ast.ParserSeparatedList).SeparatorTkns, closure.Params = $4.(*ast.ParserSeparatedList).Items
CloseParenthesisTkn: $5, closure.SeparatorTkns = $4.(*ast.ParserSeparatedList).SeparatorTkns
ClosureUse: $6, closure.CloseParenthesisTkn = $5
OpenCurlyBracketTkn: $7, closure.OpenCurlyBracketTkn = $7
Stmts: $8, closure.Stmts = $8
CloseCurlyBracketTkn: $9, closure.CloseCurlyBracketTkn = $9
}
$$ = closure
} }
| T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' | T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
{ {
$$ = &ast.ExprClosure{ closure := $7.(*ast.ExprClosure)
Position: yylex.(*Parser).builder.NewTokensPosition($1, $10),
StaticTkn: $1, closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $10)
FunctionTkn: $2, closure.StaticTkn = $1
AmpersandTkn: $3, closure.FunctionTkn = $2
OpenParenthesisTkn: $4, closure.AmpersandTkn = $3
Params: $5.(*ast.ParserSeparatedList).Items, closure.OpenParenthesisTkn = $4
SeparatorTkns: $5.(*ast.ParserSeparatedList).SeparatorTkns, closure.Params = $5.(*ast.ParserSeparatedList).Items
CloseParenthesisTkn: $6, closure.SeparatorTkns = $5.(*ast.ParserSeparatedList).SeparatorTkns
ClosureUse: $7, closure.CloseParenthesisTkn = $6
OpenCurlyBracketTkn: $8, closure.OpenCurlyBracketTkn = $8
Stmts: $9, closure.Stmts = $9
CloseCurlyBracketTkn: $10, closure.CloseCurlyBracketTkn = $10
}
$$ = closure
} }
; ;
@ -3520,17 +3522,16 @@ function:
lexical_vars: lexical_vars:
/* empty */ /* empty */
{ {
$$ = nil $$ = &ast.ExprClosure{}
} }
| T_USE '(' lexical_var_list ')' | T_USE '(' lexical_var_list ')'
{ {
$$ = &ast.ExprClosureUse{ $$ = &ast.ExprClosure{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $4),
UseTkn: $1, UseTkn: $1,
OpenParenthesisTkn: $2, UseOpenParenthesisTkn: $2,
Uses: $3.(*ast.ParserSeparatedList).Items, Use: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns, UseSeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: $4, UseCloseParenthesisTkn: $4,
} }
} }
; ;
@ -3538,13 +3539,16 @@ lexical_vars:
lexical_var_list: lexical_var_list:
lexical_var_list ',' T_VARIABLE lexical_var_list ',' T_VARIABLE
{ {
variable := &ast.ExprVariable{ variable := &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokenPosition($3),
Var: &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition($3), Position: yylex.(*Parser).builder.NewTokenPosition($3),
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition($3), Position: yylex.(*Parser).builder.NewTokenPosition($3),
IdentifierTkn: $3, IdentifierTkn: $3,
Value: $3.Value, Value: $3.Value,
}, },
},
} }
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2) $1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
@ -3554,7 +3558,7 @@ lexical_var_list:
} }
| lexical_var_list ',' '&' T_VARIABLE | lexical_var_list ',' '&' T_VARIABLE
{ {
reference := &ast.ExprReference{ variable := &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokensPosition($3, $4), Position: yylex.(*Parser).builder.NewTokensPosition($3, $4),
AmpersandTkn: $3, AmpersandTkn: $3,
Var: &ast.ExprVariable{ Var: &ast.ExprVariable{
@ -3568,15 +3572,15 @@ lexical_var_list:
} }
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2) $1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, reference) $1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, variable)
$$ = $1 $$ = $1
} }
| T_VARIABLE | T_VARIABLE
{ {
$$ = &ast.ParserSeparatedList{ variable := &ast.ExprClosureUse{
Items: []ast.Vertex{ Position: yylex.(*Parser).builder.NewTokenPosition($1),
&ast.ExprVariable{ Var: &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition($1), Position: yylex.(*Parser).builder.NewTokenPosition($1),
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition($1), Position: yylex.(*Parser).builder.NewTokenPosition($1),
@ -3584,14 +3588,15 @@ lexical_var_list:
Value: $1.Value, Value: $1.Value,
}, },
}, },
}, }
$$ = &ast.ParserSeparatedList{
Items: []ast.Vertex{ variable },
} }
} }
| '&' T_VARIABLE | '&' T_VARIABLE
{ {
$$ = &ast.ParserSeparatedList{ variable := &ast.ExprClosureUse{
Items: []ast.Vertex{
&ast.ExprReference{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), Position: yylex.(*Parser).builder.NewTokensPosition($1, $2),
AmpersandTkn: $1, AmpersandTkn: $1,
Var: &ast.ExprVariable{ Var: &ast.ExprVariable{
@ -3602,8 +3607,10 @@ lexical_var_list:
Value: $2.Value, Value: $2.Value,
}, },
}, },
}, }
},
$$ = &ast.ParserSeparatedList{
Items: []ast.Vertex{ variable },
} }
} }
; ;

View File

@ -36415,13 +36415,6 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
ClosureUse: &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
},
UseTkn: &token.Token{ UseTkn: &token.Token{
ID: token.T_USE, ID: token.T_USE,
Value: []byte("use"), Value: []byte("use"),
@ -36444,7 +36437,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
OpenParenthesisTkn: &token.Token{ UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40), ID: token.ID(40),
Value: []byte("("), Value: []byte("("),
Position: &position.Position{ Position: &position.Position{
@ -36466,8 +36459,15 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
Uses: []ast.Vertex{ Use: []ast.Vertex{
&ast.ExprVariable{ &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 27,
},
Var: &ast.ExprVariable{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -36494,7 +36494,8 @@ func TestExprClosure_Use(t *testing.T) {
Value: []byte("$c"), Value: []byte("$c"),
}, },
}, },
&ast.ExprReference{ },
&ast.ExprClosureUse{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -36552,7 +36553,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
SeparatorTkns: []*token.Token{ UseSeparatorTkns: []*token.Token{
{ {
ID: token.ID(44), ID: token.ID(44),
Value: []byte(","), Value: []byte(","),
@ -36564,7 +36565,7 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
CloseParenthesisTkn: &token.Token{ UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41), ID: token.ID(41),
Value: []byte(")"), Value: []byte(")"),
Position: &position.Position{ Position: &position.Position{
@ -36574,7 +36575,6 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 33, EndPos: 33,
}, },
}, },
},
OpenCurlyBracketTkn: &token.Token{ OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123), ID: token.ID(123),
Value: []byte("{"), Value: []byte("{"),
@ -36621,7 +36621,8 @@ func TestExprClosure_Use(t *testing.T) {
}, },
}, },
}, },
EndTkn: &token.Token{}, EndTkn: &token.Token{
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", nil) lexer := scanner.NewLexer([]byte(src), "7.4", nil)
@ -36804,13 +36805,6 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 19, EndPos: 19,
}, },
}, },
ClosureUse: &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
},
UseTkn: &token.Token{ UseTkn: &token.Token{
ID: token.T_USE, ID: token.T_USE,
Value: []byte("use"), Value: []byte("use"),
@ -36833,7 +36827,7 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
OpenParenthesisTkn: &token.Token{ UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40), ID: token.ID(40),
Value: []byte("("), Value: []byte("("),
Position: &position.Position{ Position: &position.Position{
@ -36855,8 +36849,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
Uses: []ast.Vertex{ Use: []ast.Vertex{
&ast.ExprReference{ &ast.ExprClosureUse{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -36901,7 +36895,14 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
&ast.ExprVariable{ &ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
Var: &ast.ExprVariable{
Position: &position.Position{ Position: &position.Position{
StartLine: 1, StartLine: 1,
EndLine: 1, EndLine: 1,
@ -36941,7 +36942,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
SeparatorTkns: []*token.Token{ },
UseSeparatorTkns: []*token.Token{
{ {
ID: token.ID(44), ID: token.ID(44),
Value: []byte(","), Value: []byte(","),
@ -36953,7 +36955,7 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
CloseParenthesisTkn: &token.Token{ UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41), ID: token.ID(41),
Value: []byte(")"), Value: []byte(")"),
Position: &position.Position{ Position: &position.Position{
@ -36963,7 +36965,6 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 33, EndPos: 33,
}, },
}, },
},
OpenCurlyBracketTkn: &token.Token{ OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123), ID: token.ID(123),
Value: []byte("{"), Value: []byte("{"),
@ -37010,7 +37011,8 @@ func TestExprClosure_Use2(t *testing.T) {
}, },
}, },
}, },
EndTkn: &token.Token{}, EndTkn: &token.Token{
},
} }
lexer := scanner.NewLexer([]byte(src), "7.4", nil) lexer := scanner.NewLexer([]byte(src), "7.4", nil)

287
internal/php7/php7.go generated
View File

@ -339,7 +339,7 @@ const yyEofCode = 1
const yyErrCode = 2 const yyErrCode = 2
const yyInitialStackSize = 16 const yyInitialStackSize = 16
// line internal/php7/php7.y:4342 // line internal/php7/php7.y:4345
// line yacctab:1 // line yacctab:1
var yyExca = [...]int{ var yyExca = [...]int{
@ -5767,25 +5767,26 @@ yydefault:
yyDollar = yyS[yypt-11 : yypt+1] yyDollar = yyS[yypt-11 : yypt+1]
// line internal/php7/php7.y:3180 // line internal/php7/php7.y:3180
{ {
yyVAL.node = &ast.ExprClosure{ closure := yyDollar[7].node.(*ast.ExprClosure)
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token),
FunctionTkn: yyDollar[1].token, closure.Position = yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)
AmpersandTkn: yyDollar[2].token, closure.FunctionTkn = yyDollar[1].token
OpenParenthesisTkn: yyDollar[4].token, closure.AmpersandTkn = yyDollar[2].token
Params: yyDollar[5].node.(*ast.ParserSeparatedList).Items, closure.OpenParenthesisTkn = yyDollar[4].token
SeparatorTkns: yyDollar[5].node.(*ast.ParserSeparatedList).SeparatorTkns, closure.Params = yyDollar[5].node.(*ast.ParserSeparatedList).Items
CloseParenthesisTkn: yyDollar[6].token, closure.SeparatorTkns = yyDollar[5].node.(*ast.ParserSeparatedList).SeparatorTkns
ClosureUse: yyDollar[7].node, closure.CloseParenthesisTkn = yyDollar[6].token
ColonTkn: yyDollar[8].node.(*ast.ReturnType).ColonTkn, closure.ColonTkn = yyDollar[8].node.(*ast.ReturnType).ColonTkn
ReturnType: yyDollar[8].node.(*ast.ReturnType).Type, closure.ReturnType = yyDollar[8].node.(*ast.ReturnType).Type
OpenCurlyBracketTkn: yyDollar[9].token, closure.OpenCurlyBracketTkn = yyDollar[9].token
Stmts: yyDollar[10].list, closure.Stmts = yyDollar[10].list
CloseCurlyBracketTkn: yyDollar[11].token, closure.CloseCurlyBracketTkn = yyDollar[11].token
}
yyVAL.node = closure
} }
case 374: case 374:
yyDollar = yyS[yypt-9 : yypt+1] yyDollar = yyS[yypt-9 : yypt+1]
// line internal/php7/php7.y:3198 // line internal/php7/php7.y:3199
{ {
yyVAL.node = &ast.ExprArrowFunction{ yyVAL.node = &ast.ExprArrowFunction{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node),
@ -5803,33 +5804,32 @@ yydefault:
} }
case 376: case 376:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3221 // line internal/php7/php7.y:3222
{ {
yyVAL.token = nil yyVAL.token = nil
} }
case 377: case 377:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3225 // line internal/php7/php7.y:3226
{ {
yyVAL.token = yyDollar[1].token yyVAL.token = yyDollar[1].token
} }
case 378: case 378:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3232 // line internal/php7/php7.y:3233
{ {
yyVAL.node = nil yyVAL.node = &ast.ExprClosure{}
} }
case 379: case 379:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3236 // line internal/php7/php7.y:3237
{ {
yyVAL.node = &ast.ExprClosureUse{ yyVAL.node = &ast.ExprClosure{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
UseTkn: yyDollar[1].token, UseTkn: yyDollar[1].token,
OpenParenthesisTkn: yyDollar[2].token, UseOpenParenthesisTkn: yyDollar[2].token,
Uses: yyDollar[3].node.(*ast.ParserSeparatedList).Items, Use: yyDollar[3].node.(*ast.ParserSeparatedList).Items,
SeparatorTkns: yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns, UseSeparatorTkns: yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: yyDollar[4].token, UseCloseParenthesisTkn: yyDollar[4].token,
} }
} }
case 380: case 380:
@ -5853,20 +5853,23 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3266 // line internal/php7/php7.y:3266
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
Var: &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
IdentifierTkn: yyDollar[1].token, IdentifierTkn: yyDollar[1].token,
Value: yyDollar[1].token.Value, Value: yyDollar[1].token.Value,
}, },
},
} }
} }
case 383: case 383:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3277 // line internal/php7/php7.y:3280
{ {
yyVAL.node = &ast.ExprReference{ yyVAL.node = &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token),
AmpersandTkn: yyDollar[1].token, AmpersandTkn: yyDollar[1].token,
Var: &ast.ExprVariable{ Var: &ast.ExprVariable{
@ -5881,7 +5884,7 @@ yydefault:
} }
case 384: case 384:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3295 // line internal/php7/php7.y:3298
{ {
yyVAL.node = &ast.ExprFunctionCall{ yyVAL.node = &ast.ExprFunctionCall{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node),
@ -5894,7 +5897,7 @@ yydefault:
} }
case 385: case 385:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3306 // line internal/php7/php7.y:3309
{ {
yyVAL.node = &ast.ExprStaticCall{ yyVAL.node = &ast.ExprStaticCall{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node),
@ -5909,7 +5912,7 @@ yydefault:
} }
case 386: case 386:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3319 // line internal/php7/php7.y:3322
{ {
yyVAL.node = &ast.ExprStaticCall{ yyVAL.node = &ast.ExprStaticCall{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node),
@ -5924,7 +5927,7 @@ yydefault:
} }
case 387: case 387:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3332 // line internal/php7/php7.y:3335
{ {
yyVAL.node = &ast.ExprFunctionCall{ yyVAL.node = &ast.ExprFunctionCall{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node),
@ -5937,7 +5940,7 @@ yydefault:
} }
case 388: case 388:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3346 // line internal/php7/php7.y:3349
{ {
yyVAL.node = &ast.Identifier{ yyVAL.node = &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -5947,31 +5950,31 @@ yydefault:
} }
case 389: case 389:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3354 // line internal/php7/php7.y:3357
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 390: case 390:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3361 // line internal/php7/php7.y:3364
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 391: case 391:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3365 // line internal/php7/php7.y:3368
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 392: case 392:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3372 // line internal/php7/php7.y:3375
{ {
yyVAL.node = nil yyVAL.node = nil
} }
case 393: case 393:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3376 // line internal/php7/php7.y:3379
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -5982,13 +5985,13 @@ yydefault:
} }
case 394: case 394:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3388 // line internal/php7/php7.y:3391
{ {
yyVAL.list = []ast.Vertex{} yyVAL.list = []ast.Vertex{}
} }
case 395: case 395:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3392 // line internal/php7/php7.y:3395
{ {
yyVAL.list = []ast.Vertex{ yyVAL.list = []ast.Vertex{
&ast.ScalarEncapsedStringPart{ &ast.ScalarEncapsedStringPart{
@ -6000,25 +6003,25 @@ yydefault:
} }
case 396: case 396:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3402 // line internal/php7/php7.y:3405
{ {
yyVAL.list = yyDollar[1].list yyVAL.list = yyDollar[1].list
} }
case 397: case 397:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3409 // line internal/php7/php7.y:3412
{ {
yyVAL.node = &ast.ArgumentList{} yyVAL.node = &ast.ArgumentList{}
} }
case 398: case 398:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3413 // line internal/php7/php7.y:3416
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 399: case 399:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3420 // line internal/php7/php7.y:3423
{ {
yyVAL.node = &ast.ExprArray{ yyVAL.node = &ast.ExprArray{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -6031,7 +6034,7 @@ yydefault:
} }
case 400: case 400:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3431 // line internal/php7/php7.y:3434
{ {
yyVAL.node = &ast.ExprArray{ yyVAL.node = &ast.ExprArray{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6043,7 +6046,7 @@ yydefault:
} }
case 401: case 401:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3441 // line internal/php7/php7.y:3444
{ {
yyVAL.node = &ast.ScalarString{ yyVAL.node = &ast.ScalarString{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6053,7 +6056,7 @@ yydefault:
} }
case 402: case 402:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3452 // line internal/php7/php7.y:3455
{ {
yyVAL.node = &ast.ScalarLnumber{ yyVAL.node = &ast.ScalarLnumber{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6063,7 +6066,7 @@ yydefault:
} }
case 403: case 403:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3460 // line internal/php7/php7.y:3463
{ {
yyVAL.node = &ast.ScalarDnumber{ yyVAL.node = &ast.ScalarDnumber{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6073,7 +6076,7 @@ yydefault:
} }
case 404: case 404:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3468 // line internal/php7/php7.y:3471
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6083,7 +6086,7 @@ yydefault:
} }
case 405: case 405:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3476 // line internal/php7/php7.y:3479
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6093,7 +6096,7 @@ yydefault:
} }
case 406: case 406:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3484 // line internal/php7/php7.y:3487
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6103,7 +6106,7 @@ yydefault:
} }
case 407: case 407:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3492 // line internal/php7/php7.y:3495
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6113,7 +6116,7 @@ yydefault:
} }
case 408: case 408:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3500 // line internal/php7/php7.y:3503
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6123,7 +6126,7 @@ yydefault:
} }
case 409: case 409:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3508 // line internal/php7/php7.y:3511
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6133,7 +6136,7 @@ yydefault:
} }
case 410: case 410:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3516 // line internal/php7/php7.y:3519
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6143,7 +6146,7 @@ yydefault:
} }
case 411: case 411:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3524 // line internal/php7/php7.y:3527
{ {
yyVAL.node = &ast.ScalarMagicConstant{ yyVAL.node = &ast.ScalarMagicConstant{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6153,7 +6156,7 @@ yydefault:
} }
case 412: case 412:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3532 // line internal/php7/php7.y:3535
{ {
yyVAL.node = &ast.ScalarHeredoc{ yyVAL.node = &ast.ScalarHeredoc{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6170,7 +6173,7 @@ yydefault:
} }
case 413: case 413:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3547 // line internal/php7/php7.y:3550
{ {
yyVAL.node = &ast.ScalarHeredoc{ yyVAL.node = &ast.ScalarHeredoc{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token),
@ -6180,7 +6183,7 @@ yydefault:
} }
case 414: case 414:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3555 // line internal/php7/php7.y:3558
{ {
yyVAL.node = &ast.ScalarEncapsed{ yyVAL.node = &ast.ScalarEncapsed{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6191,7 +6194,7 @@ yydefault:
} }
case 415: case 415:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3564 // line internal/php7/php7.y:3567
{ {
yyVAL.node = &ast.ScalarHeredoc{ yyVAL.node = &ast.ScalarHeredoc{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6202,19 +6205,19 @@ yydefault:
} }
case 416: case 416:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3573 // line internal/php7/php7.y:3576
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 417: case 417:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3577 // line internal/php7/php7.y:3580
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 418: case 418:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3584 // line internal/php7/php7.y:3587
{ {
yyVAL.node = &ast.ExprConstFetch{ yyVAL.node = &ast.ExprConstFetch{
Position: yylex.(*Parser).builder.NewNodePosition(yyDollar[1].node), Position: yylex.(*Parser).builder.NewNodePosition(yyDollar[1].node),
@ -6223,7 +6226,7 @@ yydefault:
} }
case 419: case 419:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3591 // line internal/php7/php7.y:3594
{ {
yyVAL.node = &ast.ExprClassConstFetch{ yyVAL.node = &ast.ExprClassConstFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token),
@ -6238,7 +6241,7 @@ yydefault:
} }
case 420: case 420:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3604 // line internal/php7/php7.y:3607
{ {
yyVAL.node = &ast.ExprClassConstFetch{ yyVAL.node = &ast.ExprClassConstFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token),
@ -6253,43 +6256,43 @@ yydefault:
} }
case 421: case 421:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3620 // line internal/php7/php7.y:3623
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 422: case 422:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3624 // line internal/php7/php7.y:3627
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 423: case 423:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3631 // line internal/php7/php7.y:3634
{ {
yyVAL.node = nil yyVAL.node = nil
} }
case 424: case 424:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3635 // line internal/php7/php7.y:3638
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 425: case 425:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3642 // line internal/php7/php7.y:3645
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 426: case 426:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3649 // line internal/php7/php7.y:3652
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 427: case 427:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3653 // line internal/php7/php7.y:3656
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6300,19 +6303,19 @@ yydefault:
} }
case 428: case 428:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3662 // line internal/php7/php7.y:3665
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 429: case 429:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3669 // line internal/php7/php7.y:3672
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 430: case 430:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3673 // line internal/php7/php7.y:3676
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6323,19 +6326,19 @@ yydefault:
} }
case 431: case 431:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3682 // line internal/php7/php7.y:3685
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 432: case 432:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3689 // line internal/php7/php7.y:3692
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 433: case 433:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3693 // line internal/php7/php7.y:3696
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token),
@ -6347,7 +6350,7 @@ yydefault:
} }
case 434: case 434:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3703 // line internal/php7/php7.y:3706
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token),
@ -6359,7 +6362,7 @@ yydefault:
} }
case 435: case 435:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3713 // line internal/php7/php7.y:3716
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token),
@ -6371,7 +6374,7 @@ yydefault:
} }
case 436: case 436:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3723 // line internal/php7/php7.y:3726
{ {
yyVAL.node = &ast.ExprMethodCall{ yyVAL.node = &ast.ExprMethodCall{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node),
@ -6386,25 +6389,25 @@ yydefault:
} }
case 437: case 437:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3736 // line internal/php7/php7.y:3739
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 438: case 438:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3743 // line internal/php7/php7.y:3746
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 439: case 439:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3747 // line internal/php7/php7.y:3750
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 440: case 440:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3751 // line internal/php7/php7.y:3754
{ {
yyVAL.node = &ast.ExprPropertyFetch{ yyVAL.node = &ast.ExprPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6415,7 +6418,7 @@ yydefault:
} }
case 441: case 441:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3763 // line internal/php7/php7.y:3766
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6428,7 +6431,7 @@ yydefault:
} }
case 442: case 442:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3774 // line internal/php7/php7.y:3777
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -6443,7 +6446,7 @@ yydefault:
} }
case 443: case 443:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3787 // line internal/php7/php7.y:3790
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -6453,7 +6456,7 @@ yydefault:
} }
case 444: case 444:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3798 // line internal/php7/php7.y:3801
{ {
yyVAL.node = &ast.ExprStaticPropertyFetch{ yyVAL.node = &ast.ExprStaticPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6464,7 +6467,7 @@ yydefault:
} }
case 445: case 445:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3807 // line internal/php7/php7.y:3810
{ {
yyVAL.node = &ast.ExprStaticPropertyFetch{ yyVAL.node = &ast.ExprStaticPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6475,13 +6478,13 @@ yydefault:
} }
case 446: case 446:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3819 // line internal/php7/php7.y:3822
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 447: case 447:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3823 // line internal/php7/php7.y:3826
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token),
@ -6493,7 +6496,7 @@ yydefault:
} }
case 448: case 448:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3833 // line internal/php7/php7.y:3836
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token),
@ -6505,7 +6508,7 @@ yydefault:
} }
case 449: case 449:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3843 // line internal/php7/php7.y:3846
{ {
yyVAL.node = &ast.ExprPropertyFetch{ yyVAL.node = &ast.ExprPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6516,7 +6519,7 @@ yydefault:
} }
case 450: case 450:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3852 // line internal/php7/php7.y:3855
{ {
yyVAL.node = &ast.ExprStaticPropertyFetch{ yyVAL.node = &ast.ExprStaticPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6527,7 +6530,7 @@ yydefault:
} }
case 451: case 451:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3861 // line internal/php7/php7.y:3864
{ {
yyVAL.node = &ast.ExprStaticPropertyFetch{ yyVAL.node = &ast.ExprStaticPropertyFetch{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6538,7 +6541,7 @@ yydefault:
} }
case 452: case 452:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3873 // line internal/php7/php7.y:3876
{ {
yyVAL.node = &ast.Identifier{ yyVAL.node = &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6548,7 +6551,7 @@ yydefault:
} }
case 453: case 453:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3881 // line internal/php7/php7.y:3884
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6559,13 +6562,13 @@ yydefault:
} }
case 454: case 454:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3890 // line internal/php7/php7.y:3893
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 455: case 455:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3897 // line internal/php7/php7.y:3900
{ {
yyVAL.node = &ast.Identifier{ yyVAL.node = &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6575,7 +6578,7 @@ yydefault:
} }
case 456: case 456:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3905 // line internal/php7/php7.y:3908
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6586,13 +6589,13 @@ yydefault:
} }
case 457: case 457:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3914 // line internal/php7/php7.y:3917
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 458: case 458:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3921 // line internal/php7/php7.y:3924
{ {
pairList := yyDollar[1].node.(*ast.ParserSeparatedList) pairList := yyDollar[1].node.(*ast.ParserSeparatedList)
fistPair := pairList.Items[0].(*ast.ExprArrayItem) fistPair := pairList.Items[0].(*ast.ExprArrayItem)
@ -6605,19 +6608,19 @@ yydefault:
} }
case 459: case 459:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
// line internal/php7/php7.y:3935 // line internal/php7/php7.y:3938
{ {
yyVAL.node = &ast.ExprArrayItem{} yyVAL.node = &ast.ExprArrayItem{}
} }
case 460: case 460:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3939 // line internal/php7/php7.y:3942
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }
case 461: case 461:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3946 // line internal/php7/php7.y:3949
{ {
yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[2].token) yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[2].token)
yyDollar[1].node.(*ast.ParserSeparatedList).Items = append(yyDollar[1].node.(*ast.ParserSeparatedList).Items, yyDollar[3].node) yyDollar[1].node.(*ast.ParserSeparatedList).Items = append(yyDollar[1].node.(*ast.ParserSeparatedList).Items, yyDollar[3].node)
@ -6626,7 +6629,7 @@ yydefault:
} }
case 462: case 462:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3953 // line internal/php7/php7.y:3956
{ {
yyVAL.node = &ast.ParserSeparatedList{ yyVAL.node = &ast.ParserSeparatedList{
Items: []ast.Vertex{yyDollar[1].node}, Items: []ast.Vertex{yyDollar[1].node},
@ -6634,7 +6637,7 @@ yydefault:
} }
case 463: case 463:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:3962 // line internal/php7/php7.y:3965
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
@ -6645,7 +6648,7 @@ yydefault:
} }
case 464: case 464:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:3971 // line internal/php7/php7.y:3974
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewNodePosition(yyDollar[1].node), Position: yylex.(*Parser).builder.NewNodePosition(yyDollar[1].node),
@ -6654,7 +6657,7 @@ yydefault:
} }
case 465: case 465:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:3978 // line internal/php7/php7.y:3981
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node), Position: yylex.(*Parser).builder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node),
@ -6669,7 +6672,7 @@ yydefault:
} }
case 466: case 466:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:3991 // line internal/php7/php7.y:3994
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -6682,7 +6685,7 @@ yydefault:
} }
case 467: case 467:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4002 // line internal/php7/php7.y:4005
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -6692,7 +6695,7 @@ yydefault:
} }
case 468: case 468:
yyDollar = yyS[yypt-6 : yypt+1] yyDollar = yyS[yypt-6 : yypt+1]
// line internal/php7/php7.y:4010 // line internal/php7/php7.y:4013
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token), Position: yylex.(*Parser).builder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token),
@ -6710,7 +6713,7 @@ yydefault:
} }
case 469: case 469:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:4026 // line internal/php7/php7.y:4029
{ {
yyVAL.node = &ast.ExprArrayItem{ yyVAL.node = &ast.ExprArrayItem{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -6726,13 +6729,13 @@ yydefault:
} }
case 470: case 470:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4043 // line internal/php7/php7.y:4046
{ {
yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) yyVAL.list = append(yyDollar[1].list, yyDollar[2].node)
} }
case 471: case 471:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4047 // line internal/php7/php7.y:4050
{ {
yyVAL.list = append( yyVAL.list = append(
yyDollar[1].list, yyDollar[1].list,
@ -6745,13 +6748,13 @@ yydefault:
} }
case 472: case 472:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4058 // line internal/php7/php7.y:4061
{ {
yyVAL.list = []ast.Vertex{yyDollar[1].node} yyVAL.list = []ast.Vertex{yyDollar[1].node}
} }
case 473: case 473:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4062 // line internal/php7/php7.y:4065
{ {
yyVAL.list = []ast.Vertex{ yyVAL.list = []ast.Vertex{
&ast.ScalarEncapsedStringPart{ &ast.ScalarEncapsedStringPart{
@ -6764,7 +6767,7 @@ yydefault:
} }
case 474: case 474:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4076 // line internal/php7/php7.y:4079
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6777,7 +6780,7 @@ yydefault:
} }
case 475: case 475:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:4087 // line internal/php7/php7.y:4090
{ {
yyVAL.node = &ast.ExprArrayDimFetch{ yyVAL.node = &ast.ExprArrayDimFetch{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -6796,7 +6799,7 @@ yydefault:
} }
case 476: case 476:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:4104 // line internal/php7/php7.y:4107
{ {
yyVAL.node = &ast.ExprPropertyFetch{ yyVAL.node = &ast.ExprPropertyFetch{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6818,7 +6821,7 @@ yydefault:
} }
case 477: case 477:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:4124 // line internal/php7/php7.y:4127
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6832,7 +6835,7 @@ yydefault:
} }
case 478: case 478:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:4136 // line internal/php7/php7.y:4139
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6850,7 +6853,7 @@ yydefault:
} }
case 479: case 479:
yyDollar = yyS[yypt-6 : yypt+1] yyDollar = yyS[yypt-6 : yypt+1]
// line internal/php7/php7.y:4152 // line internal/php7/php7.y:4155
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token),
@ -6874,7 +6877,7 @@ yydefault:
} }
case 480: case 480:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:4174 // line internal/php7/php7.y:4177
{ {
yyVAL.node = &ast.ParserBrackets{ yyVAL.node = &ast.ParserBrackets{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token),
@ -6885,7 +6888,7 @@ yydefault:
} }
case 481: case 481:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4186 // line internal/php7/php7.y:4189
{ {
yyVAL.node = &ast.ScalarString{ yyVAL.node = &ast.ScalarString{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6895,7 +6898,7 @@ yydefault:
} }
case 482: case 482:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4194 // line internal/php7/php7.y:4197
{ {
// TODO: add option to handle 64 bit integer // TODO: add option to handle 64 bit integer
if _, err := strconv.Atoi(string(yyDollar[1].token.Value)); err == nil { if _, err := strconv.Atoi(string(yyDollar[1].token.Value)); err == nil {
@ -6914,7 +6917,7 @@ yydefault:
} }
case 483: case 483:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4211 // line internal/php7/php7.y:4214
{ {
_, err := strconv.Atoi(string(yyDollar[2].token.Value)) _, err := strconv.Atoi(string(yyDollar[2].token.Value))
isInt := err == nil isInt := err == nil
@ -6940,7 +6943,7 @@ yydefault:
} }
case 484: case 484:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4235 // line internal/php7/php7.y:4238
{ {
yyVAL.node = &ast.ExprVariable{ yyVAL.node = &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token), Position: yylex.(*Parser).builder.NewTokenPosition(yyDollar[1].token),
@ -6953,7 +6956,7 @@ yydefault:
} }
case 485: case 485:
yyDollar = yyS[yypt-5 : yypt+1] yyDollar = yyS[yypt-5 : yypt+1]
// line internal/php7/php7.y:4249 // line internal/php7/php7.y:4252
{ {
if yyDollar[4].token != nil { if yyDollar[4].token != nil {
yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[4].token) yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[4].token)
@ -6970,7 +6973,7 @@ yydefault:
} }
case 486: case 486:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:4264 // line internal/php7/php7.y:4267
{ {
yyVAL.node = &ast.ExprEmpty{ yyVAL.node = &ast.ExprEmpty{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -6982,7 +6985,7 @@ yydefault:
} }
case 487: case 487:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4274 // line internal/php7/php7.y:4277
{ {
yyVAL.node = &ast.ExprInclude{ yyVAL.node = &ast.ExprInclude{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -6992,7 +6995,7 @@ yydefault:
} }
case 488: case 488:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4282 // line internal/php7/php7.y:4285
{ {
yyVAL.node = &ast.ExprIncludeOnce{ yyVAL.node = &ast.ExprIncludeOnce{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -7002,7 +7005,7 @@ yydefault:
} }
case 489: case 489:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php7/php7.y:4290 // line internal/php7/php7.y:4293
{ {
yyVAL.node = &ast.ExprEval{ yyVAL.node = &ast.ExprEval{
Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token), Position: yylex.(*Parser).builder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
@ -7014,7 +7017,7 @@ yydefault:
} }
case 490: case 490:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4300 // line internal/php7/php7.y:4303
{ {
yyVAL.node = &ast.ExprRequire{ yyVAL.node = &ast.ExprRequire{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -7024,7 +7027,7 @@ yydefault:
} }
case 491: case 491:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:4308 // line internal/php7/php7.y:4311
{ {
yyVAL.node = &ast.ExprRequireOnce{ yyVAL.node = &ast.ExprRequireOnce{
Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node), Position: yylex.(*Parser).builder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
@ -7034,7 +7037,7 @@ yydefault:
} }
case 492: case 492:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4319 // line internal/php7/php7.y:4322
{ {
yyVAL.node = &ast.ParserSeparatedList{ yyVAL.node = &ast.ParserSeparatedList{
Items: []ast.Vertex{yyDollar[1].node}, Items: []ast.Vertex{yyDollar[1].node},
@ -7042,7 +7045,7 @@ yydefault:
} }
case 493: case 493:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php7/php7.y:4325 // line internal/php7/php7.y:4328
{ {
yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[2].token) yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[2].token)
yyDollar[1].node.(*ast.ParserSeparatedList).Items = append(yyDollar[1].node.(*ast.ParserSeparatedList).Items, yyDollar[3].node) yyDollar[1].node.(*ast.ParserSeparatedList).Items = append(yyDollar[1].node.(*ast.ParserSeparatedList).Items, yyDollar[3].node)
@ -7051,7 +7054,7 @@ yydefault:
} }
case 494: case 494:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:4335 // line internal/php7/php7.y:4338
{ {
yyVAL.node = yyDollar[1].node yyVAL.node = yyDollar[1].node
} }

View File

@ -3178,21 +3178,22 @@ expr_without_variable:
inline_function: inline_function:
T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}' T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}'
{ {
$$ = &ast.ExprClosure{ closure := $7.(*ast.ExprClosure)
Position: yylex.(*Parser).builder.NewTokensPosition($1, $11),
FunctionTkn: $1, closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $11)
AmpersandTkn: $2, closure.FunctionTkn = $1
OpenParenthesisTkn: $4, closure.AmpersandTkn = $2
Params: $5.(*ast.ParserSeparatedList).Items, closure.OpenParenthesisTkn = $4
SeparatorTkns: $5.(*ast.ParserSeparatedList).SeparatorTkns, closure.Params = $5.(*ast.ParserSeparatedList).Items
CloseParenthesisTkn: $6, closure.SeparatorTkns = $5.(*ast.ParserSeparatedList).SeparatorTkns
ClosureUse: $7, closure.CloseParenthesisTkn = $6
ColonTkn: $8.(*ast.ReturnType).ColonTkn, closure.ColonTkn = $8.(*ast.ReturnType).ColonTkn
ReturnType: $8.(*ast.ReturnType).Type, closure.ReturnType = $8.(*ast.ReturnType).Type
OpenCurlyBracketTkn: $9, closure.OpenCurlyBracketTkn = $9
Stmts: $10, closure.Stmts = $10
CloseCurlyBracketTkn: $11, closure.CloseCurlyBracketTkn = $11
}
$$ = closure
} }
| T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr | T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr
{ {
@ -3230,17 +3231,16 @@ returns_ref:
lexical_vars: lexical_vars:
/* empty */ /* empty */
{ {
$$ = nil $$ = &ast.ExprClosure{}
} }
| T_USE '(' lexical_var_list ')' | T_USE '(' lexical_var_list ')'
{ {
$$ = &ast.ExprClosureUse{ $$ = &ast.ExprClosure{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $4),
UseTkn: $1, UseTkn: $1,
OpenParenthesisTkn: $2, UseOpenParenthesisTkn: $2,
Uses: $3.(*ast.ParserSeparatedList).Items, Use: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns, UseSeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: $4, UseCloseParenthesisTkn: $4,
} }
} }
; ;
@ -3264,18 +3264,21 @@ lexical_var_list:
lexical_var: lexical_var:
T_VARIABLE T_VARIABLE
{ {
$$ = &ast.ExprVariable{ $$ = &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokenPosition($1),
Var: &ast.ExprVariable{
Position: yylex.(*Parser).builder.NewTokenPosition($1), Position: yylex.(*Parser).builder.NewTokenPosition($1),
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Position: yylex.(*Parser).builder.NewTokenPosition($1), Position: yylex.(*Parser).builder.NewTokenPosition($1),
IdentifierTkn: $1, IdentifierTkn: $1,
Value: $1.Value, Value: $1.Value,
}, },
},
} }
} }
| '&' T_VARIABLE | '&' T_VARIABLE
{ {
$$ = &ast.ExprReference{ $$ = &ast.ExprClosureUse{
Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), Position: yylex.(*Parser).builder.NewTokensPosition($1, $2),
AmpersandTkn: $1, AmpersandTkn: $1,
Var: &ast.ExprVariable{ Var: &ast.ExprVariable{

View File

@ -1282,7 +1282,11 @@ type ExprClosure struct {
Params []Vertex Params []Vertex
SeparatorTkns []*token.Token SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token CloseParenthesisTkn *token.Token
ClosureUse Vertex UseTkn *token.Token
UseOpenParenthesisTkn *token.Token
Use []Vertex
UseSeparatorTkns []*token.Token
UseCloseParenthesisTkn *token.Token
ColonTkn *token.Token ColonTkn *token.Token
ReturnType Vertex ReturnType Vertex
OpenCurlyBracketTkn *token.Token OpenCurlyBracketTkn *token.Token
@ -1301,11 +1305,8 @@ func (n *ExprClosure) GetPosition() *position.Position {
// ExprClosureUse node // ExprClosureUse node
type ExprClosureUse struct { type ExprClosureUse struct {
Position *position.Position Position *position.Position
UseTkn *token.Token AmpersandTkn *token.Token
OpenParenthesisTkn *token.Token Var Vertex
Uses []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
} }
func (n *ExprClosureUse) Accept(v NodeVisitor) { func (n *ExprClosureUse) Accept(v NodeVisitor) {

View File

@ -1152,10 +1152,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
} }
t.visitor.Leave("Params", false) t.visitor.Leave("Params", false)
} }
if nn.ClosureUse != nil { if nn.Use != nil {
t.visitor.Enter("ClosureUse", true) t.visitor.Enter("Use", false)
t.Traverse(nn.ClosureUse) for _, c := range nn.Use {
t.visitor.Leave("ClosureUse", true) t.Traverse(c)
}
t.visitor.Leave("Use", false)
} }
if nn.ReturnType != nil { if nn.ReturnType != nil {
t.visitor.Enter("ReturnType", true) t.visitor.Enter("ReturnType", true)
@ -1176,12 +1178,10 @@ func (t *DFS) Traverse(n ast.Vertex) {
if !t.visitor.EnterNode(nn) { if !t.visitor.EnterNode(nn) {
return return
} }
if nn.Uses != nil { if nn.Var != nil {
t.visitor.Enter("Uses", false) t.visitor.Enter("Var", true)
for _, c := range nn.Uses { t.Traverse(nn.Var)
t.Traverse(c) t.visitor.Leave("Var", true)
}
t.visitor.Leave("Uses", false)
} }
case *ast.ExprConstFetch: case *ast.ExprConstFetch:
if nn == nil { if nn == nil {

View File

@ -1143,7 +1143,11 @@ func (v *Dumper) ExprClosure(n *ast.ExprClosure) {
v.dumpVertexList("Params", n.Params) v.dumpVertexList("Params", n.Params)
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn)
v.dumpVertex("ClosureUse", n.ClosureUse) v.dumpToken("UseTkn", n.UseTkn)
v.dumpToken("UseOpenParenthesisTkn", n.UseOpenParenthesisTkn)
v.dumpVertexList("Use", n.Use)
v.dumpTokenList("UseSeparatorTkns", n.UseSeparatorTkns)
v.dumpToken("UseCloseParenthesisTkn", n.UseCloseParenthesisTkn)
v.dumpToken("ColonTkn", n.ColonTkn) v.dumpToken("ColonTkn", n.ColonTkn)
v.dumpVertex("ReturnType", n.ReturnType) v.dumpVertex("ReturnType", n.ReturnType)
v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn)
@ -1159,11 +1163,8 @@ func (v *Dumper) ExprClosureUse(n *ast.ExprClosureUse) {
v.indent++ v.indent++
v.dumpPosition(n.Position) v.dumpPosition(n.Position)
v.dumpToken("UseTkn", n.UseTkn) v.dumpToken("AmpersandTkn", n.AmpersandTkn)
v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) v.dumpVertex("Var", n.Var)
v.dumpVertexList("Uses", n.Uses)
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn)
v.indent-- v.indent--
v.print(v.indent, "},\n") v.print(v.indent, "},\n")

View File

@ -1162,9 +1162,16 @@ func (f *formatter) ExprClosure(n *ast.ExprClosure) {
} }
n.CloseParenthesisTkn = f.newToken(')', []byte(")")) n.CloseParenthesisTkn = f.newToken(')', []byte(")"))
if n.ClosureUse != nil { n.UseTkn = nil
n.UseOpenParenthesisTkn = nil
n.UseCloseParenthesisTkn = nil
n.UseSeparatorTkns = nil
if len(n.Use) > 0 {
f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
n.ClosureUse.Accept(f) n.UseTkn = f.newToken(token.T_USE, []byte("use"))
n.OpenParenthesisTkn = f.newToken('(', []byte("("))
n.SeparatorTkns = f.formatList(n.Use, ',')
n.CloseParenthesisTkn = f.newToken(')', []byte(")"))
} }
n.ColonTkn = nil n.ColonTkn = nil
@ -1189,10 +1196,11 @@ func (f *formatter) ExprClosure(n *ast.ExprClosure) {
} }
func (f *formatter) ExprClosureUse(n *ast.ExprClosureUse) { func (f *formatter) ExprClosureUse(n *ast.ExprClosureUse) {
n.UseTkn = f.newToken(token.T_USE, []byte("use")) if n.AmpersandTkn != nil {
n.OpenParenthesisTkn = f.newToken('(', []byte("(")) n.AmpersandTkn = f.newToken('&', []byte("&"))
n.SeparatorTkns = f.formatList(n.Uses, ',') }
n.CloseParenthesisTkn = f.newToken(')', []byte(")"))
n.Var.Accept(f)
} }
func (f *formatter) ExprConstFetch(n *ast.ExprConstFetch) { func (f *formatter) ExprConstFetch(n *ast.ExprConstFetch) {

View File

@ -3714,9 +3714,9 @@ func TestFormatter_ExprClosure_Use(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
n := &ast.ExprClosure{ n := &ast.ExprClosure{
ClosureUse: &ast.ExprClosureUse{ Use: []ast.Vertex{
Uses: []ast.Vertex{ &ast.ExprClosureUse{
&ast.ExprVariable{ Var: &ast.ExprVariable{
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Value: []byte("$foo"), Value: []byte("$foo"),
}, },
@ -3748,18 +3748,11 @@ func TestFormatter_ExprClosureUse(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
n := &ast.ExprClosureUse{ n := &ast.ExprClosureUse{
Uses: []ast.Vertex{ Var: &ast.ExprVariable{
&ast.ExprVariable{
VarName: &ast.Identifier{ VarName: &ast.Identifier{
Value: []byte("$a"), Value: []byte("$a"),
}, },
}, },
&ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$b"),
},
},
},
} }
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1) f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
@ -3768,7 +3761,33 @@ func TestFormatter_ExprClosureUse(t *testing.T) {
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP) p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
n.Accept(p) n.Accept(p)
expected := `use($a, $b)` expected := `$a`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestFormatter_ExprClosureUse_Reference(t *testing.T) {
o := bytes.NewBufferString("")
n := &ast.ExprClosureUse{
AmpersandTkn: &token.Token{},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$a"),
},
},
}
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
n.Accept(f)
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
n.Accept(p)
expected := `&$a`
actual := o.String() actual := o.String()
if expected != actual { if expected != actual {

View File

@ -562,7 +562,6 @@ func TestResolveClosureName(t *testing.T) {
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}}, Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
}, },
}, },
ClosureUse: nil,
ReturnType: &ast.Nullable{Expr: nameBC}, ReturnType: &ast.Nullable{Expr: nameBC},
Stmts: []ast.Vertex{}, Stmts: []ast.Vertex{},
} }

View File

@ -684,7 +684,10 @@ func (p *printer) ExprClosure(n *ast.ExprClosure) {
p.printToken(n.OpenParenthesisTkn, []byte("(")) p.printToken(n.OpenParenthesisTkn, []byte("("))
p.printSeparatedList(n.Params, n.SeparatorTkns, []byte(",")) p.printSeparatedList(n.Params, n.SeparatorTkns, []byte(","))
p.printToken(n.CloseParenthesisTkn, []byte(")")) p.printToken(n.CloseParenthesisTkn, []byte(")"))
p.printNode(n.ClosureUse) p.printToken(n.UseTkn, p.ifNodeList(n.Use, []byte("use")))
p.printToken(n.UseOpenParenthesisTkn, p.ifNodeList(n.Use, []byte("(")))
p.printSeparatedList(n.Use, n.UseSeparatorTkns, []byte(","))
p.printToken(n.UseCloseParenthesisTkn, p.ifNodeList(n.Use, []byte(")")))
p.printToken(n.ColonTkn, p.ifNode(n.ReturnType, []byte(":"))) p.printToken(n.ColonTkn, p.ifNode(n.ReturnType, []byte(":")))
p.printNode(n.ReturnType) p.printNode(n.ReturnType)
p.printToken(n.OpenCurlyBracketTkn, []byte("{")) p.printToken(n.OpenCurlyBracketTkn, []byte("{"))
@ -693,10 +696,8 @@ func (p *printer) ExprClosure(n *ast.ExprClosure) {
} }
func (p *printer) ExprClosureUse(n *ast.ExprClosureUse) { func (p *printer) ExprClosureUse(n *ast.ExprClosureUse) {
p.printToken(n.UseTkn, []byte("use")) p.printToken(n.AmpersandTkn, nil)
p.printToken(n.OpenParenthesisTkn, []byte("(")) p.printNode(n.Var)
p.printSeparatedList(n.Uses, n.SeparatorTkns, []byte(","))
p.printToken(n.CloseParenthesisTkn, []byte(")"))
} }
func (p *printer) ExprConstFetch(n *ast.ExprConstFetch) { func (p *printer) ExprConstFetch(n *ast.ExprConstFetch) {

View File

@ -1717,18 +1717,35 @@ func TestPrinterPrintExprClosureUse(t *testing.T) {
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP) p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
n := &ast.ExprClosureUse{ n := &ast.ExprClosureUse{
Uses: []ast.Vertex{ Var: &ast.ExprVariable{
&ast.ExprReference{Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$foo")}, VarName: &ast.Identifier{Value: []byte("$foo")},
}},
&ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$bar")},
},
}, },
} }
n.Accept(p) n.Accept(p)
expected := `use(&$foo,$bar)` expected := `$foo`
actual := o.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestPrinterPrintExprClosureUse_Reference(t *testing.T) {
o := bytes.NewBufferString("")
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
n := &ast.ExprClosureUse{
AmpersandTkn: &token.Token{
Value: []byte("&"),
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$foo")},
},
}
n.Accept(p)
expected := `&$foo`
actual := o.String() actual := o.String()
if expected != actual { if expected != actual {
@ -1754,12 +1771,17 @@ func TestPrinterPrintExprClosure(t *testing.T) {
}, },
}, },
}, },
ClosureUse: &ast.ExprClosureUse{ Use: []ast.Vertex{
Uses: []ast.Vertex{ &ast.ExprClosureUse{
&ast.ExprReference{Var: &ast.ExprVariable{ AmpersandTkn: &token.Token{
Value: []byte("&"),
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$a")}, VarName: &ast.Identifier{Value: []byte("$a")},
}}, },
&ast.ExprVariable{ },
&ast.ExprClosureUse{
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$b")}, VarName: &ast.Identifier{Value: []byte("$b")},
}, },
}, },