equal
deleted
inserted
replaced
|
1 def simp(r: Rexp): (Rexp, Val => Val) = r match { |
|
2 case SEQ(r1, r2) => { |
|
3 val (r1s, f1s) = simp(r1) |
|
4 val (r2s, f2s) = simp(r2) |
|
5 (r1s, r2s) match { |
|
6 case (NULL, _) => (NULL, F_ERROR) |
|
7 case (_, NULL) => (NULL, F_ERROR) |
|
8 case (EMPTY, _) => (r2s, F_SEQ_Void1(f1s, f2s)) |
|
9 case (_, EMPTY) => (r1s, F_SEQ_Void2(f1s, f2s)) |
|
10 case _ => (SEQ(r1s,r2s), F_SEQ(f1s, f2s)) |
|
11 } |
|
12 } |
|
13 ... |
|
14 |
|
15 def F_SEQ_Void1(f1: Val => Val, f2: Val => Val) = |
|
16 (v:Val) => Sequ(f1(Void), f2(v)) |
|
17 def F_SEQ_Void2(f1: Val => Val, f2: Val => Val) = |
|
18 (v:Val) => Sequ(f1(v), f2(Void)) |
|
19 def F_SEQ(f1: Val => Val, f2: Val => Val) = |
|
20 (v:Val) => v match { |
|
21 case Sequ(v1, v2) => Sequ(f1(v1), f2(v2)) } |