Use dd-parse to parse ... patterns inside quasipatterns.

Related to racket/typed-racket#1055.
This commit is contained in:
Sam Tobin-Hochstadt 2021-03-16 08:59:37 -04:00 committed by Sam Tobin-Hochstadt
parent 5058dc5a1a
commit 4a65dfb1aa
2 changed files with 8 additions and 15 deletions

View File

@ -451,5 +451,8 @@
other-plt-tests)
'verbose))
(module+ main
(unless (= 0 (run-all-tests))
(error "Match Tests did not pass."))
(error "Match Tests did not pass.")))
(module+ test
(run-all-tests))

View File

@ -42,6 +42,8 @@
;; parse stx as a quasi-pattern
;; parse parses unquote
(define (parse-quasi stx parse)
(define (rearm new-stx) (syntax-rearm new-stx stx))
(define (rearm+pq new-stx) (pq (rearm new-stx)))
(define (pq s) (parse-quasi s parse))
(syntax-case stx (quasiquote unquote quote unquote-splicing)
[(unquote p) (parse #'p)]
@ -57,19 +59,7 @@
stx #'p)))]
[(p dd . rest)
(ddk? #'dd)
;; FIXME: parameterize dd-parse so that it can be used here
(let* ([count (ddk? #'dd)]
[min (and (number? count) count)])
(make-GSeq
(parameterize ([match-...-nesting (add1 (match-...-nesting))])
(list (list (pq #'p))))
(list min)
;; no upper bound
(list #f)
;; patterns in p get bound to lists
(list #f)
(pq #'rest)
#f))]
(dd-parse rearm+pq #'p #'dd #'rest #'list?)]
[(a . b) (make-Pair (pq #'a) (pq #'b))]
;; prefab structs
[struct