author | Christian Urban <urbanc@in.tum.de> |
Thu, 01 Nov 2012 10:04:30 +0000 | |
changeset 55 | cceed8d66b28 |
parent 7 | 73cf4406b773 |
permissions | -rw-r--r-- |
7 | 1 |
def deriv (r: Rexp, c: Char) : Rexp = r match { |
2 |
case NULL => NULL |
|
3 |
case EMPTY => NULL |
|
4 |
case CHAR(d) => if (c == d) EMPTY else NULL |
|
5 |
case ALT(r1, r2) => ALT(deriv(r1, c), deriv(r2, c)) |
|
6 |
case SEQ(r1, r2) => |
|
7 |
if (nullable(r1)) ALT(SEQ(deriv(r1, c), r2), deriv(r2, c)) |
|
8 |
else SEQ(deriv(r1, c), r2) |
|
9 |
case STAR(r) => SEQ(deriv(r, c), STAR(r)) |
|
10 |
} |
|
11 |