From 4b7d499c3dbd5586aa855e54367d95930fd42a81 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 31 Jan 2023 14:07:03 +0100 Subject: Minor improvements; implement saturated function and constructor applications --- example.txt | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'example.txt') diff --git a/example.txt b/example.txt index 38041f0..26fc2d8 100644 --- a/example.txt +++ b/example.txt @@ -5,13 +5,6 @@ (Cons a (List a)))) (type String (List Char)) -(fun length ((xs : List a)) : Int - (length_acc 0 xs)) -(fun length_acc ((n : Int) (xs : List a)) : Int - (case xs ( - (Nil -> n) - (Cons _ xs -> length_acc (+ n 1) xs)))) - (data TypeIdent ((TI String))) (data TypeVarIdent ((TVI String))) (data ConstructorIdent ((CI String))) @@ -39,7 +32,8 @@ (CaseAlternative Pattern Expression))) (data Expression ( - (Ident SymbolIdent) + (BasicValue BasicValue) + (Symbol SymbolIdent) (Case Expression (List CaseAlternative)) (ExpApp Expression Expression))) @@ -60,12 +54,26 @@ (Cons (Tuple (Cons 'n' Nil) (Type (Cons 'I' (Cons 'n' (Cons 't' Nil))))) (Cons (Tuple (Cons 'x' (Cons 's' Nil)) (TypeApp (Type (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil))))) (TypeVar (Cons 'a' Nil)))) Nil)) - (Case (Ident (Cons 'x' (Cons 's' Nil))) - (Cons (CaseAlternative (ConstructorPattern (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil) (Ident (Cons 'n' Nil))) - (Cons (CaseAlternative (ConstructorPattern (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons Wildcard (Cons (IdentPattern (Cons 'x' (Cons 's' Nil))) Nil)))) - Nil))))) + (Type (Cons 'I' (Cons 'n' (Cons 't' Nil)))) + (Case (Symbol (Cons 'x' (Cons 's' Nil))) + (Cons (CaseAlternative + (ConstructorPattern (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil) + (Symbol (Cons 'n' Nil))) + (Cons (CaseAlternative + (ConstructorPattern (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons Wildcard (Cons (IdentPattern (Cons 'x' (Cons 's' Nil))) Nil))) + (ExpApp (ExpApp (Symbol (Cons 'l' (Cons 'e' (Cons 'n' (Cons 'g' (Cons 't' (Cons 'h' (Cons '_' (Cons 'a' (Cons 'c' (Cons 'c' Nil))))))))))) (ExpApp (ExpApp (Cons '+' Nil) (Cons 'n' Nil)) (BasicValue (BVInt 1)))) (Cons 'x' (Cons 's' Nil)))) + Nil))))) + +(# +(fun length ((xs : List a)) : Int + (length_acc 0 xs)) +(fun length_acc ((n : Int) (xs : List a)) : Int + (case xs ( + (Nil -> n) + (Cons _ xs -> length_acc (+ n 1) xs)))) +#) -(fun testb () : Int - 37) +(fun testb ((x : Int) (y : Int)) : Int + (Tuple 37 'a')) (fun test () : Int - (testb)) + (testb 37 42)) -- cgit v1.2.3