summaryrefslogtreecommitdiffstats
path: root/mwexpand.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:27 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:27 -0800
commitfa3f23105ddcf07c5900de47f19af43d1db1b597 (patch)
treeb2c6cce6b97698098f50cbc78c23fdc0f8d401ab /mwexpand.scm
parentf24b9140d6f74804d5599ec225717d38ca443813 (diff)
downloadslib-fa3f23105ddcf07c5900de47f19af43d1db1b597.tar.gz
slib-fa3f23105ddcf07c5900de47f19af43d1db1b597.zip
Import Upstream version 2c3upstream/2c3
Diffstat (limited to 'mwexpand.scm')
-rw-r--r--mwexpand.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/mwexpand.scm b/mwexpand.scm
index 10083a3..a53f0da 100644
--- a/mwexpand.scm
+++ b/mwexpand.scm
@@ -146,6 +146,8 @@
((eq? keyword mw:denote-of-let-syntax) (mw:let-syntax exp env))
((eq? keyword mw:denote-of-letrec-syntax)
(mw:letrec-syntax exp env))
+ ; @@ case has a nontrivial syntax also -- wdc
+ ((eq? keyword mw:denote-of-case) (mw:case exp env))
; @@ let, let*, letrec, paint within quasiquotation -- kend
((eq? keyword mw:denote-of-let) (mw:let exp env))
((eq? keyword mw:denote-of-let*) (mw:let* exp env))
@@ -394,6 +396,21 @@
exp)
)
+; CASE -- added by wdc
+(define (mw:case exp env)
+ (let ((expand (lambda (exp)
+ (mw:expand exp env))))
+ (if (< (mw:safe-length exp) 3)
+ (mw:error "Malformed case expression" exp env)
+ `(case ,(expand (cadr exp))
+ ,@(map (lambda (clause)
+ (if (< (mw:safe-length exp) 2)
+ (mw:error "Malformed case clause" exp env)
+ (cons (mw:strip (car clause))
+ (map expand (cdr clause)))))
+ (cddr exp))))))
+
+
; LET
(define (mw:let exp env)
(let* ( (name (if (or (pair? (cadr exp)) (null? (cadr exp)))