import Data.Tuple
import StdList
from Data.Func import $
-from Text import class Text(join,toUpperCase), instance Text String
+from Text import class Text(concat,join,toUpperCase), instance Text String
toByteVal :: BC -> String
-toByteVal a = undef
+toByteVal a = toString $ toChar $ consIndex{|*|} a
derive gPrint BC, AnalogPin
derive consIndex BC
instance zero BCState where
zero = {a=()}
+toRealByteCode :: (ByteCode a Expr) -> String
+toRealByteCode (BC x) = concat $ map toByteVal x
+
//Start :: ByteCode Int Expr
//Start = (lit 36 +. lit 42) +. lit 84
//Run test programma en pretty print
-Start :: ByteCode Int Expr
-Start = If (lit True) (analogRead A1) (analogRead A0)
+Start = toRealByteCode $ If (lit True) (analogRead A1) (analogRead A0)
+//Start :: ByteCode Int Expr
+//Start = If (lit True) (analogRead A1) (analogRead A0)
//Start = If ((lit 36) ==. (lit 42)) (noOp) (noOp)
-
-//Generate header file
-//Start w
-//# (io, w) = stdio w
-//# io = io <<< "#ifndef MTASK_H\n#define MTASK_H\n"
-//# io = io <<< join "\n" ["#define " <+ toUpperCase (consName{|*|} x) <+ " " <+ consIndex{|*|} x\\x<-allBC]
-// with
-// allBC :: [BC]
-// allBC = conses{|*|}
-//# (ok, w) = fclose (io <<< "\n#endif\n") w
-//| not ok = abort "Couldn't close stdio"
-//= w