progs/re2.scala
changeset 453 36e5752fa191
parent 441 028816884f70
child 454 edb4ad356c56
equal deleted inserted replaced
452:b93f4d2aeee1 453:36e5752fa191
    27   case SEQ(r1, r2) => 
    27   case SEQ(r1, r2) => 
    28     if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
    28     if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
    29     else SEQ(der(c, r1), r2)
    29     else SEQ(der(c, r1), r2)
    30   case STAR(r1) => SEQ(der(c, r1), STAR(r1))
    30   case STAR(r1) => SEQ(der(c, r1), STAR(r1))
    31   case NTIMES(r1, i) => 
    31   case NTIMES(r1, i) => 
    32     if (i == 0) ZERO else SEQ(der(c, r1), NTIMES(r1, i - 1))
    32     if (i == 0) ZERO else der(c, SEQ(r1, NTIMES(r1, i - 1)))
    33 }
    33 }
    34 
    34 
    35 def ders (s: List[Char], r: Rexp) : Rexp = s match {
    35 def ders (s: List[Char], r: Rexp) : Rexp = s match {
    36   case Nil => r
    36   case Nil => r
    37   case c::s => ders(s, der(c, r))
    37   case c::s => ders(s, der(c, r))