diff options
author | Camil Staps | 2016-03-30 13:18:02 +0200 |
---|---|---|
committer | Camil Staps | 2016-03-30 13:18:02 +0200 |
commit | e452daceb395c4ea68bc67bd70f355f59867618b (patch) | |
tree | bf235fd22db5d4880685e83fc18dc6e6332f56e0 | |
parent | Overloaded state, more boolean ops, unaliased Var (diff) |
Parentheses for Stm toString
-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 |