diff -r 6722cd24c784 -r ad9d4a01e072 progs/matcher/re1.sc --- a/progs/matcher/re1.sc Thu Sep 29 22:07:21 2022 +0100 +++ b/progs/matcher/re1.sc Fri Sep 30 06:03:46 2022 +0100 @@ -179,47 +179,3 @@ @arg(doc = "All tests.") @main def all() = { test1(); test2() ; test3() } - - - -// runs with amm2 and amm3 - -def pp(r: Rexp): String = r match { - case SEQ(CHAR(a1), SEQ(r1, r2)) => s"${a1}${pp(r1)}${pp(r2)}" - case SEQ(ONE, SEQ(r1, r2)) => s"1${pp(r1)}${pp(r2)}" - case SEQ(ZERO, SEQ(r1, r2)) => s"0${pp(r1)}${pp(r2)}" - case SEQ(CHAR(a1), CHAR(a2)) => s"${a1}${a2}" - case SEQ(ONE, CHAR(a2)) => s"1${a2}" - case SEQ(ZERO, CHAR(a2)) => s"0${a2}" - case ZERO => "0" - case ONE => "1" - case CHAR(a) => a.toString - case ALT(r1, r2) => s"(${pp(r1)} + ${pp(r2)})" - case SEQ(r1, r2) => s"(${pp(r1)} o ${pp(r2)})" - case STAR(r1) => s"(${pp(r1)})*" -} - - -val REG = STAR(ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a')))) - -print(pp(ders("".toList, REG))) -print(pp(ders("a".toList, REG))) -print(pp(ders("aa".toList, REG))) -print(pp(ders("aaa".toList, REG))) - -size(ders("".toList, REG)) // 6 -size(ders("a".toList, REG)) // 12 -size(ders("aa".toList, REG)) // 27 -size(ders("aaa".toList, REG)) // 55 -size(ders("aaaa".toList, REG)) // 98 -size(ders("aaaaa".toList, REG)) // 169 -size(ders("aaaaaa".toList, REG)) // 283 -size(ders(("a" * 7).toList, REG)) // 468 -size(ders(("a" * 8).toList, REG)) // 767 -size(ders(("a" * 9).toList, REG)) // 1251 -size(ders(("a" * 10).toList, REG))// 2034 -size(ders(("a" * 11).toList, REG))// 3301 - -for (i <- (0 to 40)) { - println(s"$i:" + size(ders(("a" * i).toList, REG))) -} \ No newline at end of file