# HG changeset patch # User Christian Urban # Date 1630329488 -3600 # Node ID b0352633bf48dd485983b2a64c0c1eaf22b2069b # Parent dca072e2bb7d84b3273f8b2e7c3232ba4c8b79f3 updated diff -r dca072e2bb7d -r b0352633bf48 progs/fun2/sqr.ll --- a/progs/fun2/sqr.ll Thu May 13 13:10:38 2021 +0100 +++ b/progs/fun2/sqr.ll Mon Aug 30 14:18:08 2021 +0100 @@ -36,6 +36,7 @@ } ; END OF BUILD-IN FUNCTIONS (prelude) + @Max = global i32 10 define i32 @sqr (i32 %x) { diff -r dca072e2bb7d -r b0352633bf48 progs/lexer/lexer.sc --- a/progs/lexer/lexer.sc Thu May 13 13:10:38 2021 +0100 +++ b/progs/lexer/lexer.sc Mon Aug 30 14:18:08 2021 +0100 @@ -143,9 +143,7 @@ (v:Val) => Sequ(f1(Empty), f2(v)) def F_SEQ_Empty2(f1: Val => Val, f2: Val => Val) = (v:Val) => Sequ(f1(v), f2(Empty)) -def F_RECD(f: Val => Val) = (v:Val) => v match { - case Rec(x, v) => Rec(x, f(v)) -} + def F_ERROR(v: Val): Val = throw new Exception("error") // simplification diff -r dca072e2bb7d -r b0352633bf48 progs/matcher/re1.sc --- a/progs/matcher/re1.sc Thu May 13 13:10:38 2021 +0100 +++ b/progs/matcher/re1.sc Mon Aug 30 14:18:08 2021 +0100 @@ -7,6 +7,8 @@ // or // // amm re1.sc all +// + // regular expressions abstract class Rexp @@ -96,7 +98,7 @@ // test: (a?{n}) (a{n}) -@doc("Test (a?{n}) (a{n})") +@arg(doc = "Test (a?{n}) (a{n})") @main def test1() = { println("Test (a?{n}) (a{n})") @@ -107,7 +109,7 @@ } // test: (a*)* b -@doc("Test (a*)* b") +@arg(doc = "Test (a*)* b") @main def test2() = { println("Test (a*)* b") @@ -158,7 +160,7 @@ size(ders(("ab" * 200).toList, BIG)) // 366808 -@doc("Test (a + b)* o (a o b) o (a + b)*") +@arg(doc = "Test (a + b)* o (a o b) o (a + b)*") @main def test3() = { println("Test (a + b)* o (a o b) o (a + b)*") @@ -171,6 +173,10 @@ -@doc("All tests.") +@arg(doc = "All tests.") @main def all() = { test1(); test2() ; test3() } + + + +// runs with amm2 and amm3 diff -r dca072e2bb7d -r b0352633bf48 progs/matcher/re2.sc --- a/progs/matcher/re2.sc Thu May 13 13:10:38 2021 +0100 +++ b/progs/matcher/re2.sc Mon Aug 30 14:18:08 2021 +0100 @@ -74,7 +74,7 @@ -@doc("Test (a?{n}) (a{n})") +@arg(doc = "Test (a?{n}) (a{n})") @main def test1() = { println("Test (a?{n}) (a{n})") @@ -85,7 +85,7 @@ } -@doc("Test (a*)* b") +@arg(doc = "Test (a*)* b") @main def test2() = { println("Test (a*)* b") @@ -141,6 +141,11 @@ -@doc("All tests.") +@arg(doc = "All tests.") @main def all() = { test1(); test2() } + + + + +// runs with amm2 and amm3 diff -r dca072e2bb7d -r b0352633bf48 progs/matcher/re3.sc --- 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 diff -r dca072e2bb7d -r b0352633bf48 progs/matcher/re4.sc --- a/progs/matcher/re4.sc Thu May 13 13:10:38 2021 +0100 +++ b/progs/matcher/re4.sc Mon Aug 30 14:18:08 2021 +0100 @@ -1,4 +1,4 @@ -// (ASIDE!) A version which attempts to move whole strings, +// (ASIDE!) A version which attempts to move entire strings, // not just characters, under derivatives whenever possible // // call the test cases with X = {1,2} @@ -106,8 +106,7 @@ } -// test: (a?{n}) (a{n}) -@doc("Test (a?{n}) (a{n})") +@arg(doc = "Test (a?{n}) (a{n})") @main def test1() = { for (i <- 0 to 11000 by 1000) { @@ -115,8 +114,7 @@ } } -// test: (a*)* b -@doc("Test (a*)* b") +@arg(doc = "Test (a*)* b") @main def test2() = { for (i <- 0 to 7000000 by 500000) { @@ -124,7 +122,7 @@ } } -@doc("All tests.") +@arg(doc = "All tests.") @main def all() = { test1(); test2() } @@ -163,3 +161,7 @@ // test: ("" | "a" | "aa")* val EVIL4 = STAR(ALT(ONE, ALT(CHAR('a'), SEQ(CHAR('a'), CHAR('a'))))) + + + +// runs with amm2 and amm3 diff -r dca072e2bb7d -r b0352633bf48 slides/slides01.pdf Binary file slides/slides01.pdf has changed diff -r dca072e2bb7d -r b0352633bf48 slides/slides01.tex --- a/slides/slides01.tex Thu May 13 13:10:38 2021 +0100 +++ b/slides/slides01.tex Mon Aug 30 14:18:08 2021 +0100 @@ -32,6 +32,7 @@ \begin{document} %\begin{frame}[t] +% %\begin{mybox} %A physical explanation the \emph{dynamic matrix}\\ %lots of text @@ -55,7 +56,7 @@ \begin{tabular}{@ {}c@ {}} \\[-3mm] \LARGE Compilers and \\[-1mm] - \LARGE Formal Languages\\[-3mm] + \LARGE FFFormal Languages\\[-3mm] \end{tabular}} \begin{center}