aboutsummaryrefslogtreecommitdiff
path: root/run.icl
diff options
context:
space:
mode:
Diffstat (limited to 'run.icl')
-rw-r--r--run.icl17
1 files changed, 15 insertions, 2 deletions
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"]