www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit fa35d7b77752db147e34b25a15d5f646aa7859f4
parent 4df442f59f12ca7bbb97cbfad22e3635f8dd9e59
Author: Jack Firth <jackhfirth@gmail.com>
Date:   Thu, 25 Aug 2016 11:51:27 -0700

Merge pull request #10 from jsmaniac/allow-arbitrary-expander-parameters

Allow arbitrary expander parameters, like (some-foo-expander x y . z).
Diffstat:
Mprivate/expanders.rkt | 4++--
Atest/test-call-with-dotted-last.rkt | 23+++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/private/expanders.rkt b/private/expanders.rkt @@ -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) diff --git a/test/test-call-with-dotted-last.rkt b/test/test-call-with-dotted-last.rkt @@ -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)) +\ No newline at end of file