[refactoring] update ast structure of parameter "Variadic" and "Reference" nodes

This commit is contained in:
Vadym Slizov 2020-11-20 22:14:26 +02:00
parent 43ace92875
commit ddb9f3b985
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
5 changed files with 60 additions and 26 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -2041,15 +2041,23 @@ parameter:
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens) yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
if $3 != nil { if $3 != nil {
variable = &ast.Variadic{ast.Node{}, variable} variable = &ast.Variadic{
variable.GetNode().Position = position.NewTokensPosition($3, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens) Position: position.NewTokensPosition($3, $4),
},
VariadicTkn: $3,
Var: variable,
}
} }
if $2 != nil { if $2 != nil {
variable = &ast.Reference{ast.Node{}, variable} variable = &ast.Reference{
variable.GetNode().Position = position.NewTokensPosition($2, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $2.SkippedTokens) Position: position.NewTokensPosition($2, $4),
},
AmpersandTkn: $2,
Var: variable,
}
} }
$$ = &ast.Parameter{ast.Node{}, $1, variable, nil} $$ = &ast.Parameter{ast.Node{}, $1, variable, nil}
@ -2081,15 +2089,23 @@ parameter:
yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens) yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens)
if $3 != nil { if $3 != nil {
variable = &ast.Variadic{ast.Node{}, variable} variable = &ast.Variadic{
variable.GetNode().Position = position.NewTokensPosition($3, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens) Position: position.NewTokensPosition($3, $4),
},
VariadicTkn: $3,
Var: variable,
}
} }
if $2 != nil { if $2 != nil {
variable = &ast.Reference{ast.Node{}, variable} variable = &ast.Reference{
variable.GetNode().Position = position.NewTokensPosition($2, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $2.SkippedTokens) Position: position.NewTokensPosition($2, $4),
},
AmpersandTkn: $2,
Var: variable,
}
} }
$$ = &ast.Parameter{ast.Node{}, $1, variable, $6} $$ = &ast.Parameter{ast.Node{}, $1, variable, $6}

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -1865,15 +1865,23 @@ parameter:
yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens) yylex.(*Parser).setFreeFloating(variable, token.Start, $4.SkippedTokens)
if $3 != nil { if $3 != nil {
variable = &ast.Variadic{ast.Node{}, variable} variable = &ast.Variadic{
variable.GetNode().Position = position.NewTokensPosition($3, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens) Position: position.NewTokensPosition($3, $4),
},
VariadicTkn: $3,
Var: variable,
}
} }
if $2 != nil { if $2 != nil {
variable = &ast.Reference{ast.Node{}, variable} variable = &ast.Reference{
variable.GetNode().Position = position.NewTokensPosition($2, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $2.SkippedTokens) Position: position.NewTokensPosition($2, $4),
},
AmpersandTkn: $2,
Var: variable,
}
} }
$$ = &ast.Parameter{ast.Node{}, $1, variable, nil} $$ = &ast.Parameter{ast.Node{}, $1, variable, nil}
@ -1905,15 +1913,23 @@ parameter:
yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens) yylex.(*Parser).setFreeFloating(variable, token.End, $5.SkippedTokens)
if $3 != nil { if $3 != nil {
variable = &ast.Variadic{ast.Node{}, variable} variable = &ast.Variadic{
variable.GetNode().Position = position.NewTokensPosition($3, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $3.SkippedTokens) Position: position.NewTokensPosition($3, $4),
},
VariadicTkn: $3,
Var: variable,
}
} }
if $2 != nil { if $2 != nil {
variable = &ast.Reference{ast.Node{}, variable} variable = &ast.Reference{
variable.GetNode().Position = position.NewTokensPosition($2, $4) Node: ast.Node{
yylex.(*Parser).setFreeFloating(variable, token.Start, $2.SkippedTokens) Position: position.NewTokensPosition($2, $4),
},
AmpersandTkn: $2,
Var: variable,
}
} }
$$ = &ast.Parameter{ast.Node{}, $1, variable, $6} $$ = &ast.Parameter{ast.Node{}, $1, variable, $6}

View File

@ -44,6 +44,7 @@ func (n *Nullable) Accept(v NodeVisitor) {
// Reference node // Reference node
type Reference struct { type Reference struct {
Node Node
AmpersandTkn *token.Token
Var Vertex Var Vertex
} }
@ -54,6 +55,7 @@ func (n *Reference) Accept(v NodeVisitor) {
// Variadic node // Variadic node
type Variadic struct { type Variadic struct {
Node Node
VariadicTkn *token.Token
Var Vertex Var Vertex
} }