Fix handling of (or) in match.

svn: r13295
This commit is contained in:
Sam Tobin-Hochstadt 2009-01-27 19:57:59 +00:00
parent 2962c0bfa7
commit 5baa4390d3
4 changed files with 15 additions and 6 deletions

View File

@ -177,9 +177,9 @@
#f))
;; (listof pat) syntax -> void
;; ps is never null
;; check that all the ps bind the same set of variables
(define (all-vars ps stx)
(when (null? ps) (error 'bad))
(define (all-vars ps stx)
(let* ([first-vars (bound-vars (car ps))]
[l (length ps)]
[ht (make-free-identifier-mapping)])

View File

@ -25,8 +25,10 @@
"This expander only works with the standard match syntax")]
[(and p ...)
(make-And (map parse (syntax->list #'(p ...))))]
[(or p ...)
(let ([ps (map parse (syntax->list #'(p ...)))])
[(or)
(make-Not (make-Dummy stx))]
[(or p ps ...)
(let ([ps (map parse (syntax->list #'(p ps ...)))])
(all-vars ps stx)
(make-Or ps))]
[(not p ...)

View File

@ -38,8 +38,10 @@
(make-Var #'v)]
[(and p ...)
(make-And (map parse (syntax->list #'(p ...))))]
[(or p ...)
(let ([ps (map parse (syntax->list #'(p ...)))])
[(or)
(make-Not (make-Dummy stx))]
[(or p ps ...)
(let ([ps (map parse (syntax->list #'(p ps ...)))])
(all-vars ps stx)
(make-Or ps))]
[(not p ...)

View File

@ -598,4 +598,9 @@
[(? number?) (z)]))
(lambda _ 12)))
(comp 4
(match 3
[(or) 1]
[_ 4]))
))