equal
deleted
inserted
replaced
8 // call with |
8 // call with |
9 // |
9 // |
10 // amm comb2.sc |
10 // amm comb2.sc |
11 |
11 |
12 |
12 |
13 |
|
14 |
|
15 // more convenience for the map parsers later on; |
13 // more convenience for the map parsers later on; |
16 // it allows writing nested patterns as |
14 // it allows writing nested patterns as |
17 // case x ~ y ~ z => ... |
15 // case x ~ y ~ z => ... |
18 |
16 |
19 case class ~[+A, +B](_1: A, _2: B) |
17 case class ~[+A, +B](x: A, y: B) |
20 |
|
21 |
18 |
22 // constraint for the input |
19 // constraint for the input |
23 type IsSeq[A] = A => Seq[_] |
20 type IsSeq[A] = A => Seq[_] |
24 |
21 |
25 |
22 |
170 ((p"{" ~ Stmts ~ p"}").map{ case _ ~ y ~ _ => y } || |
167 ((p"{" ~ Stmts ~ p"}").map{ case _ ~ y ~ _ => y } || |
171 (Stmt.map(s => List(s)))) |
168 (Stmt.map(s => List(s)))) |
172 |
169 |
173 |
170 |
174 // Examples |
171 // Examples |
175 Stmts.parse_all("x2:=5+3;") |
172 Stmt.parse_all("x2:=5+3") |
176 Block.parse_all("{x:=5;y:=8}") |
173 Block.parse_all("{x:=5;y:=8}") |
177 Block.parse_all("if(false)then{x:=5}else{x:=10}") |
174 Block.parse_all("if(false)then{x:=5}else{x:=10}") |
178 |
175 |
179 |
176 |
180 val fib = """n := 10; |
177 val fib = """n := 10; |