--- a/progs/re2.scala Tue Aug 23 23:12:55 2016 +0200
+++ b/progs/re2.scala Tue Sep 20 12:24:29 2016 +0100
@@ -1,3 +1,5 @@
+// version with explicit n-times regular expression
+
abstract class Rexp
case object NULL extends Rexp
case object EMPTY extends Rexp
@@ -41,6 +43,7 @@
//optional: one or zero times
def OPT(r: Rexp) = ALT(r, EMPTY)
+//evil regular expressions
def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))
val EVIL2 = SEQ(STAR(CHAR('a')), CHAR('b'))
@@ -55,7 +58,7 @@
println(i + ": " + "%.5f".format(time_needed(1, matches(EVIL1(i), "a" * i))))
}
-//a bit bolder test
+//a bit bolder tests
for (i <- 1 to 1001 by 50) {
println(i + " " + "%.5f".format(time_needed(2, matches(EVIL1(i), "a" * i))))
}