Spiral.scala
changeset 149 6c5920fd02a7
parent 148 c8ef391dd6f7
child 150 b51d34113d47
equal deleted inserted replaced
148:c8ef391dd6f7 149:6c5920fd02a7
   840         println(i)
   840         println(i)
   841         println(s)
   841         println(s)
   842         println(r)
   842         println(r)
   843         println(ders(s, r))
   843         println(ders(s, r))
   844         println(ders2(s,r))
   844         println(ders2(s,r))
   845         println("neq")
   845         println("neq") 
   846       }
   846       }
   847     }
   847     }
   848   }
   848   }
   849   def have_fun(){
   849   def have_fun(){
   850     val bis = List(S,S)
   850     val bis = List(S,S)
   851     val bits = List(S,S,Z)
   851     val bits = List(S,S,Z)
   852     val reg = ("a" | (("a")%) )~("b")
   852     val reg = ("a" | (("a")%) )~("b")
   853     val res = decode_aux(reg, bis)
   853     val res = decode_aux(reg, bis)
   854     val result = decode_aux(reg, bis)
   854     val result = decode_aux(reg, bis) 
   855     val result1 = decode_aux(reg, List(Z))
   855     val result1 = decode_aux(reg, List(Z))
   856     println(res)
   856     println(res)
   857     println(result)
   857     println(result)
   858     println(bsimp(bders( "a".toList, internalise(reg))))
   858     println(bsimp(bders( "a".toList, internalise(reg))))
   859     println(result1)
   859     println(result1)
   860   }
   860   }
   861   def finj_test0(c: Char, r: ARexp){
   861   def finj_test0(c: Char, r: ARexp){
   862     val dr = bsimp(bder(c, r))
   862     val dr = (bder(c, r))
   863     val v = if(bnullable(dr)) mkeps(erase(dr)) else mkchr(erase(dr))
   863     val sdr = bsimp(dr)
   864     val v0 = if(bnullable(dr)) mkeps(erase(bder(c,r))) else mkchr(erase(bder(c, r)))
   864     val v = if(bnullable(sdr)) mkeps(erase(sdr)) else mkchr(erase(sdr))
       
   865     val v0 = if(bnullable(sdr)) mkeps(erase(bder(c,r))) else mkchr(erase(bder(c, r)))
   865     val v1 = inj(erase(r), c, v0)
   866     val v1 = inj(erase(r), c, v0)
   866     val v2 = fuzzy_inj(r, c, v)
   867     val v2 = fuzzy_inj(r, c, v)
       
   868     println("regular expression original")
       
   869     println(bits_print(r))
       
   870     println("regular expression derivative")
       
   871     println(bits_print(dr))
       
   872     println("regular expression simped derivative")
       
   873     println(bits_print(sdr))
       
   874     println("simplified value")
       
   875     println(v)
       
   876     println("unsimplified value")
       
   877     println(v0)
       
   878     println("normal injection")
   867     println(v1)
   879     println(v1)
       
   880     println("fuzzy injection")
   868     println(v2)
   881     println(v2)
   869     
   882     println("inj "+r+c+v0)
   870   }
   883     println("fuzzy_inj "+r+c+v)
   871   def main(args: Array[String]) {
   884   }
   872     //finj_test0('b', fuse(List(S, Z), internalise(  ( ("a"|"b")% ) )   ))
   885   def vunsimp_test(){
   873     //finj_test0('a', fuse(List(S, Z), internalise(  ( ("a"|"b")% ) )   ))
       
   874     //finj_test0('b', bder('a', internalise(   (("c" | "ab")%)  )))
       
   875     //finj_test0('a', internalise(   (("c" | "ab")%)  ))
       
   876     //this example gives us an exception
       
   877     val r = internalise(ALTS(List(STAR(CHAR('c')), STAR(CHAR('b')))))
       
   878     val c = 'c'
       
   879     //println(bits_print(r))
       
   880     //println(c)
       
   881     //finj_test0(c, r)
       
   882     for(i <- 1 to 1000){
   886     for(i <- 1 to 1000){
   883       val r = random_struct_gen(3)//[{  a}*~{{a}*}*]
   887       val r = random_struct_gen(5)//[{  a}*~{{a}*}*]
   884       val c = (ran.nextInt(3) + 97).toChar//Sequ(Stars(List()),Stars(List()))
   888       val c = (ran.nextInt(3) + 97).toChar//Sequ(Stars(List()),Stars(List()))
   885       val dr = der(c, r)
   889       val dr = der(c, r)
   886       val bdr = bder(c, internalise(r))
   890       val bdr = bder(c, internalise(r))
   887       if(nullable(dr)){
   891       if(nullable(dr)){
   888         println("bohooooooooooooooooo!")
   892         println("bohooooooooooooooooo!")
   891         println(bits_print(target_vr._1))
   895         println(bits_print(target_vr._1))
   892         println(target_vr._2)
   896         println(target_vr._2)
   893         println(vunsimp(bdr, dv)(target_vr._2))
   897         println(vunsimp(bdr, dv)(target_vr._2))
   894       }
   898       }
   895     }
   899     }
   896     
   900   }
       
   901   def main(args: Array[String]) {
       
   902     //finj_test0('b', fuse(List(S, Z), internalise(  ( ("a"|"b")% ) )   ))
       
   903     //finj_test0('a', fuse(List(S, Z), internalise(  ( ("a"|"b")% ) )   ))
       
   904     //finj_test0('b', bder('a', internalise(   (("c" | "ab")%)  )))
       
   905     //finj_test0('a', internalise(   (("c" | "ab")%)  ))
       
   906     //this example gives us an exception
       
   907     //val r = internalise(ALTS(List(STAR(CHAR('c')), STAR(CHAR('b')))))
       
   908     //val c = 'c'
       
   909     //if(bder(c, r) != internalise(der(c, erase(r))))
       
   910       //println("noooooo!")
       
   911     //println(bits_print(r))
       
   912     //println(c)
       
   913     //finj_test0(c, r) 
       
   914     vunsimp_test()
   897   }
   915   }
   898    
   916    
   899 }
   917 }
   900 //List(              ASTAR(List(Z),ACHAR(List(),a)),            AALTS(List(S),List(ACHAR(List(Z),b), ACHAR(List(S),a)))       )
   918 //List(              ASTAR(List(Z),ACHAR(List(),a)),            AALTS(List(S),List(ACHAR(List(Z),b), ACHAR(List(S),a)))       )