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

View File

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