diff options
Diffstat (limited to 'assignment-13/uFPL/C.icl')
-rw-r--r-- | assignment-13/uFPL/C.icl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/assignment-13/uFPL/C.icl b/assignment-13/uFPL/C.icl index 763774c..87f8573 100644 --- a/assignment-13/uFPL/C.icl +++ b/assignment-13/uFPL/C.icl @@ -15,7 +15,7 @@ import Data.Tuple import uFPL.Arduino import uFPL.Util -(`seq`) infix 0 :: CBody CBody -> CBody +(`seq`) infixr 0 :: CBody CBody -> CBody (`seq`) CBEmpty cb = cb (`seq`) cb CBEmpty = cb (`seq`) a b = CBSeq a b @@ -68,10 +68,14 @@ instance print CBody where print (CBReturn Nothing) = print "return;" print (CBReturn (Just e)) = print "return " o print e o print ";" - print (CBIf c t e) = print "if (" o print c o print ") {" o indent o nl - o print t o unindent o nl - o print "} else {" o indent o nl - o print e o unindent o nl o print "}" + print (CBIf c t eifs e) = + prsperse "} else " [print "if (" o print c o print ") {" o indent o nl o print t o unindent o nl \\ (c,t) <- [(c,t):eifs]] + o case e of + Just e -> + print "} else {" o indent o nl + o print e o unindent o nl o print "}" + Nothing -> + print "}" print (CBWhile e b) = print "while (" o print e o print ") {" o nl o print b o nl o print "}" print (CBAssign v e) = print v o print " = " o print e o print ";" print (CBSeq a b) = print a o nl o print b |