diff -r 53e7da9f372a -r 53f08d873e09 progs/matcher/re2.sc --- a/progs/matcher/re2.sc Fri Sep 15 10:49:33 2023 +0100 +++ b/progs/matcher/re2.sc Sun Sep 17 19:12:57 2023 +0100 @@ -1,6 +1,8 @@ -// A Version with an explicit n-times regular expression; +// A Version of the matcher with an explicit +// n-times regular expression +// // this keeps the size of the regular expression in the -// EVIL1 test-case quite small +// EVIL1 testcase small // // call the test cases with X = {1,2} // @@ -31,7 +33,6 @@ case NTIMES(r, n) => if (n == 0) true else nullable(r) } - def der(c: Char, r: Rexp) : Rexp = r match { case ZERO => ZERO case ONE => ZERO @@ -54,13 +55,13 @@ nullable(ders(s.toList, r)) +// Test Cases + // the optional regular expression: one or zero times // this regular expression is still defined in terms of ALT def OPT(r: Rexp) = ALT(r, ONE) -// Test Cases - // evil regular expressions def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) @@ -90,7 +91,7 @@ def test2() = { println("Test (a*)* b") - for (i <- 0 to 30 by 2) { + for (i <- 0 to 22 by 2) { println(f"$i: ${time_needed(1, matcher(EVIL2, "a" * i))}%.5f") } }