From e452daceb395c4ea68bc67bd70f355f59867618b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 30 Mar 2016 13:18:02 +0200 Subject: Parentheses for Stm toString --- While.icl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'While.icl') diff --git a/While.icl b/While.icl index efa1c92..6d34a26 100644 --- a/While.icl +++ b/While.icl @@ -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} -- cgit v1.2.3