author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Thu, 14 Nov 2013 20:08:39 +0000 | |
changeset 190 | 0b63c0edfb09 |
parent 117 | 25999de692b2 |
child 262 | ee4304bc6350 |
permissions | -rw-r--r-- |
def der (r: Rexp, c: Char) : Rexp = r match { case NULL => NULL case EMPTY => NULL case CHAR(d) => if (c == d) EMPTY else NULL case ALT(r1, r2) => ALT(der(r1, c), der(r2, c)) case SEQ(r1, r2) => if (nullable(r1)) ALT(SEQ(der(r1, c), r2), der(r2, c)) else SEQ(der(r1, c), r2) case STAR(r) => SEQ(der(r, c), STAR(r)) } def ders (s: List[Char], r: Rexp) : Rexp = s match { case Nil => r case c::s => ders(s, der(c, r)) }