From 3987a0ca20da1a438e2999ba0da3f8f4f4461267 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Thu, 2 Aug 2012 15:24:07 -0400 Subject: [PATCH] Implemented alternative function definition syntax with no tests --- source/parser.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/parser.scm b/source/parser.scm index 3c08fd8..d9f326c 100644 --- a/source/parser.scm +++ b/source/parser.scm @@ -66,7 +66,11 @@ (keyword-match in "def") (set! node (syntree 'define "" - (list (token->syntree (token-match in 'id)) (dlang/expression in)))) + (list + (token->syntree (token-match in 'id)) + (if (test-apply dlang/id-list in) + (dlang/func-body in) + (dlang/expression in))))) (token-match in 'term) node) @@ -99,14 +103,18 @@ node) (define (dlang/func in) - (define node (syntree 'func "" '())) + (define node '()) (keyword-match in "func") - (syntree-children-set! node - (list (dlang/id-list in) (dlang/expr-block in 'term))) + (set! node (dlang/func-body in)) (token-match in 'term) - (syntree-type-set! node 'func) node) +(define (dlang/func-body in) + (syntree 'func "" + (list + (dlang/id-list in) + (dlang/expr-block in 'term)))) + (define (dlang/basic-expr in) (if (token-matches? in 'lpar) (dlang/operator-app in) -- 2.52.0