Allow arbitrary expander parameters, like (some-foo-expander x y . z).
This commit is contained in:
parent
4df442f59f
commit
6f05f1ec92
|
@ -22,12 +22,12 @@
|
|||
(define (expander-stx? v)
|
||||
(and (syntax? v)
|
||||
(syntax-parse v
|
||||
[(id:id _ ...) (expander? (maybe-syntax-local-value #'id))]
|
||||
[(id:id . _) (expander? (maybe-syntax-local-value #'id))]
|
||||
[_ #f])))
|
||||
|
||||
(define (expander-stx->expander expander-stx)
|
||||
(syntax-parse expander-stx
|
||||
[(id:id _ ...) (maybe-syntax-local-value #'id)]))
|
||||
[(id:id . _) (maybe-syntax-local-value #'id)]))
|
||||
|
||||
(define (expander-stx-of-type? type v)
|
||||
(and (expander-stx? v)
|
||||
|
|
22
test/test-call-with-dotted-last.rkt
Normal file
22
test/test-call-with-dotted-last.rkt
Normal file
|
@ -0,0 +1,22 @@
|
|||
#lang racket
|
||||
|
||||
(require generic-syntax-expanders
|
||||
(for-syntax syntax/parse)
|
||||
rackunit)
|
||||
|
||||
(define-expander-type foo)
|
||||
|
||||
(define-foo-expander some-foo-expander
|
||||
(syntax-parser
|
||||
[(_ a:id b:id c:id . d:id) #'(d c b a)]))
|
||||
|
||||
(define-syntax (test-foo-expander stx)
|
||||
(syntax-parse stx
|
||||
[(_ e:expr)
|
||||
#`'#,(expand-all-foo-expanders #'e)]))
|
||||
|
||||
(test-equal?
|
||||
"Check that some-foo-expander accepts being called
|
||||
when it is the first item of a dotted list"
|
||||
(test-foo-expander (some-foo-expander x y z . t))
|
||||
'(t z y x))
|
Loading…
Reference in New Issue
Block a user