--- a/progs/re4.scala Tue Oct 04 12:00:23 2016 +0100
+++ b/progs/re4.scala Tue Oct 04 14:30:08 2016 +0100
@@ -29,7 +29,7 @@
case SEQ(r1, r2) =>
if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
else SEQ(der(c, r1), r2)
- case STAR(r) => SEQ(der(c, r), STAR(r))
+ case STAR(r1) => SEQ(der(c, r1), STAR(r1))
case NTIMES(r, i) =>
if (i == 0) ZERO else SEQ(der(c, r), NTIMES(r, i - 1))
}
@@ -74,7 +74,7 @@
def OPT(r: Rexp) = ALT(r, ONE)
def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))
-val EVIL2 = SEQ(STAR(CHAR('a')), CHAR('b'))
+val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
def time_needed[T](i: Int, code: => T) = {
@@ -85,14 +85,23 @@
}
// warmup
-val i = 5000
-println(i + " " + "%.5f".format(time_needed(10, matcher(EVIL1(i), "a" * i))))
+//test: (a?{n}) (a{n})
+for (i <- 1 to 7000001 by 500000) {
+ println(i + " " + "%.5f".format(time_needed(2, matcher(EVIL1(i), "a" * i))))
+}
-for (i <- 1 to 7000001 by 1000000) {
+for (i <- 1 to 7000001 by 500000) {
println(i + " " + "%.5f".format(time_needed(2, matcher(EVIL1(i), "a" * i))))
}
-for (i <- 1 to 7500001 by 500000) {
+//test: (a*)* b
+for (i <- 1 to 7000001 by 500000) {
println(i + " " + "%.5f".format(time_needed(2, matcher(EVIL2, "a" * i))))
}
+for (i <- 1 to 7000001 by 500000) {
+ println(i + " " + "%.5f".format(time_needed(2, matcher(EVIL2, "a" * i))))
+}
+
+
+