[refactoring] update ast structure of "Nop" node
This commit is contained in:
parent
e78f0dc650
commit
33af1df9c4
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -1141,14 +1141,12 @@ unticked_statement:
|
||||
}
|
||||
| ';'
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| T_TRY '{' inner_statement_list '}' catch_statement finally_statement
|
||||
{
|
||||
@ -2420,13 +2418,12 @@ trait_list:
|
||||
trait_adaptations:
|
||||
';'
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| '{' trait_adaptation_list '}'
|
||||
{
|
||||
@ -2587,14 +2584,12 @@ trait_modifiers:
|
||||
method_body:
|
||||
';' /* abstract method */
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| '{' inner_statement_list '}'
|
||||
{
|
||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -1051,14 +1051,12 @@ statement:
|
||||
}
|
||||
| ';'
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| T_TRY '{' inner_statement_list '}' catch_list finally_statement
|
||||
{
|
||||
@ -2203,13 +2201,12 @@ name_list:
|
||||
trait_adaptations:
|
||||
';'
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| '{' '}'
|
||||
{
|
||||
@ -2372,14 +2369,12 @@ absolute_trait_method_reference:
|
||||
method_body:
|
||||
';' /* abstract method */
|
||||
{
|
||||
$$ = &ast.StmtNop{ast.Node{}, }
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $1.SkippedTokens)
|
||||
$$ = &ast.StmtNop{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenPosition($1),
|
||||
},
|
||||
SemiColonTkn: $1,
|
||||
}
|
||||
}
|
||||
| '{' inner_statement_list '}'
|
||||
{
|
||||
|
@ -597,6 +597,7 @@ func (n *StmtNamespace) Accept(v NodeVisitor) {
|
||||
// StmtNop node
|
||||
type StmtNop struct {
|
||||
Node
|
||||
SemiColonTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *StmtNop) Accept(v NodeVisitor) {
|
||||
|
@ -235,3 +235,7 @@ func (v *FilterTokens) StmtDeclare(n *ast.StmtDeclare) {
|
||||
n.EndDeclareTkn = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) StmtNop(n *ast.StmtNop) {
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
@ -2581,13 +2581,8 @@ func (p *Printer) printStmtNamespace(n *ast.StmtNamespace) {
|
||||
p.printToken(n.SemiColonTkn, ";")
|
||||
}
|
||||
|
||||
func (p *Printer) printStmtNop(n ast.Vertex) {
|
||||
p.printFreeFloatingOrDefault(n, token.Start, p.bufStart)
|
||||
p.printFreeFloating(n, token.SemiColon)
|
||||
if n.GetNode().Tokens.IsEmpty() {
|
||||
p.write([]byte(";"))
|
||||
}
|
||||
p.printFreeFloating(n, token.End)
|
||||
func (p *Printer) printStmtNop(n *ast.StmtNop) {
|
||||
p.printToken(n.SemiColonTkn, ";")
|
||||
}
|
||||
|
||||
func (p *Printer) printStmtPropertyList(n ast.Vertex) {
|
||||
|
Loading…
Reference in New Issue
Block a user