fix `defform[*]' handling of #:id and grammar production

In @defform*[#:id x1 [(qqq x1)]], for example, `#:id x1' needs to
calcel the default treatment of `x1' within `(qqq x1)' as
a metavariable, while treating `qqq' as a meta-variable.

original commit: 7d2914fc8a8f2647605da1d6699d0bc54685a5f3
This commit is contained in:
Matthew Flatt 2011-12-03 10:03:13 -07:00
parent ef02b4039c
commit c17636d399
2 changed files with 15 additions and 7 deletions

View File

@ -55,7 +55,7 @@
(syntax->list #'(lit ...)))
#'(with-togetherable-racket-variables
(lit ...)
([form spec] [form spec1] ...
([form [defined-id spec]] [form [defined-id spec1]] ...
[non-term (non-term-id non-term-form ...)] ...)
(*defforms defined-id-expr
'(spec spec1 ...)

View File

@ -75,12 +75,18 @@
(do-proc (car s-exp)))))])
(do-proc s-exp))]
[(form form/none form/maybe non-term)
(define skip-id (case (syntax-e kind)
[(form)
(syntax-case s-exp ()
[(defined-id actual-s-exp) (let ([id #'defined-id])
(and (identifier? id)
id))]
[_ #f])]
[else #f]))
(let loop ([form (case (syntax-e kind)
[(form) (if (identifier? s-exp)
null
(if (pair? (syntax-e s-exp))
(cdr (syntax-e s-exp))
null))]
[(form)
(syntax-case s-exp ()
[(defined-id actual-s-exp) #'actual-s-exp])]
[(form/none) s-exp]
[(form/maybe)
(syntax-case s-exp ()
@ -88,7 +94,9 @@
[(#t (id . form)) #'form])]
[(non-term) s-exp])])
(if (identifier? form)
(unless (or (eq? (syntax-e form) '...)
(unless (or (and skip-id
(free-identifier=? skip-id form))
(eq? (syntax-e form) '...)
(eq? (syntax-e form) '...+)
(eq? (syntax-e form) 'code:line)
(eq? (syntax-e form) 'code:blank)