correct behavior of blank curlies

hide-top-rule-name
Matthew Butterick 7 years ago
parent 10c399bfd7
commit b99869ca40

@ -168,18 +168,20 @@
[(list all min range? max) (let* ([min (if min (string->number min) 0)] [(list all min range? max) (let* ([min (if min (string->number min) 0)]
[max (cond [max (cond
[(and range? max) (string->number max)] [(and range? max) (string->number max)]
[(and (not range?) (not max)) min] ; {3} -> {3,3} [(and (not range?) (not max)) (if (zero? min)
[else #f])]) #f ; {} -> {0,}
(cons min max))]))] min))] ; {3} -> {3,3}
[else (raise-argument-error 'grammar-parse "unknown repetition operator" $2)])) [else #f])])
(pattern-repeat (position->pos $1-start-pos) (cons min max))]))]
[else (raise-argument-error 'grammar-parse "unknown repetition operator" $2)]))
(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
#f))] #f))]
[(atomic-pattern) [(atomic-pattern)
$1]] $1]]
[atomic-pattern [atomic-pattern
[(LIT) [(LIT)
(pattern-lit (position->pos $1-start-pos) (pattern-lit (position->pos $1-start-pos)
(position->pos $1-end-pos) (position->pos $1-end-pos)
@ -220,7 +222,7 @@
'splice))]]) 'splice))]])
(error (lambda (tok-ok? tok-name tok-value start-pos end-pos) (error (lambda (tok-ok? tok-name tok-value start-pos end-pos)
((current-parser-error-handler) tok-ok? tok-name tok-value (position->pos start-pos) (position->pos end-pos)))))) ((current-parser-error-handler) tok-ok? tok-name tok-value (position->pos start-pos) (position->pos end-pos))))))
;; relocate-pattern: pattern -> pattern ;; relocate-pattern: pattern -> pattern

Loading…
Cancel
Save