Fix match with (list-no-order p ..k) patterns

p ..k matches exactly k repetitions of p, but its documented
behavior is to match "k or more" repetitions. This fix implements
the documented behavior.

Fixes bug number 15122.
This commit is contained in:
Konrad Hinsen 2015-07-28 15:52:10 +02:00 committed by Sam Tobin-Hochstadt
parent 4f5d8da278
commit a47800686c
2 changed files with 21 additions and 2 deletions

View File

@ -202,6 +202,26 @@
[(list-no-order 1 2 3 rest ...) rest]
[_ 'no]))
(comp '(x y z)
(match '(1 x 2 y 3 z)
[(list-no-order 1 2 3 rest ..1) rest]
[_ 'no]))
(comp '(x y z)
(match '(1 x 2 y 3 z)
[(list-no-order 1 2 3 rest ..2) rest]
[_ 'no]))
(comp '(x y z)
(match '(1 x 2 y 3 z)
[(list-no-order 1 2 3 rest ..3) rest]
[_ 'no]))
(comp 'no
(match '(1 x 2 y 3 z)
[(list-no-order 1 2 3 rest ..4) rest]
[_ 'no]))
(comp
'yes
(match '(a (c d))

View File

@ -101,12 +101,11 @@
(ddk? #'dd)
(let* ([count (ddk? #'dd)]
[min (if (number? count) count #f)]
[max (if (number? count) count #f)]
[ps (syntax->list #'(p ...))])
(GSeq (cons (list (rearm+parse #'lp))
(for/list ([p ps]) (list (parse p))))
(cons min (map (lambda _ 1) ps))
(cons max (map (lambda _ 1) ps))
(cons #f (map (lambda _ 1) ps))
;; vars in lp are lists, vars elsewhere are not
(cons #f (map (lambda _ #t) ps))
(Null (Dummy (syntax/loc stx _)))