[refactoring] update ast structure of "While" node

This commit is contained in:
Vadym Slizov
2020-09-04 10:33:47 +03:00
parent 6976388a82
commit 3b85f5e82b
21 changed files with 1066 additions and 1162 deletions

View File

@@ -270,12 +270,6 @@ func (v *Dump) StmtAltSwitch(n *ast.StmtAltSwitch) {
v.printNode(n.GetNode())
}
func (v *Dump) StmtAltWhile(n *ast.StmtAltWhile) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtAltWhile{\n")
v.printNode(n.GetNode())
}
func (v *Dump) StmtBreak(n *ast.StmtBreak) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtBreak{\n")
@@ -637,6 +631,11 @@ func (v *Dump) StmtWhile(n *ast.StmtWhile) {
v.printIndentIfNotSingle(v.indent - 1)
v.print("&ast.StmtWhile{\n")
v.printNode(n.GetNode())
if n.Alt {
v.printIndent(v.indent)
v.print("Alt: true,\n")
}
}
func (v *Dump) ExprArray(n *ast.ExprArray) {

View File

@@ -13,26 +13,6 @@ func (v *FilterParserNodes) EnterNode(n ast.Vertex) bool {
return true
}
func (v *FilterParserNodes) StmtWhile(n *ast.StmtWhile) {
for {
if nn, ok := n.Cond.(*ast.ParserBrackets); ok {
n.Cond = nn.Child
} else {
break
}
}
}
func (v *FilterParserNodes) StmtAltWhile(n *ast.StmtAltWhile) {
for {
if nn, ok := n.Cond.(*ast.ParserBrackets); ok {
n.Cond = nn.Child
} else {
break
}
}
}
func (v *FilterParserNodes) StmtDo(n *ast.StmtDo) {
for {
if nn, ok := n.Cond.(*ast.ParserBrackets); ok {

View File

@@ -113,3 +113,12 @@ func (v *FilterTokens) ParserBrackets(n *ast.ParserBrackets) {
n.OpenBracketTkn = nil
n.CloseBracketTkn = nil
}
func (v *FilterTokens) StmtWhile(n *ast.StmtWhile) {
n.WhileTkn = nil
n.OpenParenthesisTkn = nil
n.CloseParenthesisTkn = nil
n.ColonTkn = nil
n.EndWhileTkn = nil
n.SemiColonTkn = nil
}

View File

@@ -66,10 +66,6 @@ func (v *Null) StmtAltSwitch(_ *ast.StmtAltSwitch) {
// do nothing
}
func (v *Null) StmtAltWhile(_ *ast.StmtAltWhile) {
// do nothing
}
func (v *Null) StmtBreak(_ *ast.StmtBreak) {
// do nothing
}