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

@ -31770,7 +31770,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 36,
},
FunctionTkn: &token.Token{
ID: token.T_FUNCTION,
ID: token.T_FUNCTION,
Value: []byte("function"),
Position: &position.Position{
StartLine: 1,
@ -31780,7 +31780,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_OPEN_TAG,
ID: token.T_OPEN_TAG,
Value: []byte("<?"),
Position: &position.Position{
StartLine: 1,
@ -31790,7 +31790,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -31802,7 +31802,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
@ -31834,7 +31834,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 14,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$a"),
Position: &position.Position{
StartLine: 1,
@ -31869,7 +31869,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 18,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$b"),
Position: &position.Position{
StartLine: 1,
@ -31879,7 +31879,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -31897,7 +31897,7 @@ func TestExprClosure_Use(t *testing.T) {
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
@ -31908,7 +31908,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
@ -31917,59 +31917,59 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 19,
},
},
ClosureUse: &ast.ExprClosureUse{
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
EndPos: 23,
},
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
},
Uses: []ast.Vertex{
&ast.ExprVariable{
},
Use: []ast.Vertex{
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 27,
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@ -31984,7 +31984,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 27,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
@ -31996,89 +31996,89 @@ func TestExprClosure_Use(t *testing.T) {
Value: []byte("$c"),
},
},
&ast.ExprReference{
},
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 32,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 32,
EndPos: 30,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 30,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
},
},
Var: &ast.ExprVariable{
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
VarName: &ast.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
VarName: &ast.Identifier{
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
},
Value: []byte("$d"),
},
Value: []byte("$d"),
},
},
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 27,
EndPos: 28,
},
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
},
UseSeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 27,
EndPos: 28,
},
},
},
UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123),
ID: token.ID(123),
Value: []byte("{"),
Position: &position.Position{
StartLine: 1,
@ -32088,7 +32088,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -32101,7 +32101,7 @@ func TestExprClosure_Use(t *testing.T) {
},
Stmts: []ast.Vertex{},
CloseCurlyBracketTkn: &token.Token{
ID: token.ID(125),
ID: token.ID(125),
Value: []byte("}"),
Position: &position.Position{
StartLine: 1,
@ -32112,7 +32112,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
SemiColonTkn: &token.Token{
ID: token.ID(59),
ID: token.ID(59),
Value: []byte(";"),
Position: &position.Position{
StartLine: 1,
@ -32123,7 +32123,8 @@ func TestExprClosure_Use(t *testing.T) {
},
},
},
EndTkn: &token.Token{},
EndTkn: &token.Token{
},
}
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
@ -32159,7 +32160,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 36,
},
FunctionTkn: &token.Token{
ID: token.T_FUNCTION,
ID: token.T_FUNCTION,
Value: []byte("function"),
Position: &position.Position{
StartLine: 1,
@ -32169,7 +32170,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_OPEN_TAG,
ID: token.T_OPEN_TAG,
Value: []byte("<?"),
Position: &position.Position{
StartLine: 1,
@ -32179,7 +32180,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -32191,7 +32192,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
@ -32223,7 +32224,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 14,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$a"),
Position: &position.Position{
StartLine: 1,
@ -32258,7 +32259,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 18,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$b"),
Position: &position.Position{
StartLine: 1,
@ -32268,7 +32269,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -32286,7 +32287,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
@ -32297,7 +32298,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
@ -32306,104 +32307,104 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 19,
},
},
ClosureUse: &ast.ExprClosureUse{
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
EndPos: 23,
},
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
},
Uses: []ast.Vertex{
&ast.ExprReference{
},
Use: []ast.Vertex{
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 28,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 26,
},
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 26,
},
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
VarName: &ast.Identifier{
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
},
Value: []byte("$c"),
},
Value: []byte("$c"),
},
},
&ast.ExprVariable{
},
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@ -32418,7 +32419,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 32,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
@ -32428,7 +32429,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -32443,31 +32444,31 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
},
UseSeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
StartPos: 28,
EndPos: 29,
},
},
},
UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123),
ID: token.ID(123),
Value: []byte("{"),
Position: &position.Position{
StartLine: 1,
@ -32477,7 +32478,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -32490,7 +32491,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
Stmts: []ast.Vertex{},
CloseCurlyBracketTkn: &token.Token{
ID: token.ID(125),
ID: token.ID(125),
Value: []byte("}"),
Position: &position.Position{
StartLine: 1,
@ -32501,7 +32502,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
SemiColonTkn: &token.Token{
ID: token.ID(59),
ID: token.ID(59),
Value: []byte(";"),
Position: &position.Position{
StartLine: 1,
@ -32512,7 +32513,8 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
},
EndTkn: &token.Token{},
EndTkn: &token.Token{
},
}
lexer := scanner.NewLexer([]byte(src), "5.6", nil)

569
internal/php5/php5.go generated

File diff suppressed because it is too large Load Diff

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

@ -36268,7 +36268,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 36,
},
FunctionTkn: &token.Token{
ID: token.T_FUNCTION,
ID: token.T_FUNCTION,
Value: []byte("function"),
Position: &position.Position{
StartLine: 1,
@ -36278,7 +36278,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_OPEN_TAG,
ID: token.T_OPEN_TAG,
Value: []byte("<?"),
Position: &position.Position{
StartLine: 1,
@ -36288,7 +36288,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36300,7 +36300,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
@ -36332,7 +36332,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 14,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$a"),
Position: &position.Position{
StartLine: 1,
@ -36367,7 +36367,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 18,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$b"),
Position: &position.Position{
StartLine: 1,
@ -36377,7 +36377,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36395,7 +36395,7 @@ func TestExprClosure_Use(t *testing.T) {
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
@ -36406,7 +36406,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
@ -36415,59 +36415,59 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 19,
},
},
ClosureUse: &ast.ExprClosureUse{
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
EndPos: 23,
},
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
},
Uses: []ast.Vertex{
&ast.ExprVariable{
},
Use: []ast.Vertex{
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 27,
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@ -36482,7 +36482,7 @@ func TestExprClosure_Use(t *testing.T) {
EndPos: 27,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
@ -36494,89 +36494,89 @@ func TestExprClosure_Use(t *testing.T) {
Value: []byte("$c"),
},
},
&ast.ExprReference{
},
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 32,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 32,
EndPos: 30,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 29,
EndPos: 30,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
},
},
Var: &ast.ExprVariable{
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
VarName: &ast.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
VarName: &ast.Identifier{
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
},
Value: []byte("$d"),
},
Value: []byte("$d"),
},
},
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 27,
EndPos: 28,
},
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
},
UseSeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 27,
EndPos: 28,
},
},
},
UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123),
ID: token.ID(123),
Value: []byte("{"),
Position: &position.Position{
StartLine: 1,
@ -36586,7 +36586,7 @@ func TestExprClosure_Use(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36599,7 +36599,7 @@ func TestExprClosure_Use(t *testing.T) {
},
Stmts: []ast.Vertex{},
CloseCurlyBracketTkn: &token.Token{
ID: token.ID(125),
ID: token.ID(125),
Value: []byte("}"),
Position: &position.Position{
StartLine: 1,
@ -36610,7 +36610,7 @@ func TestExprClosure_Use(t *testing.T) {
},
},
SemiColonTkn: &token.Token{
ID: token.ID(59),
ID: token.ID(59),
Value: []byte(";"),
Position: &position.Position{
StartLine: 1,
@ -36621,7 +36621,8 @@ func TestExprClosure_Use(t *testing.T) {
},
},
},
EndTkn: &token.Token{},
EndTkn: &token.Token{
},
}
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
@ -36657,7 +36658,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 36,
},
FunctionTkn: &token.Token{
ID: token.T_FUNCTION,
ID: token.T_FUNCTION,
Value: []byte("function"),
Position: &position.Position{
StartLine: 1,
@ -36667,7 +36668,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_OPEN_TAG,
ID: token.T_OPEN_TAG,
Value: []byte("<?"),
Position: &position.Position{
StartLine: 1,
@ -36677,7 +36678,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36689,7 +36690,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
@ -36721,7 +36722,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 14,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$a"),
Position: &position.Position{
StartLine: 1,
@ -36756,7 +36757,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 18,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$b"),
Position: &position.Position{
StartLine: 1,
@ -36766,7 +36767,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36784,7 +36785,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
@ -36795,7 +36796,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
@ -36804,104 +36805,104 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 19,
},
},
ClosureUse: &ast.ExprClosureUse{
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 33,
EndPos: 23,
},
UseTkn: &token.Token{
ID: token.T_USE,
Value: []byte("use"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 23,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 20,
},
},
},
OpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
UseOpenParenthesisTkn: &token.Token{
ID: token.ID(40),
Value: []byte("("),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 25,
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 23,
EndPos: 24,
},
},
},
Uses: []ast.Vertex{
&ast.ExprReference{
},
Use: []ast.Vertex{
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 28,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 26,
},
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
AmpersandTkn: &token.Token{
ID: token.ID(38),
Value: []byte("&"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 25,
EndPos: 26,
},
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
VarName: &ast.Identifier{
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
Value: []byte("$c"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 26,
EndPos: 28,
},
},
Value: []byte("$c"),
},
Value: []byte("$c"),
},
},
&ast.ExprVariable{
},
&ast.ExprClosureUse{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 30,
EndPos: 32,
},
Var: &ast.ExprVariable{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
@ -36916,7 +36917,7 @@ func TestExprClosure_Use2(t *testing.T) {
EndPos: 32,
},
IdentifierTkn: &token.Token{
ID: token.T_VARIABLE,
ID: token.T_VARIABLE,
Value: []byte("$d"),
Position: &position.Position{
StartLine: 1,
@ -36926,7 +36927,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36941,31 +36942,31 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
},
SeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 28,
EndPos: 29,
},
},
},
CloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
},
UseSeparatorTkns: []*token.Token{
{
ID: token.ID(44),
Value: []byte(","),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
StartPos: 28,
EndPos: 29,
},
},
},
UseCloseParenthesisTkn: &token.Token{
ID: token.ID(41),
Value: []byte(")"),
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 32,
EndPos: 33,
},
},
OpenCurlyBracketTkn: &token.Token{
ID: token.ID(123),
ID: token.ID(123),
Value: []byte("{"),
Position: &position.Position{
StartLine: 1,
@ -36975,7 +36976,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
FreeFloating: []*token.Token{
{
ID: token.T_WHITESPACE,
ID: token.T_WHITESPACE,
Value: []byte(" "),
Position: &position.Position{
StartLine: 1,
@ -36988,7 +36989,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
Stmts: []ast.Vertex{},
CloseCurlyBracketTkn: &token.Token{
ID: token.ID(125),
ID: token.ID(125),
Value: []byte("}"),
Position: &position.Position{
StartLine: 1,
@ -36999,7 +37000,7 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
SemiColonTkn: &token.Token{
ID: token.ID(59),
ID: token.ID(59),
Value: []byte(";"),
Position: &position.Position{
StartLine: 1,
@ -37010,7 +37011,8 @@ func TestExprClosure_Use2(t *testing.T) {
},
},
},
EndTkn: &token.Token{},
EndTkn: &token.Token{
},
}
lexer := scanner.NewLexer([]byte(src), "7.4", nil)

297
internal/php7/php7.go generated

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

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

@ -1274,20 +1274,24 @@ func (n *ExprClone) GetPosition() *position.Position {
// ExprClosure node
type ExprClosure struct {
Position *position.Position
StaticTkn *token.Token
FunctionTkn *token.Token
AmpersandTkn *token.Token
OpenParenthesisTkn *token.Token
Params []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
ClosureUse Vertex
ColonTkn *token.Token
ReturnType Vertex
OpenCurlyBracketTkn *token.Token
Stmts []Vertex
CloseCurlyBracketTkn *token.Token
Position *position.Position
StaticTkn *token.Token
FunctionTkn *token.Token
AmpersandTkn *token.Token
OpenParenthesisTkn *token.Token
Params []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
UseTkn *token.Token
UseOpenParenthesisTkn *token.Token
Use []Vertex
UseSeparatorTkns []*token.Token
UseCloseParenthesisTkn *token.Token
ColonTkn *token.Token
ReturnType Vertex
OpenCurlyBracketTkn *token.Token
Stmts []Vertex
CloseCurlyBracketTkn *token.Token
}
func (n *ExprClosure) Accept(v NodeVisitor) {
@ -1300,12 +1304,9 @@ func (n *ExprClosure) GetPosition() *position.Position {
// ExprClosureUse node
type ExprClosureUse struct {
Position *position.Position
UseTkn *token.Token
OpenParenthesisTkn *token.Token
Uses []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
Position *position.Position
AmpersandTkn *token.Token
Var Vertex
}
func (n *ExprClosureUse) Accept(v NodeVisitor) {

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

@ -1143,7 +1143,11 @@ func (v *Dumper) ExprClosure(n *ast.ExprClosure) {
v.dumpVertexList("Params", n.Params)
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
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.dumpVertex("ReturnType", n.ReturnType)
v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn)
@ -1159,11 +1163,8 @@ func (v *Dumper) ExprClosureUse(n *ast.ExprClosureUse) {
v.indent++
v.dumpPosition(n.Position)
v.dumpToken("UseTkn", n.UseTkn)
v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn)
v.dumpVertexList("Uses", n.Uses)
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn)
v.dumpToken("AmpersandTkn", n.AmpersandTkn)
v.dumpVertex("Var", n.Var)
v.indent--
v.print(v.indent, "},\n")

@ -1162,9 +1162,16 @@ func (f *formatter) ExprClosure(n *ast.ExprClosure) {
}
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(" "))
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
@ -1189,10 +1196,11 @@ func (f *formatter) ExprClosure(n *ast.ExprClosure) {
}
func (f *formatter) ExprClosureUse(n *ast.ExprClosureUse) {
n.UseTkn = f.newToken(token.T_USE, []byte("use"))
n.OpenParenthesisTkn = f.newToken('(', []byte("("))
n.SeparatorTkns = f.formatList(n.Uses, ',')
n.CloseParenthesisTkn = f.newToken(')', []byte(")"))
if n.AmpersandTkn != nil {
n.AmpersandTkn = f.newToken('&', []byte("&"))
}
n.Var.Accept(f)
}
func (f *formatter) ExprConstFetch(n *ast.ExprConstFetch) {

@ -3714,9 +3714,9 @@ func TestFormatter_ExprClosure_Use(t *testing.T) {
o := bytes.NewBufferString("")
n := &ast.ExprClosure{
ClosureUse: &ast.ExprClosureUse{
Uses: []ast.Vertex{
&ast.ExprVariable{
Use: []ast.Vertex{
&ast.ExprClosureUse{
Var: &ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$foo"),
},
@ -3748,16 +3748,9 @@ func TestFormatter_ExprClosureUse(t *testing.T) {
o := bytes.NewBufferString("")
n := &ast.ExprClosureUse{
Uses: []ast.Vertex{
&ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$a"),
},
},
&ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$b"),
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{
Value: []byte("$a"),
},
},
}
@ -3768,7 +3761,33 @@ func TestFormatter_ExprClosureUse(t *testing.T) {
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
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()
if expected != actual {

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

@ -684,7 +684,10 @@ func (p *printer) ExprClosure(n *ast.ExprClosure) {
p.printToken(n.OpenParenthesisTkn, []byte("("))
p.printSeparatedList(n.Params, n.SeparatorTkns, []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.printNode(n.ReturnType)
p.printToken(n.OpenCurlyBracketTkn, []byte("{"))
@ -693,10 +696,8 @@ func (p *printer) ExprClosure(n *ast.ExprClosure) {
}
func (p *printer) ExprClosureUse(n *ast.ExprClosureUse) {
p.printToken(n.UseTkn, []byte("use"))
p.printToken(n.OpenParenthesisTkn, []byte("("))
p.printSeparatedList(n.Uses, n.SeparatorTkns, []byte(","))
p.printToken(n.CloseParenthesisTkn, []byte(")"))
p.printToken(n.AmpersandTkn, nil)
p.printNode(n.Var)
}
func (p *printer) ExprConstFetch(n *ast.ExprConstFetch) {

@ -1717,18 +1717,35 @@ func TestPrinterPrintExprClosureUse(t *testing.T) {
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
n := &ast.ExprClosureUse{
Uses: []ast.Vertex{
&ast.ExprReference{Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$foo")},
}},
&ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$bar")},
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$foo")},
},
}
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()
if expected != actual {
@ -1754,12 +1771,17 @@ func TestPrinterPrintExprClosure(t *testing.T) {
},
},
},
ClosureUse: &ast.ExprClosureUse{
Uses: []ast.Vertex{
&ast.ExprReference{Var: &ast.ExprVariable{
Use: []ast.Vertex{
&ast.ExprClosureUse{
AmpersandTkn: &token.Token{
Value: []byte("&"),
},
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$a")},
}},
&ast.ExprVariable{
},
},
&ast.ExprClosureUse{
Var: &ast.ExprVariable{
VarName: &ast.Identifier{Value: []byte("$b")},
},
},