diff options
-rw-r--r-- | While.icl | 9 | ||||
-rw-r--r-- | test.icl | 1 |
2 files changed, 8 insertions, 2 deletions
@@ -107,8 +107,13 @@ where toString Skip = "skip" toString (s1 :. s2) = s1 <+ "; " <+ s2 toString (v := a) = v <+ ":=" <+ a - toString (If b s1 s2) = "if " <+ b <+ " then " <+ s1 <+ " else " <+ s2 - toString (While b s) = "while " <+ b <+ " do " <+ s <+ " done" + toString (While b s) = "while " <+ b <+ " do " <+ parens s + toString (If b s1 s2) + = "if " <+ b <+ " then " <+ parens s1 <+ " else " <+ parens s2 + +parens :: Stm -> String +parens (s1 :. s2) = "(" <+ s1 <+ "; " <+ s2 <+ ")" +parens stm = toString stm instance toString Var where toString (Var v) = {v} @@ -25,6 +25,7 @@ Start :: Int // Value of z after execution of sqrt in st Start = eval NS sqrt st z //Start = toString (seq sqrt st) // Derivation sequence of sqrt in st //Start = toString (tree sqrt st) // Derivation tree of sqrt in st +//Start = toString sqrt // The statement itself where st :: Char -> Int st 'x' = 9 |