progs/comb2.scala
changeset 607 3f4fc76dab2f
parent 531 f6e937ed0332
child 624 8d0af38389bc
equal deleted inserted replaced
606:a50feaa0c4b3 607:3f4fc76dab2f
   128 lazy val Block: Parser[String, Block] =
   128 lazy val Block: Parser[String, Block] =
   129   (("{" ~ Stmts ~ "}") ==> { case ((x, y), z) => y} || 
   129   (("{" ~ Stmts ~ "}") ==> { case ((x, y), z) => y} || 
   130    (Stmt ==> ((s) => List(s))))
   130    (Stmt ==> ((s) => List(s))))
   131 
   131 
   132 
   132 
   133 Stmt.parse_all("x2:=5+3")
   133 Stmts.parse_all("x2:=5+3;")
   134 Block.parse_all("{x:=5;y:=8}")
   134 Block.parse_all("{x:=5;y:=8}")
   135 Block.parse_all("if(false)then{x:=5}else{x:=10}")
   135 Block.parse_all("if(false)then{x:=5}else{x:=10}")
   136 
   136 
   137 val fib = """{n:=10;minus1:=0;minus2:=1;temp:=0;while(n>0)do{temp:=minus2;minus2:=minus1+minus2;minus1:=temp;n:=n-1};result:=minus2}"""
   137 val fib = """{n:=10;minus1:=0;minus2:=1;temp:=0;while(n>0)do{temp:=minus2;minus2:=minus1+minus2;minus1:=temp;n:=n-1};result:=minus2}"""
   138 
   138