From 7465aead4c5f5efe0562f2022da12cf6223f7c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 29 Sep 2016 17:21:30 +0200 Subject: [PATCH] Fixed {~^ power:nat} for the match expander (the . rest was missing) --- implementation.rkt | 4 +++- test/test-match.rkt | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/implementation.rkt b/implementation.rkt index 6974b0d..de157f8 100644 --- a/implementation.rkt +++ b/implementation.rkt @@ -285,6 +285,8 @@ (syntax-parser #:context context #:literals (^ * + - ∞ once) + [({~do (displayln this-syntax)} #:oops-nope) + #'trbgfdsctgbrfvdc] [() #'(list)] [rest:not-stx-pair @@ -335,7 +337,7 @@ #`(list-rest-ish [] base ellipsis #,(xl #'rest))] [(:base {~^ once} . rest) #`(list-rest-ish [] base #|no ellipsis|# #,(xl #'rest))] - [(:base {~^ power:nat}) + [(:base {~^ power:nat} . rest) #:with occurrences (gensym 'occurrences) #`(list-rest-ish [(? (λ (_) (= (length occurrences) power)))] (and occurrences base) ooo diff --git a/test/test-match.rkt b/test/test-match.rkt index 3260855..ae0b0d0 100644 --- a/test/test-match.rkt +++ b/test/test-match.rkt @@ -200,9 +200,9 @@ (void)) (test-begin - "{once}, {1} and a simple pattern variable" - (check-match '(a a a a a a a a) - [(xlist a1 ^ {once} a2 ^ {1} a3 a4 ^ *) - (list a4 a3 a2 a1)] - '((a a a a a) a (a) a)) - (void)) + "{once}, {1} and a simple pattern variable" + (check-match '(a a a a a a a a) + [(xlist a1 ^ {once} a2 ^ {1} a3 a4 ^ *) + (list a4 a3 a2 a1)] + '((a a a a a) a (a) a)) + (void))