improve template->pattern, used in syntax-lens
This commit is contained in:
parent
7274791b7d
commit
27806613c0
|
@ -53,10 +53,11 @@
|
||||||
[(a ...) (ormap (target-stx target-id) (syntax->list #'(a ...)))]
|
[(a ...) (ormap (target-stx target-id) (syntax->list #'(a ...)))]
|
||||||
[a (and (bound-identifier=? target-id #'a) #'a)]))
|
[a (and (bound-identifier=? target-id #'a) #'a)]))
|
||||||
|
|
||||||
(define template->pattern
|
(define (template->pattern stx)
|
||||||
(syntax-parser #:literals (_)
|
(syntax-parse stx
|
||||||
[(a ...) #`(#,@(stx-map template->pattern #'(a ...)))]
|
;; preserve lexical context, source location, and properties
|
||||||
[_ (generate-temporary)]
|
[(a ...) (datum->syntax stx (stx-map template->pattern #'(a ...)) stx stx)]
|
||||||
|
[(~literal _) (generate-temporary)]
|
||||||
[a #'a]))
|
[a #'a]))
|
||||||
|
|
||||||
(define ((template-rebuilder target-id) parse-pattern)
|
(define ((template-rebuilder target-id) parse-pattern)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user