diff options
author | Camil Staps | 2017-07-19 12:25:45 +0000 |
---|---|---|
committer | Camil Staps | 2017-07-19 12:25:45 +0000 |
commit | 2788df88e6261ac641adf9f39bbfe517a7d77d9c (patch) | |
tree | 49ee4f4932dccf4b06782bd4879898dfa6fdfe4e /Sil/Util/Printer.icl | |
parent | Add readme and license (diff) |
Add else if
Diffstat (limited to 'Sil/Util/Printer.icl')
-rw-r--r-- | Sil/Util/Printer.icl | 13 |
1 files changed, 7 insertions, 6 deletions
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 |