progs/matcher/re3.sc
changeset 782 a26a20acd1c2
parent 769 f9686b22db7e
child 825 dca072e2bb7d
equal deleted inserted replaced
781:bae72c598afd 782:a26a20acd1c2
   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 }