progs/matcher/re3.sc
changeset 782 be79edaf06e1
parent 769 b153de5339bc
child 825 fb9f63a22114
equal deleted inserted replaced
781:4fcc88f06d5e 782:be79edaf06e1
   144 @doc("All tests.")
   144 @doc("All tests.")
   145 @main
   145 @main
   146 def all() = { test1(); test2() } 
   146 def all() = { test1(); test2() } 
   147 
   147 
   148 
   148 
       
   149 
       
   150 
       
   151 
       
   152 // test: (a + aa)*
       
   153 val EVIL3 = STAR(ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a'))))
       
   154 
       
   155 // test: (1 + a + aa)*
       
   156 val EVIL4 = STAR(ALT(ONE, ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a')))))
       
   157 
       
   158 @doc("Test Evil3")
       
   159 @main
       
   160 def test3() = {
       
   161   println("Test (a + aa)*")
       
   162 
       
   163   for (i <- 0 to 35 by 5) {
       
   164     println(f"$i: ${time_needed(1, matcher(EVIL3, "a" * i))}%.5f")
       
   165   }
       
   166 }
       
   167 
       
   168 @doc("Test Evil4")
       
   169 @main
       
   170 def test4() = {
       
   171   println("Test (1 + a + aa)*")
       
   172 
       
   173   for (i <- 0 to 35 by 5) {
       
   174     println(f"$i: ${time_needed(1, matcher(EVIL4, "a" * i))}%.5f")
       
   175   }
       
   176 }