php2go/normalisealts.go

42 lines
811 B
Go

package main
import (
//"fmt"
//"io/ioutil"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
//"github.com/z7zmey/php-parser/walker"
)
func normaliseAltCb(n_ *node.Node) {
switch n := (*n_).(type) {
case *stmt.AltIf:
// Build replacement node
ifStmt := stmt.NewIf(n.Cond, n.Stmt, n.ElseIf, n.Else)
ifStmt.FreeFloating = n.FreeFloating
ifStmt.Position = n.Position
// ifStmt has no .Attributes prop
*n_ = ifStmt
case *stmt.AltElse:
elseStmt := stmt.NewElse(n.Stmt)
elseStmt.FreeFloating = n.FreeFloating
elseStmt.Position = n.Position
*n_ = elseStmt
case *stmt.AltElseIf:
elifStmt := stmt.NewElseIf(n.Cond, n.Stmt)
elifStmt.FreeFloating = n.FreeFloating
elifStmt.Position = n.Position
*n_ = elifStmt
default:
return // no change
}
}