[refactoring] update ast structure of "Goto" and "Label" nodes

This commit is contained in:
Vadym Slizov
2020-09-17 16:49:54 +03:00
parent 48aaa7cc47
commit 94aa9cf829
7 changed files with 904 additions and 879 deletions

976
internal/php5/php5.go generated

File diff suppressed because it is too large Load Diff

View File

@@ -829,15 +829,19 @@ statement:
| T_STRING ':'
{
label := &ast.Identifier{ast.Node{}, $1.Value}
$$ = &ast.StmtLabel{ast.Node{}, label}
$$ = &ast.StmtLabel{
Node: ast.Node{
Position: position.NewTokensPosition($1, $2),
},
LabelName: label,
ColonTkn: $2,
}
// save position
label.GetNode().Position = position.NewTokenPosition($1)
$$.GetNode().Position = position.NewTokensPosition($1, $2)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.Label, $2.SkippedTokens)
yylex.(*Parser).setFreeFloating(label, token.Start, $1.SkippedTokens)
}
;
@@ -1179,17 +1183,21 @@ unticked_statement:
| T_GOTO T_STRING ';'
{
label := &ast.Identifier{ast.Node{}, $2.Value}
$$ = &ast.StmtGoto{ast.Node{}, label}
$$ = &ast.StmtGoto{
Node: ast.Node{
Position: position.NewTokensPosition($1, $3),
},
GotoTkn: $1,
Label: label,
SemiColonTkn: $3,
}
// save position
label.GetNode().Position = position.NewTokenPosition($2)
$$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloating(label, token.Start, $2.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.Label, $3.SkippedTokens)
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
}
;