[refactoring] update ast structure of "Nullable"

This commit is contained in:
Vadym Slizov 2020-11-20 22:07:58 +02:00
parent bf3ae74d56
commit 43ace92875
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
4 changed files with 1029 additions and 1028 deletions

14
internal/php7/php7.go generated
View File

@ -4343,13 +4343,13 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php7/php7.y:1950
{
yyVAL.node = &ast.Nullable{ast.Node{}, yyDollar[2].node}
// save position
yyVAL.node.GetNode().Position = position.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)
// save comments
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Start, yyDollar[1].token.SkippedTokens)
yyVAL.node = &ast.Nullable{
Node: ast.Node{
Position: position.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node),
},
QuestionTkn: yyDollar[1].token,
Expr: yyDollar[2].node,
}
}
case 223:
yyDollar = yyS[yypt-1 : yypt+1]

View File

@ -1948,13 +1948,13 @@ type_expr:
}
| '?' type
{
$$ = &ast.Nullable{ast.Node{}, $2}
// save position
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
$$ = &ast.Nullable{
Node: ast.Node{
Position: position.NewTokenNodePosition($1, $2),
},
QuestionTkn: $1,
Expr: $2,
}
}
;

View File

@ -33,6 +33,7 @@ func (n *Root) Accept(v NodeVisitor) {
// Nullable node
type Nullable struct {
Node
QuestionTkn *token.Token
Expr Vertex
}