From 2788df88e6261ac641adf9f39bbfe517a7d77d9c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 19 Jul 2017 12:25:45 +0000 Subject: Add else if --- Sil/Util/Printer.icl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Sil/Util/Printer.icl') diff --git a/Sil/Util/Printer.icl b/Sil/Util/Printer.icl index 2252ee4..af3d072 100644 --- a/Sil/Util/Printer.icl +++ b/Sil/Util/Printer.icl @@ -91,12 +91,13 @@ where instance PrettyPrinter Statement where - print st (If c t Nothing) = st <+ "if (" <+ c <+ ") {\r\n" <+ - print (incIndent st) t <+ "\r\n" <+ st <+ "}" - print st (If c t (Just e)) = st <+ "if (" <+ c <+ ") {\r\n" <+ - print st` t <+ "\r\n" <+ st <+ "} else {\r\n" <+ - print st` e <+ "\r\n" <+ st <+ "}" - where st` = incIndent st + print st (If bs else) = st <+ printersperse " else " (map oneblock bs) <+ else` + where + st` = incIndent st + oneblock (c,b) = "if (" <+ c <+ ") {\r\n" <+ print st` b <+ "\r\n" <+ st <+ "}" + else` = case else of + Nothing -> "" + Just e -> " else {\r\n" <+ print st` e <+ "\r\n" <+ st <+ "}" print st stm = st <+ stm printersperse :: a [b] -> String | toString a & toString b -- cgit v1.2.3