X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.dcl;h=f853c651649678d14f91c491d56593f68fa4f046;hb=ff7049a99f7fdd701d49222019df65a9aee8f05a;hp=17034beb04f6e8e0d1f78cf4776b65cddb0d694c;hpb=1d6cedaf81bbbe0ae869f20c9003bf018fb027ff;p=mTask.git diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 17034be..f853c65 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -34,7 +34,8 @@ decode :: String -> MTaskMSGRecv :: BC = BCNop | BCLab Int - | BCPush [Char] +// | E.e: BCPush e & toByteCode e + | BCPush String | BCPop //SDS functions | BCSdsStore Int @@ -61,8 +62,8 @@ decode :: String -> MTaskMSGRecv | BCJmpT Int | BCJmpF Int //UserLED - | BCLedOn [Char] - | BCLedOff [Char] + | BCLedOn UserLED + | BCLedOff UserLED //Serial | BCSerialAvail | BCSerialPrint @@ -76,6 +77,9 @@ decode :: String -> MTaskMSGRecv | BCDigitalWrite Pin | BCTest AnalogPin +derive gPrint BC +derive class gCons BC + :: ByteCode a p = BC (BCState -> ([BC], BCState)) instance Semigroup (ByteCode a p) instance Monoid (ByteCode a p) @@ -83,7 +87,7 @@ instance Monoid (ByteCode a p) :: BCShare = { sdsi :: Int, sdspub :: Bool, - sdsval :: [Char] + sdsval :: String } :: BCState = { @@ -93,15 +97,14 @@ instance Monoid (ByteCode a p) } instance zero BCState -class toByteCode a :: a -> [Char] -instance toByteCode Int -instance toByteCode Bool -instance toByteCode Char -instance toByteCode String -instance toByteCode Long -instance toByteCode Button -instance toByteCode UserLED -//instance toByteCode MTaskInterval +class toByteCode a :: a -> String +class fromByteCode a :: String -> a +class mTaskType a | toByteCode, fromByteCode, zero a + +instance toByteCode Int, Bool, Char, Long, String, Button, UserLED +instance fromByteCode Int, Bool, Char, Long, String, Button, UserLED +instance toByteCode MTaskInterval +instance fromByteCode MTaskInterval instance toChar Pin instance arith ByteCode @@ -109,9 +112,9 @@ instance boolExpr ByteCode instance analogIO ByteCode instance digitalIO ByteCode instance userLed ByteCode -//instance If ByteCode Stmt Stmt Stmt -//instance If ByteCode e Stmt Stmt -//instance If ByteCode Stmt e Stmt +instance If ByteCode Stmt Stmt Stmt +instance If ByteCode e Stmt Stmt +instance If ByteCode Stmt e Stmt instance If ByteCode x y Stmt instance IF ByteCode instance noOp ByteCode @@ -124,6 +127,6 @@ instance serial ByteCode toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState) toSDSUpdate :: Int Int -> [MTaskMSGSend] -toByteVal :: BC -> [Char] +toByteVal :: BC -> String toReadableByteCode :: (ByteCode a b) -> (String, BCState) toRealByteCode :: (ByteCode a b) BCState -> (String, BCState)