]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Implemented alternative function definition syntax with no tests
authorMike D. Lowis <mike@mdlowis.com>
Thu, 2 Aug 2012 19:24:07 +0000 (15:24 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Thu, 2 Aug 2012 19:24:07 +0000 (15:24 -0400)
source/parser.scm

index 3c08fd81306f5d25c096dade5dd3232855fc8637..d9f326cb709849cc08ea9f2ff8d4e1c1d4f3fc22 100644 (file)
   (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)
 
   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)