aboutsummaryrefslogtreecommitdiff
path: root/Smurf.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Smurf.icl')
-rw-r--r--Smurf.icl11
1 files changed, 7 insertions, 4 deletions
diff --git a/Smurf.icl b/Smurf.icl
index 7223ce7..d4fbcb6 100644
--- a/Smurf.icl
+++ b/Smurf.icl
@@ -57,6 +57,9 @@ where
fromChar 'g' = Get
fromChar 'x' = Exec
+printList :: [a] -> String | toString a
+printList xs = "[" <+ concat (intersperse ":" (map (\s->'"' <+ s <+ '"') xs)) <+ "]"
+
instance zero State where zero = { stack = zero, store = zero }
instance zero ListIO where zero = {input=[], output=[]}
@@ -68,14 +71,14 @@ where
instance toString Transition
where
toString ((p1, ip1, st1) --> (ip2, op, st2))
- = "<" <+ simple 2 p1 <+ "," <+ st1 <+ "," <+ printToString ip1 <+ "> -> ("
- <+ printToString ip2 <+ "," <+ printToString op <+ "," <+ st2 <+ ")"
+ = "<" <+ simple 2 p1 <+ "," <+ st1 <+ "," <+ printList ip1 <+ "> -> ("
+ <+ printList ip2 <+ "," <+ printList op <+ "," <+ st2 <+ ")"
where
simple :: !Int !Program -> String
simple _ [] = "λ"
simple i pgm
- | i <= length pgm = concat $ intersperse ":" $ map toString pgm
- = concat $ intersperse ":" $ map toString (take i pgm)
+ | i >= length pgm = concat $ intersperse ":" $ map toString pgm
+ = simple i (take i pgm) +++ ":..."
instance toString DerivationTree
where