curly tests

hide-top-rule-name
Matthew Butterick 7 years ago
parent 7bf128c0cd
commit 54fb498c63

@ -1,7 +1,8 @@
#lang brag
;; test the curly quantifier
start : a-rule | b-rule | c-rule | d-rule
start : a-rule | b-rule | c-rule | d-rule | e-rule
a-rule : "a"{2} ; exactly 2
b-rule : "b"{,2} ; up to 2
c-rule : "c"{2,} ; 2 or more
d-rule : "d"{2,3} ; 2 or 3
d-rule : "d"{2,3} ; 2 or 3
e-rule : "e"{} ; 0 or more

@ -21,3 +21,8 @@
(check-equal? (parse-to-datum "dd") '(start (d-rule "d" "d")))
(check-equal? (parse-to-datum "ddd") '(start (d-rule "d" "d" "d")))
(check-exn exn:fail:parsing? (λ () (parse-to-datum "dddd")))
(check-equal? (syntax->datum ((make-rule-parser e-rule) "")) '(e-rule)) ; to prevent ambiguity with b-rule while parsing empty string
(check-equal? (parse-to-datum "e") '(start (e-rule "e")))
(check-equal? (parse-to-datum "ee") '(start (e-rule "e" "e")))
(check-equal? (parse-to-datum "eee") '(start (e-rule "e" "e" "e")))
Loading…
Cancel
Save