syntax/parse: add test for non-tilde pattern expander
This commit is contained in:
parent
4d703fa2e2
commit
2acb10a5da
|
@ -591,6 +591,33 @@
|
||||||
(+ x y z))))
|
(+ x y z))))
|
||||||
(syntax->datum #'(let ([x 1] [y 2] [z 3])
|
(syntax->datum #'(let ([x 1] [y 2] [z 3])
|
||||||
(+ x y z))))
|
(+ x y z))))
|
||||||
|
|
||||||
|
(define-syntax sep-comma ; test pattern expanders that don't begin with tilde
|
||||||
|
(pattern-expander
|
||||||
|
(lambda (stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(sep-comma pat)
|
||||||
|
(with-syntax ([ooo '...])
|
||||||
|
#'((~seq (~or (~and pat (~not ((~datum unquote) _))) ((~datum unquote) pat))
|
||||||
|
(~or (~peek-not _) (~peek ((~datum unquote) _))))
|
||||||
|
ooo))]))))
|
||||||
|
|
||||||
|
(define-splicing-syntax-class bindings2
|
||||||
|
[pattern (sep-comma [b:binding])
|
||||||
|
#:with (name ...) #'(b.name ...)
|
||||||
|
#:with (expr ...) #'(b.expr ...)])
|
||||||
|
|
||||||
|
(define (parse-my-let2 stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ bs:bindings2 body)
|
||||||
|
#'(let ([bs.name bs.expr] ...)
|
||||||
|
body)]))
|
||||||
|
|
||||||
|
(check-equal? (syntax->datum
|
||||||
|
(parse-my-let2 #'(my-let ([x = 1], [y = 2], [z = 3])
|
||||||
|
(+ x y z))))
|
||||||
|
(syntax->datum #'(let ([x 1] [y 2] [z 3])
|
||||||
|
(+ x y z))))
|
||||||
))
|
))
|
||||||
|
|
||||||
(test-case "this-syntax"
|
(test-case "this-syntax"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user