Use dd-parse
to parse ...
patterns inside quasipatterns.
Related to racket/typed-racket#1055.
This commit is contained in:
parent
5058dc5a1a
commit
4a65dfb1aa
|
@ -451,5 +451,8 @@
|
||||||
other-plt-tests)
|
other-plt-tests)
|
||||||
'verbose))
|
'verbose))
|
||||||
|
|
||||||
(unless (= 0 (run-all-tests))
|
(module+ main
|
||||||
(error "Match Tests did not pass."))
|
(unless (= 0 (run-all-tests))
|
||||||
|
(error "Match Tests did not pass.")))
|
||||||
|
(module+ test
|
||||||
|
(run-all-tests))
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
;; parse stx as a quasi-pattern
|
;; parse stx as a quasi-pattern
|
||||||
;; parse parses unquote
|
;; parse parses unquote
|
||||||
(define (parse-quasi stx parse)
|
(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))
|
(define (pq s) (parse-quasi s parse))
|
||||||
(syntax-case stx (quasiquote unquote quote unquote-splicing)
|
(syntax-case stx (quasiquote unquote quote unquote-splicing)
|
||||||
[(unquote p) (parse #'p)]
|
[(unquote p) (parse #'p)]
|
||||||
|
@ -57,19 +59,7 @@
|
||||||
stx #'p)))]
|
stx #'p)))]
|
||||||
[(p dd . rest)
|
[(p dd . rest)
|
||||||
(ddk? #'dd)
|
(ddk? #'dd)
|
||||||
;; FIXME: parameterize dd-parse so that it can be used here
|
(dd-parse rearm+pq #'p #'dd #'rest #'list?)]
|
||||||
(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))]
|
|
||||||
[(a . b) (make-Pair (pq #'a) (pq #'b))]
|
[(a . b) (make-Pair (pq #'a) (pq #'b))]
|
||||||
;; prefab structs
|
;; prefab structs
|
||||||
[struct
|
[struct
|
||||||
|
|
Loading…
Reference in New Issue
Block a user