--- a/progs/matcher/re3.sc Thu May 13 13:10:38 2021 +0100
+++ b/progs/matcher/re3.sc Mon Aug 30 14:18:08 2021 +0100
@@ -96,8 +96,7 @@
}
-//
-//@doc("Test (a?{n}) (a{n})")
+@arg(doc = "Test (a?{n}) (a{n})")
@main
def test1() = {
println("Test (a?{n}) (a{n})")
@@ -107,8 +106,7 @@
}
}
-//
-//@doc("Test (a*)* b")
+@arg(doc = "Test (a*)* b")
@main
def test2() = {
println("Test (a*)* b")
@@ -141,7 +139,7 @@
size(ders("aaaaa".toList, EVIL2)) // 8
-@doc("All tests.")
+@arg(doc = "All tests.")
@main
def all() = { test1(); test2() }
@@ -149,28 +147,43 @@
+// PS:
+//
+// If you want to dig deeper into the topic, you can have
+// a look at these examples which still explode. They
+// need an even more aggressive simplification.
+
// test: (a + aa)*
val EVIL3 = STAR(ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a'))))
-// test: (1 + a + aa)*
-val EVIL4 = STAR(ALT(ONE, ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a')))))
-@doc("Test Evil3")
+@arg(doc = "Test EVIL3")
@main
def test3() = {
println("Test (a + aa)*")
- for (i <- 0 to 35 by 5) {
+ for (i <- 0 to 30 by 5) {
println(f"$i: ${time_needed(1, matcher(EVIL3, "a" * i))}%.5f")
}
}
-@doc("Test Evil4")
+
+// test: (1 + a + aa)*
+val EVIL4 = STAR(ALT(ONE, ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a')))))
+
+@arg(doc = "Test EVIL4")
@main
def test4() = {
println("Test (1 + a + aa)*")
- for (i <- 0 to 35 by 5) {
+ for (i <- 0 to 30 by 5) {
println(f"$i: ${time_needed(1, matcher(EVIL4, "a" * i))}%.5f")
}
}
+
+@arg(doc = "Tests that show not all is hunky-dory, but a solution leads too far afield.")
+@main
+def fail() = { test3(); test4() }
+
+
+// runs with amm2 and amm3