progs/parser-combinators/comb2.sc
changeset 955 ca67172b8fa1
parent 954 4a7ed272d46e
child 964 d3e22099963d
equal deleted inserted replaced
954:4a7ed272d46e 955:ca67172b8fa1
   166   ((p"{" ~ Stmts ~ p"}").map{ case _ ~ y ~ _ => y } || 
   166   ((p"{" ~ Stmts ~ p"}").map{ case _ ~ y ~ _ => y } || 
   167    (Stmt.map(s => List(s))))
   167    (Stmt.map(s => List(s))))
   168 
   168 
   169 
   169 
   170 // Examples
   170 // Examples
       
   171 println(AExp.parse_all("2*2*2"))
   171 println(BExp.parse_all("5+3"))
   172 println(BExp.parse_all("5+3"))
   172 println(Stmt.parse_all("5==3"))
   173 println(Stmt.parse_all("5==3"))
   173 println(Stmt.parse_all("x2:=5+3"))
   174 println(Stmt.parse_all("x2:=5+3"))
   174 println(Block.parse_all("{x:=5;y:=8}"))
   175 println(Block.parse_all("{x:=5;y:=8}"))
   175 println(Block.parse_all("if(false)then{x:=5}else{x:=10}"))
   176 println(Block.parse_all("if(false)then{x:=5}else{x:=10}"))