--- a/progs/comb2.scala Wed Nov 01 11:44:23 2017 +0000
+++ b/progs/comb2.scala Wed Nov 08 12:54:39 2017 +0000
@@ -64,30 +64,6 @@
new SeqParser[String, String, String](s, r)
}
-lazy val E: Parser[String, Int] =
- (T ~ "+" ~ E) ==> { case ((x, y), z) => x + z} || T
-lazy val T: Parser[String, Int] =
- (F ~ "*" ~ T) ==> { case ((x, y), z) => x * z} || F
-lazy val F: Parser[String, Int] =
- ("(" ~ E ~ ")") ==> { case ((x, y), z) => y} || NumParser
-
-println(E.parse_all("123"))
-println(E.parse_all("1*2+3"))
-println(E.parse_all("1+2*3"))
-println(E.parse_all("1+2+3"))
-println(E.parse_all("1+2+3"))
-println(E.parse_all("1+2*3+1"))
-
-
-// no left-recursion allowed
-lazy val EL: Parser[String, Int] =
- ((EL ~ "+" ~ EL) ==> { case ((x, y), z) => x + z} ||
- (EL ~ "*" ~ EL) ==> { case ((x, y), z) => x * z} ||
- ("(" ~ EL ~ ")") ==> { case ((x, y), z) => y} ||
- NumParser)
-
-//println(E.parse_all("1+2+3"))
-
// the abstract syntax trees for the WHILE language
abstract class Stmt
@@ -154,7 +130,7 @@
(Stmt ==> ((s) => List(s))))
-Stmt.parse_all("x2:=5")
+Stmt.parse_all("x2:=5+3")
Block.parse_all("{x:=5;y:=8}")
Block.parse_all("if(false)then{x:=5}else{x:=10}")