aboutsummaryrefslogtreecommitdiff
path: root/Sil/Util/Printer.icl
diff options
context:
space:
mode:
authorCamil Staps2017-07-29 00:17:28 +0200
committerCamil Staps2017-07-29 00:18:29 +0200
commitcda243a41b13626f72ceaaa99901c402b9797dc7 (patch)
tree88788ec4d6d7490e2b4aa9da5f3cba570ff18151 /Sil/Util/Printer.icl
parentFix lazy operators (diff)
Cleanup; add <> < > <= >=
Diffstat (limited to 'Sil/Util/Printer.icl')
-rw-r--r--Sil/Util/Printer.icl16
1 files changed, 10 insertions, 6 deletions
diff --git a/Sil/Util/Printer.icl b/Sil/Util/Printer.icl
index 55c2498..979e478 100644
--- a/Sil/Util/Printer.icl
+++ b/Sil/Util/Printer.icl
@@ -31,6 +31,8 @@ decIndent ps = {ps & indent=dec ps.indent}
instance toString PrintState where toString st = {'\t' \\ _ <- [1..st.indent]}
+instance PrettyPrinter String where print _ s = s
+
instance PrettyPrinter [Token]
where
print st [] = ""
@@ -68,12 +70,14 @@ where
instance PrettyPrinter Program
where
- print st prog = p st prog.p_globals <+ "\r\n" <+ p st prog.p_funs
- where
- p :: PrintState [a] -> String | PrettyPrinter a
- p _ [] = ""
- p st [f] = print st f
- p st [f:fs] = print st f <+ "\r\n\r\n" <+ p st fs
+ print st prog=:{p_globals=gs=:[_:_]}
+ = stprintersperse st "\r\n" gs <+ "\r\n\r\n" <+ print st {prog & p_globals=[]}
+ print st prog = stprintersperse st "\r\n\r\n" prog.p_funs
+
+stprintersperse :: PrintState a [b] -> String | PrettyPrinter a & PrettyPrinter b
+stprintersperse st _ [] = ""
+stprintersperse st _ [x] = print st x
+stprintersperse st g [x:xs] = print st x +++ print st g +++ stprintersperse st g xs
instance PrettyPrinter Function
where