From 8a490208c570b2079b8f6b1f13e5469196bf68f0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 14 Mar 2015 09:49:07 -0600 Subject: [PATCH] fix `racketgrammar`, etc., treatment of `...` for new macro system The `(let ([... _]) _)` trick to hide the binding of `...` no longer works; explicitly strip the context of any `...`, instead. --- .../scribble/private/manual-scheme.rkt | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/scribble-lib/scribble/private/manual-scheme.rkt b/scribble-lib/scribble/private/manual-scheme.rkt index 26c70f34..3321dcdf 100644 --- a/scribble-lib/scribble/private/manual-scheme.rkt +++ b/scribble-lib/scribble/private/manual-scheme.rkt @@ -238,9 +238,34 @@ (define-syntax (id stx) (syntax-case stx () [(_ a) - (with-syntax ([ellipses (datum->syntax #'a '(... ...))]) - #'(let ([ellipses #f]) - (base a)))]))) + ;; Remove the context from any ellipsis in `a`: + (with-syntax ([a (strip-ellipsis-context #'a)]) + #'(base a))]))) + +(define-for-syntax (strip-ellipsis-context a) + (define a-ellipsis (datum->syntax a '...)) + (let loop ([a a]) + (cond + [(identifier? a) + (if (free-identifier=? a a-ellipsis #f) + (datum->syntax #f '... a a) + a)] + [(syntax? a) + (datum->syntax a (loop (syntax-e a)) a a)] + [(pair? a) + (cons (loop (car a)) + (loop (cdr a)))] + [(vector? a) + (list->vector + (map loop (vector->list a)))] + [(box? a) + (box (loop (unbox a)))] + [(prefab-struct-key a) + => (lambda (k) + (apply make-prefab-struct + k + (loop (cdr (vector->list (struct->vector a))))))] + [else a]))) (define-/form racketblock0/form racketblock0) (define-/form racketblock/form racketblock)