reformatting

This commit is contained in:
Sam Tobin-Hochstadt 2006-09-01 16:52:45 -04:00
parent dd4c63ab07
commit 9e17a6d993

View File

@ -65,57 +65,57 @@
((_ ([pat exp] rest ...) body ...) ((_ ([pat exp] rest ...) body ...)
(if (pattern-var? (syntax pat)) (if (pattern-var? (syntax pat))
#'(let ([pat exp]) #'(let ([pat exp])
(match-let* (rest ...) body ...)) (match-let* (rest ...) body ...))
#'(match exp [pat (match-let* (rest ...) body ...)])) #'(match exp [pat (match-let* (rest ...) body ...)]))
))) )))
(define-syntax (match-letrec stx) (define-syntax (match-letrec stx)
(syntax-case stx () (syntax-case stx ()
[(_ (clauses ...)) (match:syntax-err stx "bad syntax (empty body)")] [(_ (clauses ...)) (match:syntax-err stx "bad syntax (empty body)")]
[(_ ([pat exp] ...) . body) [(_ ([pat exp] ...) . body)
(andmap pattern-var? (andmap pattern-var?
(syntax->list #'(pat ...))) (syntax->list #'(pat ...)))
#'(letrec ([pat exp] ...) . body)] #'(letrec ([pat exp] ...) . body)]
[(_ ([pat exp] ...) . body) [(_ ([pat exp] ...) . body)
(let* ((**match-bound-vars** '()) (let* ((**match-bound-vars** '())
(compiled-match (compiled-match
(gen-match #'the-exp (gen-match #'the-exp
'() '()
#'(((list pat ...) never-used)) #'(((list pat ...) never-used))
stx stx
(lambda (sf bv) (lambda (sf bv)
(set! **match-bound-vars** bv) (set! **match-bound-vars** bv)
#`(begin #`(begin
#,@(map (lambda (x) #`(set! #,(car x) #,(cdr x))) #,@(map (lambda (x) #`(set! #,(car x) #,(cdr x)))
(reverse bv)) (reverse bv))
. body ))))) . body )))))
#`(letrec (#,@(map #`(letrec (#,@(map
(lambda (x) #`(#,(car x) #f)) (lambda (x) #`(#,(car x) #f))
(reverse **match-bound-vars**)) (reverse **match-bound-vars**))
(the-exp (list exp ...))) (the-exp (list exp ...)))
#,compiled-match))])) #,compiled-match))]))
(define-syntax (match-define stx) (define-syntax (match-define stx)
(syntax-case stx () (syntax-case stx ()
[(_ pat exp) [(_ pat exp)
(identifier? #'pat) (identifier? #'pat)
#'(define pat exp)] #'(define pat exp)]
[(_ pat exp) [(_ pat exp)
(let* ((**match-bound-vars** '()) (let* ([**match-bound-vars** '()]
(compiled-match [compiled-match
(gen-match #'the-exp (gen-match #'the-exp
'() '()
#'((pat never-used)) #'((pat never-used))
stx stx
(lambda (sf bv) (lambda (sf bv)
(set! **match-bound-vars** bv) (set! **match-bound-vars** bv)
#`(begin #`(begin
#,@(map (lambda (x) #,@(map (lambda (x)
#`(set! #,(car x) #,(cdr x))) #`(set! #,(car x) #,(cdr x)))
(reverse bv))))))) (reverse bv)))))])
#`(begin #,@(map #`(begin #,@(map
(lambda (x) #`(define #,(car x) #f)) (lambda (x) #`(define #,(car x) #f))
(reverse **match-bound-vars**)) (reverse **match-bound-vars**))
(let ((the-exp exp)) (let ((the-exp exp))
#,compiled-match)))])) #,compiled-match)))]))
) )