From e71c1ade8e975fa5a1919e1fdfd90ba6659254a7 Mon Sep 17 00:00:00 2001 From: EmilySillars Date: Wed, 21 Sep 2022 10:36:32 -0400 Subject: [PATCH 1/3] add a minimal test case --- regression-tests/tests/list4.out | 3 +++ regression-tests/tests/list4.ssl | 41 ++++++++++++++++++++++++++++++++ src/Common/Pretty.hs | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 regression-tests/tests/list4.out create mode 100644 regression-tests/tests/list4.ssl diff --git a/regression-tests/tests/list4.out b/regression-tests/tests/list4.out new file mode 100644 index 00000000..50cccb54 --- /dev/null +++ b/regression-tests/tests/list4.out @@ -0,0 +1,3 @@ +A +D +[] diff --git a/regression-tests/tests/list4.ssl b/regression-tests/tests/list4.ssl new file mode 100644 index 00000000..04f27cf0 --- /dev/null +++ b/regression-tests/tests/list4.ssl @@ -0,0 +1,41 @@ +// ./runtests.sh tests/list4.ssl +// stack exec sslc -- --dump-ir tests/list4.ssl +// stack exec sslc -- tests/list4.ssl + + + +type List a + Cons a (List a) + Nil + +main cin cout = + let putc c = after 1, cout <- c + wait cout + let printNil _ = putc '[' // do we not have 0 argument functions?? + putc ']' + + // want to add syntax for list here! + let two = Cons 65 (Cons 68 Nil) // 'A' : 'D' : [] + //^ instead of this, eventually want to be able to do + //^ let two = ['A', 'D'] + + match two + Cons c _ = putc c // Should print A + Nil = printNil 33 + putc '\n' + + match two + Cons _ l = match l + Cons c _ = putc c // Should print D + Nil = printNil 33 + Nil = printNil 33 + putc '\n' + + match two + Cons _ l = match l + Cons _ l = match l + Cons c _ = putc 33 // should never reach here + Nil = printNil 33 + Nil = printNil 33 + Nil = printNil 33 + putc '\n' diff --git a/src/Common/Pretty.hs b/src/Common/Pretty.hs index 4a501329..62f4ccb0 100644 --- a/src/Common/Pretty.hs +++ b/src/Common/Pretty.hs @@ -61,7 +61,7 @@ spaghetti :: Dumpy t => t -> String spaghetti = renderString . layoutPretty opts . dumpy where opts = LayoutOptions { layoutPageWidth = Unbounded } -{- | Lengthy Typeclass: print an ugly but parseable representation of the AST +{- | Dumpy Typeclass: print an ugly but parseable representation of the AST * Translates from IR to Doc representation in one-to-one fashion * No simplifications From fdfbb9185f1fb35a1df62d58f40f5acad739a5e4 Mon Sep 17 00:00:00 2001 From: EmilySillars Date: Wed, 21 Sep 2022 10:50:12 -0400 Subject: [PATCH 2/3] add comments to test case --- regression-tests/tests/list4.ssl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/regression-tests/tests/list4.ssl b/regression-tests/tests/list4.ssl index 04f27cf0..76c501f6 100644 --- a/regression-tests/tests/list4.ssl +++ b/regression-tests/tests/list4.ssl @@ -3,7 +3,6 @@ // stack exec sslc -- tests/list4.ssl - type List a Cons a (List a) Nil @@ -11,8 +10,17 @@ type List a main cin cout = let putc c = after 1, cout <- c wait cout - let printNil _ = putc '[' // do we not have 0 argument functions?? + let printNil _ = putc '[' // maybe we don't have 0 argument functions yet?? putc ']' + +/* maybe we don't have local recursive functions yet?? + let printList lst = match lst + Cons h tl = putc h + putc '\n' + printList tl + Nil = printNil + putc '\n' +*/ // want to add syntax for list here! let two = Cons 65 (Cons 68 Nil) // 'A' : 'D' : [] From 87e74bda50127ba88b5e20d1644e8c49d245fd26 Mon Sep 17 00:00:00 2001 From: EmilySillars Date: Fri, 23 Sep 2022 12:21:47 -0400 Subject: [PATCH 3/3] more changes --- regression-tests/tests/list4.ssl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/regression-tests/tests/list4.ssl b/regression-tests/tests/list4.ssl index 76c501f6..712284f3 100644 --- a/regression-tests/tests/list4.ssl +++ b/regression-tests/tests/list4.ssl @@ -1,12 +1,17 @@ // ./runtests.sh tests/list4.ssl // stack exec sslc -- --dump-ir tests/list4.ssl // stack exec sslc -- tests/list4.ssl +// stack exec sslc -- --dump-ir-annotated tests/list4.ssl type List a Cons a (List a) Nil +testfunc (arg0 : Int) -> Int = arg0 + + + main cin cout = let putc c = after 1, cout <- c wait cout @@ -21,6 +26,8 @@ main cin cout = Nil = printNil putc '\n' */ + + let x = 'h' + 't' // this should throw an error once character literals are a thing! // want to add syntax for list here! let two = Cons 65 (Cons 68 Nil) // 'A' : 'D' : []