racket/collects/r6rs/private/check-pattern.ss
Matthew Flatt 41ad955597 R6RS repairs (PRs 9361 and 9371)
svn: r9844
2008-05-15 13:23:16 +00:00

26 lines
757 B
Scheme

#lang scheme/base
(require (for-template (only-in scheme/base ...)))
(provide check-pat-ellipses)
(define ((check-pat-ellipses orig-stx) stx)
(let loop ([stx stx][car-ok? #f])
(cond
[(syntax? stx) (loop (syntax-e stx) car-ok?)]
[(pair? stx)
(if (and (not car-ok?)
(identifier? (car stx))
(free-identifier=? (car stx) (quote-syntax ...)))
(raise-syntax-error #f
"ellipsis without preceding form"
orig-stx
(car stx))
(begin (loop (car stx) #f)
(loop (cdr stx) #t)))]
[(vector? stx)
(for-each (lambda (stx) (loop stx #f)) (vector->list stx))]
[else (void)])))