handle exact quantifier

pull/6/head
Matthew Butterick 7 years ago
parent 46ddd5cfd4
commit 83f16034b0

@ -162,12 +162,17 @@
(pattern-repeat (position->pos $1-start-pos) (pattern-repeat (position->pos $1-start-pos)
(position->pos $2-end-pos) (position->pos $2-end-pos)
1 #f $1)] 1 #f $1)]
[(regexp-match #px"^\\{(\\d+)?,?(\\d+)?\\}$" $2) ; "{min,max}" with both min & max optional [(regexp-match #px"^\\{(\\d+)?(,)?(\\d+)?\\}$" $2) ; "{min,max}" with both min & max optional
=> (λ (m) => (λ (m)
(match-define (list min-repeat max-repeat) (match-define (list min-repeat max-repeat)
(match m (match m
[(list _ min max) (list (if min (string->number min) 0) [(list _ min range? max) (let ([min (if min (string->number min) 0)])
(and max (string->number max)))])) (list
min
(cond
[(and range? max) (string->number max)]
[(and (not range?) (not max)) min] ; {3} -> {3,3}
[(not max) #f])))]))
(pattern-repeat (position->pos $1-start-pos) (pattern-repeat (position->pos $1-start-pos)
(position->pos $2-end-pos) (position->pos $2-end-pos)
min-repeat max-repeat $1))] min-repeat max-repeat $1))]

Loading…
Cancel
Save