main_solution3/re.scala
changeset 470 86a456f8cb92
parent 456 d076cb2e0b75
child 475 59e005dcf163
equal deleted inserted replaced
469:48de09728447 470:86a456f8cb92
    60   case CHAR(d) => if (c == d) ONE else ZERO
    60   case CHAR(d) => if (c == d) ONE else ZERO
    61   case ALTs(rs) => ALTs(rs.map(der(c, _)))
    61   case ALTs(rs) => ALTs(rs.map(der(c, _)))
    62   case SEQs(Nil) => ZERO
    62   case SEQs(Nil) => ZERO
    63   case SEQs(r1::rs) => 
    63   case SEQs(r1::rs) => 
    64     if (nullable(r1)) ALT(SEQs(der(c, r1)::rs), der(c, SEQs(rs)))
    64     if (nullable(r1)) ALT(SEQs(der(c, r1)::rs), der(c, SEQs(rs)))
    65     else SEQs(der(c, r1):: rs)
    65     else SEQs(der(c, r1) :: rs)
    66   case STAR(r1) => SEQ(der(c, r1), STAR(r1))
    66   case STAR(r1) => SEQ(der(c, r1), STAR(r1))
    67 }
    67 }
    68 
    68 
    69 
    69 
    70 // (3) 
    70 // (3)