doc: support transformations on AltFor/Foreach/Switch/While

This commit is contained in:
mappu 2020-04-15 19:14:06 +12:00
parent 4d333fc297
commit 02cbd3997a

View File

@ -35,6 +35,34 @@ func normaliseAltCb(n_ *node.Node) error {
*n_ = elifStmt
case *stmt.AltFor:
forStmt := stmt.NewFor(n.Init, n.Cond, n.Loop, n.Stmt)
forStmt.FreeFloating = n.FreeFloating
forStmt.Position = n.Position
*n_ = forStmt
case *stmt.AltForeach:
feStmt := stmt.NewForeach(n.Expr, n.Key, n.Variable, n.Stmt)
feStmt.FreeFloating = n.FreeFloating
feStmt.Position = n.Position
*n_ = feStmt
case *stmt.AltSwitch:
swStmt := stmt.NewSwitch(n.Cond, n.CaseList)
swStmt.FreeFloating = n.FreeFloating
swStmt.Position = n.Position
*n_ = swStmt
case *stmt.AltWhile:
wStmt := stmt.NewWhile(n.Cond, n.Stmt)
wStmt.FreeFloating = n.FreeFloating
wStmt.Position = n.Position
*n_ = wStmt
default:
// no change
}