lex_blex_Frankensteined.scala
changeset 3 f15dccc42c7b
parent 0 902326e1615a
child 5 622ddbb1223a
equal deleted inserted replaced
2:cf169411b771 3:f15dccc42c7b
    86     case STAR(r) => ASTAR(Nil, internalise(r))
    86     case STAR(r) => ASTAR(Nil, internalise(r))
    87     case RECD(x, r) => internalise(r)
    87     case RECD(x, r) => internalise(r)
    88   }
    88   }
    89 
    89 
    90   internalise(("a" | "ab") ~ ("b" | ""))
    90   internalise(("a" | "ab") ~ ("b" | ""))
    91 
    91 /*
    92   def decode_aux(r: Rexp, bs: Bits) : (Val, Bits) = (r, bs) match {
    92   def decode_aux(r: Rexp, bs: Bits) : (Val, Bits) = (r, bs) match {
    93     case (ONE, bs) => (Empty, bs)
    93     case (ONE, bs) => (Empty, bs)
    94     case (PRED(f), C(c)::bs) => (Chr(c), bs)
    94     case (PRED(f), C(c)::bs) => (Chr(c), bs)
    95     case (ALTS(r::Nil), bs) => decode_aux(r, bs)//this case seems tailor made for those who want to simplify the regex before der or simp
    95     case (ALTS(r::Nil), bs) => decode_aux(r, bs)//this case seems tailor made for those who want to simplify the regex before der or simp
    96     case (ALTS(rs), bs) => bs match {
    96     case (ALTS(rs), bs) => bs match {
   123 
   123 
   124   def decode(r: Rexp, bs: Bits) = decode_aux(r, bs) match {
   124   def decode(r: Rexp, bs: Bits) = decode_aux(r, bs) match {
   125     case (v, Nil) => v
   125     case (v, Nil) => v
   126     case _ => throw new Exception("Not decodable")
   126     case _ => throw new Exception("Not decodable")
   127   }
   127   }
   128 
   128 */
   129 
   129 
   130   //erase function: extracts the regx from Aregex
   130   //erase function: extracts the regx from Aregex
   131   def erase(r:ARexp): Rexp = r match{
   131   def erase(r:ARexp): Rexp = r match{
   132     case AZERO => ZERO
   132     case AZERO => ZERO
   133     case AONE(_) => ONE
   133     case AONE(_) => ONE