From ba10d1b5ec24a33059030c16f82558fe45e165d2 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 26 May 2016 17:23:16 +0200 Subject: Overloading IO functions in step; POC derivation tree generation --- run.icl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'run.icl') diff --git a/run.icl b/run.icl index fd90027..64ef079 100644 --- a/run.icl +++ b/run.icl @@ -45,10 +45,12 @@ where loop :: Bool ![Stm] !Program !State !*File -> *File loop v brk p st f # p = if v (trace (foldl (+++) "" (map toString p) +++ "\n") p) p - # (mbProgSt, f) = step p st f + # (mbProgSt, f) = step p st f iofunc | isNothing mbProgSt = f <<< "NOTHING!!!\n" # (prog, st) = fromJust mbProgSt - | isEmpty prog = f <<< "\n---------------------------\n" <<< toString st + | isEmpty prog + | v = f <<< "\n---------------------------\n" <<< toString st + = f | not (isBrk prog) = loop v brk prog st f # f = f <<< "---> " <<< toString (hd prog) <<< " ? " # (cmd, f) = freadline f @@ -62,6 +64,17 @@ where isBrk [(Push _):_] = isMember (Push "") brk isBrk [stm:_] = isMember stm brk + iofunc :: *IO *File + iofunc = IO read show + where + read :: *File -> *(String, *File) + read f + # (s, f) = freadline f + = (s % (0, size s - 2), f) + + show :: String *File -> *File + show s f = f <<< s + options = [ Option ['i'] ["infile"] (ReqArg IFile "FILE") "Smurf file" , Option ['b'] ["break"] -- cgit v1.2.3