Spiral.scala
changeset 6 26b40a985622
parent 5 622ddbb1223a
child 7 1572760ff866
equal deleted inserted replaced
5:622ddbb1223a 6:26b40a985622
   212       case (0, i) => STAR(random_struct_gen(depth - 1))
   212       case (0, i) => STAR(random_struct_gen(depth - 1))
   213       case (1, i) => SEQ(random_struct_gen(depth - 1), random_struct_gen(depth - 1))
   213       case (1, i) => SEQ(random_struct_gen(depth - 1), random_struct_gen(depth - 1))
   214       case (2, i) => ALTS( List(random_struct_gen(depth - 1), random_struct_gen(depth - 1) ) )
   214       case (2, i) => ALTS( List(random_struct_gen(depth - 1), random_struct_gen(depth - 1) ) )
   215     }
   215     }
   216   }
   216   }
       
   217   def random_pool(n: Int, d: Int) : Stream[Rexp] = n match {
       
   218     case 0 => (for (i <- 1 to 10) yield balanced_struct_gen(d)).toStream
       
   219     case n => {  
       
   220       val rs = random_pool(n - 1, d)
       
   221       rs #:::
       
   222       (for (i <- (1 to 10).toStream) yield balanced_struct_gen(d)) #::: 
       
   223       (for (i <- (1 to 10).toStream) yield random_struct_gen(d))
       
   224     }
       
   225   }
       
   226 
   217   def rd_string_gen(alp_size: Int, len: Int): String = {
   227   def rd_string_gen(alp_size: Int, len: Int): String = {
   218     if( len > 0)
   228     if( len > 0)
   219       ((ran.nextInt(alp_size) + 97).toChar).toString + rd_string_gen(alp_size, len - 1)
   229       ((ran.nextInt(alp_size) + 97).toChar).toString + rd_string_gen(alp_size, len - 1)
   220     else
   230     else
   221       ((ran.nextInt(alp_size) + 97).toChar).toString
   231       ((ran.nextInt(alp_size) + 97).toChar).toString
   386         }
   396         }
   387     }
   397     }
   388   }
   398   }
   389   def main(args: Array[String]) {
   399   def main(args: Array[String]) {
   390     //check_all()   
   400     //check_all()   
   391     enum(3, "abc").map(tests_blexer_simp(strs(3, "abc"))).toSet
   401     //enum(3, "abc").map(tests_blexer_simp(strs(3, "abc"))).toSet
       
   402     //
       
   403     random_pool(1, 5).map(tests_blexer_simp(strs(5, "abc"))).toSet
   392     //correctness_proof_convenient_path()
   404     //correctness_proof_convenient_path()
   393   } 
   405   } 
   394 }
   406 }
   395 
   407