create CaseList node

This commit is contained in:
z7zmey
2018-04-29 23:10:56 +03:00
parent f8d9d6d7c2
commit d1b0cebf9a
13 changed files with 1578 additions and 1349 deletions

View File

@@ -1428,7 +1428,7 @@ func (p *Printer) printStmtAltSwitch(n node.Node) {
p.Print(nn.Cond)
io.WriteString(p.w, ") :\n")
s := nn.Cases
s := nn.CaseList.Cases
p.printNodes(s)
io.WriteString(p.w, "\n")
@@ -2009,7 +2009,7 @@ func (p *Printer) printStmtSwitch(n node.Node) {
io.WriteString(p.w, ")")
io.WriteString(p.w, " {\n")
p.printNodes(nn.Cases)
p.printNodes(nn.CaseList.Cases)
io.WriteString(p.w, "\n")
p.printIndent()
io.WriteString(p.w, "}")

View File

@@ -2284,17 +2284,19 @@ func TestPrintStmtAltSwitch(t *testing.T) {
Stmts: []node.Node{
&stmt.AltSwitch{
Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.String{Value: "'a'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
CaseList: &stmt.CaseList{
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.String{Value: "'a'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
},
},
},
&stmt.Case{
Cond: &scalar.String{Value: "'b'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
&stmt.Case{
Cond: &scalar.String{Value: "'b'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
},
},
},
@@ -3649,17 +3651,19 @@ func TestPrintStmtSwitch(t *testing.T) {
Stmts: []node.Node{
&stmt.Switch{
Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.String{Value: "'a'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
CaseList: &stmt.CaseList{
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.String{Value: "'a'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
},
},
},
&stmt.Case{
Cond: &scalar.String{Value: "'b'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
&stmt.Case{
Cond: &scalar.String{Value: "'b'"},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
},
},
},