equal
deleted
inserted
replaced
1 def simp(r: Rexp): (Rexp, Val => Val) = r match { |
1 def simp(r: Rexp): (Rexp, Val => Val) = r match { |
2 case ALT(r1, r2) => { |
2 case ALT(r1, r2) => { |
3 val (r1s, f1s) = simp(r1) |
3 val (r1s, f1s) = simp(r1) |
4 val (r2s, f2s) = simp(r2) |
4 val (r2s, f2s) = simp(r2) |
5 (r1s, r2s) match { |
5 (r1s, r2s) match { |
6 case (NULL, _) => (r2s, F_RIGHT(f2s)) |
6 case (ZERO, _) => (r2s, F_RIGHT(f2s)) |
7 case (_, NULL) => (r1s, F_LEFT(f1s)) |
7 case (_, ZERO) => (r1s, F_LEFT(f1s)) |
8 case _ => |
8 case _ => |
9 if (r1s == r2s) (r1s, F_LEFT(f1s)) |
9 if (r1s == r2s) (r1s, F_LEFT(f1s)) |
10 else (ALT (r1s, r2s), F_ALT(f1s, f2s)) |
10 else (ALT (r1s, r2s), F_ALT(f1s, f2s)) |
11 } |
11 } |
12 } |
12 } |