syntax/parse: add test for non-tilde pattern expander

This commit is contained in:
AlexKnauth 2015-10-13 15:26:13 -04:00 committed by Ryan Culpepper
parent 4d703fa2e2
commit 2acb10a5da

View File

@ -591,6 +591,33 @@
(+ x y z))))
(syntax->datum #'(let ([x 1] [y 2] [z 3])
(+ 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"