[refactoring] update ast structure of parameter "Parameter" node

This commit is contained in:
Vadym Slizov 2020-11-20 22:25:37 +02:00
parent ddb9f3b985
commit 73d819eb6c
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
5 changed files with 54 additions and 29 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -2060,19 +2060,24 @@ parameter:
}
}
$$ = &ast.Parameter{ast.Node{}, $1, variable, nil}
pos := position.NewTokenPosition($4)
if $1 != nil {
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
pos = position.NewNodeTokenPosition($1, $4)
} else if $2 != nil {
$$.GetNode().Position = position.NewTokensPosition($2, $4)
pos = position.NewTokensPosition($2, $4)
} else if $3 != nil {
$$.GetNode().Position = position.NewTokensPosition($3, $4)
} else {
$$.GetNode().Position = position.NewTokenPosition($4)
pos = position.NewTokensPosition($3, $4)
}
$$ = &ast.Parameter{
Node: ast.Node{
Position: pos,
},
Type: $1,
Var: variable,
}
}
| optional_class_type is_reference is_variadic T_VARIABLE '=' static_scalar
| optional_class_type is_reference is_variadic T_VARIABLE '=' expr
{
identifier := &ast.Identifier{
Node: ast.Node{
@ -2108,16 +2113,23 @@ parameter:
}
}
$$ = &ast.Parameter{ast.Node{}, $1, variable, $6}
pos := position.NewTokenNodePosition($4, $6)
if $1 != nil {
$$.GetNode().Position = position.NewNodesPosition($1, $6)
pos = position.NewNodesPosition($1, $6)
} else if $2 != nil {
$$.GetNode().Position = position.NewTokenNodePosition($2, $6)
pos = position.NewTokenNodePosition($2, $6)
} else if $3 != nil {
$$.GetNode().Position = position.NewTokenNodePosition($3, $6)
} else {
$$.GetNode().Position = position.NewTokenNodePosition($4, $6)
pos = position.NewTokenNodePosition($3, $6)
}
$$ = &ast.Parameter{
Node: ast.Node{
Position: pos,
},
Type: $1,
Var: variable,
EqualTkn: $5,
DefaultValue: $6,
}
}
;

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -1884,16 +1884,21 @@ parameter:
}
}
$$ = &ast.Parameter{ast.Node{}, $1, variable, nil}
pos := position.NewTokenPosition($4)
if $1 != nil {
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
pos = position.NewNodeTokenPosition($1, $4)
} else if $2 != nil {
$$.GetNode().Position = position.NewTokensPosition($2, $4)
pos = position.NewTokensPosition($2, $4)
} else if $3 != nil {
$$.GetNode().Position = position.NewTokensPosition($3, $4)
} else {
$$.GetNode().Position = position.NewTokenPosition($4)
pos = position.NewTokensPosition($3, $4)
}
$$ = &ast.Parameter{
Node: ast.Node{
Position: pos,
},
Type: $1,
Var: variable,
}
}
| optional_type is_reference is_variadic T_VARIABLE '=' expr
@ -1932,16 +1937,23 @@ parameter:
}
}
$$ = &ast.Parameter{ast.Node{}, $1, variable, $6}
pos := position.NewTokenNodePosition($4, $6)
if $1 != nil {
$$.GetNode().Position = position.NewNodesPosition($1, $6)
pos = position.NewNodesPosition($1, $6)
} else if $2 != nil {
$$.GetNode().Position = position.NewTokenNodePosition($2, $6)
pos = position.NewTokenNodePosition($2, $6)
} else if $3 != nil {
$$.GetNode().Position = position.NewTokenNodePosition($3, $6)
} else {
$$.GetNode().Position = position.NewTokenNodePosition($4, $6)
pos = position.NewTokenNodePosition($3, $6)
}
$$ = &ast.Parameter{
Node: ast.Node{
Position: pos,
},
Type: $1,
Var: variable,
EqualTkn: $5,
DefaultValue: $6,
}
}
;

View File

@ -68,6 +68,7 @@ type Parameter struct {
Node
Type Vertex
Var Vertex
EqualTkn *token.Token
DefaultValue Vertex
}