exps/both.scala
changeset 317 db0ff630bbb7
parent 314 20a57552d722
child 330 89e6605c4ca4
equal deleted inserted replaced
316:0eaa1851a5b6 317:db0ff630bbb7
   350 // decoding of values from bit sequences
   350 // decoding of values from bit sequences
   351 def decode_aux(r: Rexp, bs: Bits) : (Val, Bits) = (r, bs) match {
   351 def decode_aux(r: Rexp, bs: Bits) : (Val, Bits) = (r, bs) match {
   352   case (ONE, bs) => (Empty, bs)
   352   case (ONE, bs) => (Empty, bs)
   353   case (PRED(f, _), C(c)::bs) => (Chr(c), bs)
   353   case (PRED(f, _), C(c)::bs) => (Chr(c), bs)
   354   case (ALTS(r::Nil), bs) => decode_aux(r, bs)
   354   case (ALTS(r::Nil), bs) => decode_aux(r, bs)
   355   case (ALTS(rs), bs) => bs match {
   355   case (ALTS(rs), Z::bs1) => {
   356     case Z::bs1 => {
       
   357       val (v, bs2) = decode_aux(rs.head, bs1)
   356       val (v, bs2) = decode_aux(rs.head, bs1)
   358       (Left(v), bs2)
   357       (Left(v), bs2)
   359     }
   358     }
   360     case S::bs1 => {
   359   case (ALTS(rs), S::bs1) => {
   361       val (v, bs2) = decode_aux(ALTS(rs.tail), bs1)
   360       val (v, bs2) = decode_aux(ALTS(rs.tail), bs1)
   362       (Right(v), bs2)			
   361       (Right(v), bs2)	
   363     }
       
   364   }
   362   }
   365   case (SEQ(r1, r2), bs) => {
   363   case (SEQ(r1, r2), bs) => {
   366     val (v1, bs1) = decode_aux(r1, bs)
   364     val (v1, bs1) = decode_aux(r1, bs)
   367     val (v2, bs2) = decode_aux(r2, bs1)
   365     val (v2, bs2) = decode_aux(r2, bs1)
   368     (Sequ(v1, v2), bs2)
   366     (Sequ(v1, v2), bs2)