diff options
-rw-r--r-- | doc/docs/frontend/syntax.md | 12 | ||||
-rw-r--r-- | example.txt | 30 | ||||
-rw-r--r-- | snug-clean/src/Snug/Parse.icl | 2 |
3 files changed, 22 insertions, 22 deletions
diff --git a/doc/docs/frontend/syntax.md b/doc/docs/frontend/syntax.md index 836201c..17436af 100644 --- a/doc/docs/frontend/syntax.md +++ b/doc/docs/frontend/syntax.md @@ -40,19 +40,19 @@ Type synonyms can be defined with: ## Functions ```snug -(fun length ((xs : List a)) : Int - (length_acc 0 xs)) +(fun length ((xs : List a)) : Int : + length_acc 0 xs) -(fun length_acc ((n : Int) (xs : List a)) : Int - (case xs ( +(fun length_acc ((n : Int) (xs : List a)) : Int : + case xs ( (Nil -> n) - (Cons _ xs -> length_acc (+ n 1) xs)))) + (Cons _ xs -> length_acc (+ n 1) xs))) ``` In abstract terms, the syntax is: ```snug -(fun NAME (ARGUMENTS) : TYPE (EXPRESSION)) +(fun NAME (ARGUMENTS) : TYPE : EXPRESSION) ``` where arguments are of the form `(NAME : TYPE)`. diff --git a/example.txt b/example.txt index 26fc2d8..5aa858a 100644 --- a/example.txt +++ b/example.txt @@ -41,15 +41,15 @@ (DataDef TypeIdent (List TypeVarIdent) (List ConstructorDef)) (FunDef SymbolIdent (List (Tuple SymbolIdent Type)) Type Expression))) -(fun list_ast () : Definition - (DataDef +(fun list_ast () : Definition : + DataDef (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil)))) (Cons (Cons 'a' Nil) Nil) (Cons (ConstructorDef (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil) (Cons (ConstructorDef (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons (TypeVar (Cons 'a' Nil)) (Cons (TypeApp (Type (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil))))) (TypeVar (Cons 'a' Nil))) Nil))) - Nil)))) -(fun length_acc_ast () : Definition - (FunDef + Nil))) +(fun length_acc_ast () : Definition : + FunDef (Cons 'l' (Cons 'e' (Cons 'n' (Cons 'g' (Cons 't' (Cons 'h' (Cons '_' (Cons 'a' (Cons 'c' (Cons 'c' Nil)))))))))) (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)))) @@ -62,18 +62,18 @@ (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))))) + Nil)))) (# -(fun length ((xs : List a)) : Int - (length_acc 0 xs)) -(fun length_acc ((n : Int) (xs : List a)) : Int - (case xs ( +(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)))) + (Cons _ xs -> length_acc (+ n 1) xs))) #) -(fun testb ((x : Int) (y : Int)) : Int - (Tuple 37 'a')) -(fun test () : Int - (testb 37 42)) +(fun testb ((x : Int) (y : Int)) : Int : + Tuple 37 'a') +(fun test () : Int : + testb 37 42) diff --git a/snug-clean/src/Snug/Parse.icl b/snug-clean/src/Snug/Parse.icl index 64331c5..9d58f23 100644 --- a/snug-clean/src/Snug/Parse.icl +++ b/snug-clean/src/Snug/Parse.icl @@ -42,7 +42,7 @@ where (pToken (TIdent "fun") *> symbolIdent) (simpleList (parenthesized typedArgument)) (pToken TColon *> type) - simpleOrParenthesizedExpression + (pToken TColon *> expression) simpleConstructorDef = liftM2 ConstructorDef constructorIdent (pure []) constructorDef = liftM2 ConstructorDef constructorIdent (many simpleOrParenthesizedType) |