From 02cbd3997ad9a6119c2de913fd7182b7e065b880 Mon Sep 17 00:00:00 2001 From: mappu Date: Wed, 15 Apr 2020 19:14:06 +1200 Subject: [PATCH] doc: support transformations on AltFor/Foreach/Switch/While --- normalisealts.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/normalisealts.go b/normalisealts.go index d31533c..2c2dbf6 100644 --- a/normalisealts.go +++ b/normalisealts.go @@ -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 }