[refactoring] update ast structure of "PostDec", "PostInc", "PreDec", "PreInc" and "New" nodes

This commit is contained in:
Vadym Slizov
2020-12-03 22:04:59 +02:00
parent b1e9f5e167
commit 45e959056b
8 changed files with 1039 additions and 972 deletions

View File

@@ -1230,8 +1230,11 @@ func (n *ExprMethodCall) Accept(v NodeVisitor) {
// ExprNew node
type ExprNew struct {
Node
Class Vertex
ArgumentList *ArgumentList
NewTkn *token.Token
Class Vertex
OpenParenthesisTkn *token.Token
Arguments []Vertex
CloseParenthesisTkn *token.Token
}
func (n *ExprNew) Accept(v NodeVisitor) {
@@ -1241,7 +1244,8 @@ func (n *ExprNew) Accept(v NodeVisitor) {
// ExprPostDec node
type ExprPostDec struct {
Node
Var Vertex
Var Vertex
DecTkn *token.Token
}
func (n *ExprPostDec) Accept(v NodeVisitor) {
@@ -1251,7 +1255,8 @@ func (n *ExprPostDec) Accept(v NodeVisitor) {
// ExprPostInc node
type ExprPostInc struct {
Node
Var Vertex
Var Vertex
IncTkn *token.Token
}
func (n *ExprPostInc) Accept(v NodeVisitor) {
@@ -1261,7 +1266,8 @@ func (n *ExprPostInc) Accept(v NodeVisitor) {
// ExprPreDec node
type ExprPreDec struct {
Node
Var Vertex
DecTkn *token.Token
Var Vertex
}
func (n *ExprPreDec) Accept(v NodeVisitor) {
@@ -1271,7 +1277,8 @@ func (n *ExprPreDec) Accept(v NodeVisitor) {
// ExprPreInc node
type ExprPreInc struct {
Node
Var Vertex
IncTkn *token.Token
Var Vertex
}
func (n *ExprPreInc) Accept(v NodeVisitor) {

View File

@@ -1415,10 +1415,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
t.Traverse(nn.Class)
t.visitor.Leave("Class", true)
}
if nn.ArgumentList != nil {
t.visitor.Enter("ArgumentList", true)
t.Traverse(nn.ArgumentList)
t.visitor.Leave("ArgumentList", true)
if nn.Arguments != nil {
t.visitor.Enter("Arguments", false)
for _, c := range nn.Arguments {
t.Traverse(c)
}
t.visitor.Leave("Arguments", false)
}
case *ast.ExprPostDec:
if nn == nil {