progs/app06.scala
changeset 453 36e5752fa191
parent 446 16742bf62365
child 788 3b1136fb6bee
equal deleted inserted replaced
452:b93f4d2aeee1 453:36e5752fa191
     1 def simp(r: Rexp): (Rexp, Val => Val) = r match {
     1 def simp(r: Rexp): (Rexp, Val => Val) = r match {
     2   case SEQ(r1, r2) => {
     2   case SEQ(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, _) => (NULL, F_ERROR)
     6       case (ZERO, _) => (ZERO, F_ERROR)
     7       case (_, NULL) => (NULL, F_ERROR)
     7       case (_, ZERO) => (ZERO, F_ERROR)
     8       case (EMPTY, _) => (r2s, F_SEQ_Void1(f1s, f2s))
     8       case (ONE, _) => (r2s, F_SEQ_Void1(f1s, f2s))
     9       case (_, EMPTY) => (r1s, F_SEQ_Void2(f1s, f2s))
     9       case (_, ONE) => (r1s, F_SEQ_Void2(f1s, f2s))
    10       case _ => (SEQ(r1s,r2s), F_SEQ(f1s, f2s))
    10       case _ => (SEQ(r1s,r2s), F_SEQ(f1s, f2s))
    11     }
    11     }
    12   }
    12   }
    13   ...
    13   ...
    14 
    14