lex_blex_Frankensteined.scala
changeset 93 d486c12deeab
parent 92 aaa2f2b52baf
child 107 b1e365afa29c
--- a/lex_blex_Frankensteined.scala	Wed Nov 27 14:15:00 2019 +0000
+++ b/lex_blex_Frankensteined.scala	Thu Jan 09 22:20:09 2020 +0000
@@ -203,6 +203,7 @@
     case c::cs => if(nullable(c)) re_closeo(cs, l2.tail, ALT(re_init,  l2.head)  ) 
     else re_closeo(cs, l2.tail, re_init)
   }
+
   //HERE
   def closed_string_dero(r1: Rexp, r2: Rexp, s: List[Char]): Rexp = {
     val l1 = der_seqo(r1, s, Nil)
@@ -473,13 +474,15 @@
       val dist_res = distinctBy(flat_res, erase)
       dist_res match {
         case Nil => AZERO
-        case s :: Nil => fuse(bs1, s)
+        case r :: Nil => fuse(bs1, r)
         case rs => AALTS(bs1, rs)  
       }
     }
     //case ASTAR(bs, r) => ASTAR(bs, bsimp(r))
     case r => r
   }
+  //only print at the top level
+
   def find_pos(v: Val, rs: List[ARexp]): Int = (v, rs) match{
     case (v, r::Nil) => 0
     case (Right(v), r::rs) => find_pos(v, rs) + 1
@@ -528,8 +531,6 @@
     case (AALTS(bs1, rs), v) => {
       //phase 1 transformation so that aalts(bs1, rs) => aalts(bs1, rsf) and v => vf
       val init_ind = find_pos(v, rs)
-      //println(rs)
-      //println(v)
       val vs = bsimp2(rs(init_ind), remove(v, rs))//remove all the outer layers of left and right in v to  match the regx rs[i]
       //println(vs)
       val rs_simp = rs.map(bsimp)
@@ -538,30 +539,17 @@
         case r => vs._2
       }
       val flat_res = flats(rs_simp)
-      //println(rs_simp)
-      //println(flat_res)
-      //println(init_ind)
       val vs_for_coating = if(isend(vs._2, rs_simp, init_ind)||flat_res.length == 1) vs_kernel else Left(vs_kernel)
-      //println(vs_for_coating)
       val r_s = rs_simp(init_ind)//or vs._1
       val shift = flats_vsimp(rs_simp, init_ind) + find_pos_aux(vs._2, rs_simp(init_ind))
-      //println(shift)
       val new_ind = init_ind + shift
-      //println("new ind:")
-      //println(new_ind)
       val vf = coat(vs_for_coating, new_ind)
-      //println("vf:")
-      //println(vf)
       //flats2 returns a list of regex and a single v
       //now |- vf: ALTS(bs1, flat_res)
-
       //phase 2 transformation so that aalts(bs1, rsf) => aalts(bs, rsdb) and vf => vdb
       val dist_res = distinctBy(flat_res, erase)
       val front_part = distinctBy(flat_res.slice(0, new_ind + 1), erase)
       //val size_reduction = new_ind + 1 - front_part.length
-      //println(flat_res.length)
-      //println(dist_res)
-      //println(front_part)
       val vdb = if(dist_res.length == front_part.length )//that means the regex we are interested in is at the end of the list
       {
         coat(vs_kernel, front_part.length - 1)