while.scala
changeset 71 7717f20f0504
parent 70 e6868bd2942b
child 72 d65525aeca08
--- a/while.scala	Wed Nov 21 09:04:11 2012 +0000
+++ b/while.scala	Fri Nov 23 14:08:31 2012 +0000
@@ -105,8 +105,9 @@
   (T_KWD("skip") ==> ((_) => Skip: Stmt)) ||
   (IdParser ~ T_OP(":=") ~ AExp) ==> { case ((x, y), z) => Assign(x, z): Stmt } ||
   (T_KWD("if") ~ BExp ~ T_KWD("then") ~ Block ~ T_KWD("else") ~ Block) ==>
-    { case (((((x,y),z),u),v),w) => If(y, u, w): Stmt }
-
+    { case (((((x,y),z),u),v),w) => If(y, u, w): Stmt } ||
+  (T_KWD("while") ~ BExp ~ T_KWD("do") ~ Block) ==> { case (((x, y), z), w) => While(y, w) } 
+ 
 lazy val Stmts: Parser[List[Token], Block] =
   (Stmt ~ T_SEMI ~ Stmts) ==> { case ((x, y), z) => x :: z : Block } ||
   (Stmt ==> ((s) => List(s) : Block))