;;; SPDX-FileCopyrightText: 2025 Sergei Egorov ;;; SPDX-License-Identifier: MIT (define (ssre->sre/opts s . o*) (if (pair? o*) (let* ((os (apply string-append (map symbol->string o*))) (s (string-append "(?" os ")" s))) (string-sre->sre s)) (string-sre->sre s))) (define *tests-run* 0) (define *tests-passed* 0) (define-syntax test (syntax-rules () ((test name expect expr) (test expect expr)) ((test expect expr) (begin (set! *tests-run* (+ *tests-run* 1)) (let ((display-str (lambda () (write *tests-run*) (display ". ") (write 'expr))) (res expr)) (display-str) (write-char #\space) (display (make-string 10 #\.)) (cond ((equal? res expect) (set! *tests-passed* (+ *tests-passed* 1)) (display " [PASS]\n")) (else (display " [FAIL]\n") (display "********** expected ") (write expect) (display " but got ") (write res) (newline)))))))) (define-syntax test-assert (syntax-rules () ((test-assert expr) (test #f (not expr))) ((test-assert name expr) (test name #f (not expr))))) (define-syntax test-equal (syntax-rules () ((test-equal res expr) (test res expr)) ((test-equal = expr ...) (if (string? =) (test = #t (equal? expr ...)) (test #t (= expr ...)))))) (define-syntax test-error (syntax-rules () ((test-error name expr) (test-error expr)) ((test-error expr) (guard (condition (else (set! *tests-run* (- *tests-run* 1)) (test 'expr 'expr))) (test ' expr))))) (define (test-end . name) (write *tests-passed*) (display " out of ") (write *tests-run*) (display " passed (") (if (> *tests-run* 0) (display (number->string (* (/ *tests-passed* *tests-run*) 100.0)))) (display "%)") (newline)) (define-syntax test-ssre (syntax-rules () ((test-ssre pat o* res) (test-equal 'res (apply ssre->sre/opts 'pat 'o*))))) ; add some random definitions to pass the tests (string-sre-definitions (string-sre-bind 'Any 'cset 'any (string-sre-bind 'Nd 'cset 'numeric (string-sre-bind 'vowel 'cset '(or #\a #\e #\i #\o #\u #\y #\w) (string-sre-bind 'Vowel 'cset '(or #\A #\E #\I #\O #\U #\Y #\W) (string-sre-bind 'L 'cset 'alpha (string-sre-bind 'Ll 'cset 'lower (string-sre-bind 'Lu 'cset 'upper (string-sre-definitions))))))))) (test-ssre "the quick brown fox" () (: #\t #\h #\e #\space #\q #\u #\i #\c #\k #\space #\b #\r #\o #\w #\n #\space #\f #\o #\x)) (test-ssre "a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" () (: (* #\a) #\a #\b (? #\c) #\x #\y (+ #\z) #\p #\q (= 3 #\r) #\a (>= 2 #\b) #\x (** 4 5 #\y) #\p (** 0 6 #\q) #\A (>= 0 #\B) #\z #\z)) (test-ssre "^(abc){1,2}zz" () (: bos (** 1 2 ($ (: #\a #\b #\c))) #\z #\z)) (test-ssre "^(b+?|a){1,2}?c" () (: bos (**? 1 2 ($ (or (**? 1 #f #\b) #\a))) #\c)) (test-ssre "^(b+|a){1,2}c" () (: bos (** 1 2 ($ (or (+ #\b) #\a))) #\c)) (test-ssre "^(ba|b*){1,2}?bc" () (: bos (**? 1 2 ($ (or (: #\b #\a) (* #\b)))) #\b #\c)) (test-ssre "^[ab\\]cde]" () (: bos (or #\a #\b #\] #\c #\d #\e))) (test-ssre "^[]cde]" () (: bos (or #\] #\c #\d #\e))) (test-ssre "^[^ab\\]cde]" () (: bos (~ (or #\a #\b #\] #\c #\d #\e)))) (test-ssre "^[^]cde]" () (: bos (~ (or #\] #\c #\d #\e)))) (test-ssre "^@" () (: bos #\@)) (test-ssre "^[0-9]+$" () (: bos (+ (char-range #\0 #\9)) eos)) (test-ssre "^.*nter" () (: bos (* nonl) #\n #\t #\e #\r)) (test-ssre "^xxx[0-9]+$" () (: bos #\x #\x #\x (+ (char-range #\0 #\9)) eos)) (test-ssre "^.+[0-9][0-9][0-9]$" () (: bos (+ nonl) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) eos)) (test-ssre "^.+?[0-9][0-9][0-9]$" () (: bos (**? 1 #f nonl) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) eos)) (test-ssre "^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" () (: bos ($ (+ (~ #\!))) #\! ($ (+ nonl)) #\= #\a #\p #\q #\u #\x #\z #\. #\i #\x #\r #\. #\z #\z #\z #\. #\a #\c #\. #\u #\k eos)) (test-ssre ":" () #\:) (test-ssre "([\\da-f:]+)$" () (: ($ (+ (or numeric (char-range #\a #\f) #\:))) eos)) (test-ssre "^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" () (: bos (* nonl) #\. ($ (** 1 3 numeric)) #\. ($ (** 1 3 numeric)) #\. ($ (** 1 3 numeric)) eos)) (test-ssre "^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" () (: bos ($ (+ numeric)) (+ space) #\I #\N (+ space) #\S #\O #\A (+ space) ($ (+ (~ space))) (+ space) ($ (+ (~ space))) (* space) #\( (* space) eos)) (test-ssre "^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" () (: bos (or (char-range #\a #\z) (char-range #\A #\Z) numeric) (* (or (char-range #\a #\z) (char-range #\A #\Z) numeric #\-)) (* ($ (: #\. (or (char-range #\a #\z) (char-range #\A #\Z) numeric) (* (or (char-range #\a #\z) (char-range #\A #\Z) numeric #\-))))) #\. eos)) (test-ssre "^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" () (: bos #\* #\. (char-range #\a #\z) (? ($ (: (* (or (char-range #\a #\z) #\- numeric)) (+ (or (char-range #\a #\z) numeric))))) (* ($ (: #\. (char-range #\a #\z) (? ($ (: (* (or (char-range #\a #\z) #\- numeric)) (+ (or (char-range #\a #\z) numeric)))))))) eos)) (test-ssre "^(?=ab(de))(abd)(e)" () (: bos (look-ahead (: #\a #\b ($ (: #\d #\e)))) ($ (: #\a #\b #\d)) ($ #\e))) (test-ssre "^(?!(ab)de|x)(abd)(f)" () (: bos (neg-look-ahead (or (: ($ (: #\a #\b)) #\d #\e) #\x)) ($ (: #\a #\b #\d)) ($ #\f))) (test-ssre "^(?=(ab(cd)))(ab)" () (: bos (look-ahead ($ (: #\a #\b ($ (: #\c #\d))))) ($ (: #\a #\b)))) (test-ssre "^[\\da-f](\\.[\\da-f])*$" () (: bos (or numeric (char-range #\a #\f)) (* ($ (: #\. (or numeric (char-range #\a #\f))))) eos)) (test-ssre "^\".*\"\\s*(;.*)?$" () (: bos #\" (* nonl) #\" (* space) (? ($ (: #\; (* nonl)))) eos)) (test-ssre "^$" () (: bos eos)) (test-ssre "^ a\\ b[c ]d $" (x) (: bos #\a #\space #\b (or #\c #\space) #\d eos)) (test-ssre "^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$" () (: bos ($ (: #\a ($ (: #\b ($ #\c))))) ($ (: #\d ($ (: #\e ($ #\f))))) ($ (: #\h ($ (: #\i ($ #\j))))) ($ (: #\k ($ (: #\l ($ #\m))))) eos)) (test-ssre "^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$" () (: bos (: #\a ($ (: #\b ($ #\c)))) (: #\d ($ (: #\e ($ #\f)))) (: #\h ($ (: #\i ($ #\j)))) (: #\k ($ (: #\l ($ #\m)))) eos)) (test-ssre "^[\\w][\\W][\\s][\\S][\\d][\\D]\\]" () (: bos (or alnum #\_) (~ (or alnum #\_)) space (~ space) numeric (~ numeric) #\])) (test-ssre "^[.^$|()*+?{,}]+" () (: bos (+ (or #\. #\^ #\$ #\| #\( #\) #\* #\+ #\? #\{ #\, #\})))) (test-ssre "^a*\\w" () (: bos (* #\a) (or alnum #\_))) (test-ssre "^a*?\\w" () (: bos (*? #\a) (or alnum #\_))) (test-ssre "^a+\\w" () (: bos (+ #\a) (or alnum #\_))) (test-ssre "^a+?\\w" () (: bos (**? 1 #f #\a) (or alnum #\_))) (test-ssre "^\\d{8}\\w{2,}" () (: bos (= 8 numeric) (>= 2 (or alnum #\_)))) (test-ssre "^[aeiou\\d]{4,5}$" () (: bos (** 4 5 (or #\a #\e #\i #\o #\u numeric)) eos)) (test-ssre "^[aeiou\\d]{4,5}?" () (: bos (**? 4 5 (or #\a #\e #\i #\o #\u numeric)))) (test-ssre "^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]" () (: bos #\F #\r #\o #\m (+ #\space) ($ (+ (~ #\space))) (+ #\space) (or (char-range #\a #\z) (char-range #\A #\Z)) (or (char-range #\a #\z) (char-range #\A #\Z)) (or (char-range #\a #\z) (char-range #\A #\Z)) (+ #\space) (or (char-range #\a #\z) (char-range #\A #\Z)) (or (char-range #\a #\z) (char-range #\A #\Z)) (or (char-range #\a #\z) (char-range #\A #\Z)) (+ #\space) (? (char-range #\0 #\9)) (char-range #\0 #\9) (+ #\space) (char-range #\0 #\9) (char-range #\0 #\9) #\: (char-range #\0 #\9) (char-range #\0 #\9))) (test-ssre "^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" () (: bos #\F #\r #\o #\m (+ space) (+ (~ space)) (+ space) (= 2 ($ (: (= 3 (or (char-range #\a #\z) (char-range #\A #\Z))) (+ space)))) (** 1 2 numeric) (+ space) numeric numeric #\: numeric numeric)) (test-ssre "^12.34" () (: bos #\1 #\2 nonl #\3 #\4)) (test-ssre "foo(?!bar)(.*)" () (: #\f #\o #\o (neg-look-ahead (: #\b #\a #\r)) ($ (* nonl)))) (test-ssre "(?:(?!foo)...|^.{0,2})bar(.*)" () (: (or (: (neg-look-ahead (: #\f #\o #\o)) nonl nonl nonl) (: bos (** 0 2 nonl))) #\b #\a #\r ($ (* nonl)))) (test-ssre "^(\\D*)(?=\\d)(?!123)" () (: bos ($ (* (~ numeric))) (look-ahead numeric) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "(?!^)abc" () (: (neg-look-ahead bos) #\a #\b #\c)) (test-ssre "(?=^)abc" () (: (look-ahead bos) #\a #\b #\c)) (test-ssre "^[ab]{1,3}(ab*|b)" () (: bos (** 1 3 (or #\a #\b)) ($ (or (: #\a (* #\b)) #\b)))) (test-ssre "^[ab]{1,3}?(ab*|b)" () (: bos (**? 1 3 (or #\a #\b)) ($ (or (: #\a (* #\b)) #\b)))) (test-ssre "^[ab]{1,3}?(ab*?|b)" () (: bos (**? 1 3 (or #\a #\b)) ($ (or (: #\a (*? #\b)) #\b)))) (test-ssre "^[ab]{1,3}(ab*?|b)" () (: bos (** 1 3 (or #\a #\b)) ($ (or (: #\a (*? #\b)) #\b)))) (test-ssre "ab{1,3}bc" () (: #\a (** 1 3 #\b) #\b #\c)) (test-ssre "([^.]*)\\.([^:]*):[T ]+(.*)" () (: ($ (* (~ #\.))) #\. ($ (* (~ #\:))) #\: (+ (or #\T #\space)) ($ (* nonl)))) (test-ssre "^[W-c]+$" () (: bos (+ (char-range #\W #\c)) eos)) (test-ssre "^[?-_]+$" () (: bos (+ (char-range #\? #\_)) eos)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "\\Aabc\\z" () (: bos #\a #\b #\c eos)) (test-ssre "\\A(.)*\\z" () (: bos (* ($ nonl)) eos)) (test-ssre "(?:b)|(?::+)" () (or #\b (+ #\:))) (test-ssre "[-az]+" () (+ (or #\- #\a #\z))) (test-ssre "[az-]+" () (+ (or #\a #\z #\-))) (test-ssre "[a\\-z]+" () (+ (or #\a #\- #\z))) (test-ssre "[a-z]+" () (+ (char-range #\a #\z))) (test-ssre "[\\d-]+" () (+ (or numeric #\-))) (test-ssre "\\\\" () #\\) (test-ssre "a{0}bc" () (: (= 0 #\a) #\b #\c)) (test-ssre "(a|(bc)){0,0}?xyz" () (: (**? 0 0 ($ (or #\a ($ (: #\b #\c))))) #\x #\y #\z)) (test-ssre "^([^a])([^b])([^c]*)([^d]{3,4})" () (: bos ($ (~ #\a)) ($ (~ #\b)) ($ (* (~ #\c))) ($ (** 3 4 (~ #\d))))) (test-ssre "[^a]" () (~ #\a)) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "[^k]$" () (: (~ #\k) eos)) (test-ssre "[^k]{2,3}$" () (: (** 2 3 (~ #\k)) eos)) (test-ssre "^\\d{8,}@.+[^k]$" () (: bos (>= 8 numeric) #\@ (+ nonl) (~ #\k) eos)) (test-ssre "[^a]" () (~ #\a)) (test-ssre "[^az]" () (~ (or #\a #\z))) (test-ssre "P[^*]TAIRE[^*]{1,6}?LL" () (: #\P (~ #\*) #\T #\A #\I #\R #\E (**? 1 6 (~ #\*)) #\L #\L)) (test-ssre "P[^*]TAIRE[^*]{1,}?LL" () (: #\P (~ #\*) #\T #\A #\I #\R #\E (**? 1 #f (~ #\*)) #\L #\L)) (test-ssre "(\\.\\d\\d[1-9]?)\\d+" () (: ($ (: #\. numeric numeric (? (char-range #\1 #\9)))) (+ numeric))) (test-ssre "(\\.\\d\\d((?=0)|\\d(?=\\d)))" () ($ (: #\. numeric numeric ($ (or (look-ahead #\0) (: numeric (look-ahead numeric))))))) (test-ssre "\\b(foo)\\s+(\\w+)" () (: (or bow eow) ($ (: #\f #\o #\o)) (+ space) ($ (+ (or alnum #\_))))) (test-ssre "foo(.*)bar" () (: #\f #\o #\o ($ (* nonl)) #\b #\a #\r)) (test-ssre "foo(.*?)bar" () (: #\f #\o #\o ($ (*? nonl)) #\b #\a #\r)) (test-ssre "(.*)(\\d*)" () (: ($ (* nonl)) ($ (* numeric)))) (test-ssre "(.*)(\\d+)" () (: ($ (* nonl)) ($ (+ numeric)))) (test-ssre "(.*?)(\\d*)" () (: ($ (*? nonl)) ($ (* numeric)))) (test-ssre "(.*?)(\\d+)" () (: ($ (*? nonl)) ($ (+ numeric)))) (test-ssre "(.*)(\\d+)$" () (: ($ (* nonl)) ($ (+ numeric)) eos)) (test-ssre "(.*?)(\\d+)$" () (: ($ (*? nonl)) ($ (+ numeric)) eos)) (test-ssre "(.*)\\b(\\d+)$" () (: ($ (* nonl)) (or bow eow) ($ (+ numeric)) eos)) (test-ssre "(.*\\D)(\\d+)$" () (: ($ (: (* nonl) (~ numeric))) ($ (+ numeric)) eos)) (test-ssre "^\\D*(?!123)" () (: bos (* (~ numeric)) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "^(\\D*)(?=\\d)(?!123)" () (: bos ($ (* (~ numeric))) (look-ahead numeric) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "^[W-]46\\]" () (: bos (or #\W #\-) #\4 #\6 #\])) (test-ssre "^[W-\\]46]" () (: bos (or (char-range #\W #\]) #\4 #\6))) (test-ssre "word (?:[a-zA-Z0-9]+ ){0,10}otherword" () (: #\w #\o #\r #\d #\space (** 0 10 (: (+ (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9))) #\space)) #\o #\t #\h #\e #\r #\w #\o #\r #\d)) (test-ssre "word (?:[a-zA-Z0-9]+ ){0,300}otherword" () (: #\w #\o #\r #\d #\space (** 0 300 (: (+ (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9))) #\space)) #\o #\t #\h #\e #\r #\w #\o #\r #\d)) (test-ssre "^(a){0,0}" () (: bos (= 0 ($ #\a)))) (test-ssre "^(a){0,1}" () (: bos (** 0 1 ($ #\a)))) (test-ssre "^(a){0,2}" () (: bos (** 0 2 ($ #\a)))) (test-ssre "^(a){0,3}" () (: bos (** 0 3 ($ #\a)))) (test-ssre "^(a){0,}" () (: bos (>= 0 ($ #\a)))) (test-ssre "^(a){1,1}" () (: bos (= 1 ($ #\a)))) (test-ssre "^(a){1,2}" () (: bos (** 1 2 ($ #\a)))) (test-ssre "^(a){1,3}" () (: bos (** 1 3 ($ #\a)))) (test-ssre "^(a){1,}" () (: bos (>= 1 ($ #\a)))) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".{0,}\\.gif" () (: (>= 0 nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre "(.*X|^B)" () ($ (or (: (* nonl) #\X) (: bos #\B)))) (test-ssre "^.*B" () (: bos (* nonl) #\B)) (test-ssre "(?m)^.*B" () (: bol (* nonl) #\B)) (test-ssre "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" () (: bos (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9))) (test-ssre "^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d" () (: bos numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric)) (test-ssre "^[\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d]" () (: bos numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric)) (test-ssre "^[abc]{12}" () (: bos (= 12 (or #\a #\b #\c)))) (test-ssre "^[a-c]{12}" () (: bos (= 12 (char-range #\a #\c)))) (test-ssre "^(a|b|c){12}" () (: bos (= 12 ($ (or #\a #\b #\c))))) (test-ssre "^[abcdefghijklmnopqrstuvwxy0123456789]" () (: bos (or #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))) (test-ssre "abcde{0,0}" () (: #\a #\b #\c #\d (= 0 #\e))) (test-ssre "ab[cd]{0,0}e" () (: #\a #\b (= 0 (or #\c #\d)) #\e)) (test-ssre "ab(c){0,0}d" () (: #\a #\b (= 0 ($ #\c)) #\d)) (test-ssre "a(b*)" () (: #\a ($ (* #\b)))) (test-ssre "ab\\d{0}e" () (: #\a #\b (= 0 numeric) #\e)) (test-ssre "\"([^\\\\\"]+|\\\\.)*\"" () (: #\" (* ($ (or (+ (~ (or #\\ #\"))) (: #\\ nonl)))) #\")) (test-ssre ".*?" () (*? nonl)) (test-ssre "\\b" () (or bow eow)) (test-ssre "\\b" () (or bow eow)) (test-ssre "a[^a]b" () (: #\a (~ #\a) #\b)) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "a[^a]b" () (: #\a (~ #\a) #\b)) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "^(b+?|a){1,2}?c" () (: bos (**? 1 2 ($ (or (**? 1 #f #\b) #\a))) #\c)) (test-ssre "^(b+|a){1,2}?c" () (: bos (**? 1 2 ($ (or (+ #\b) #\a))) #\c)) (test-ssre "(?!\\A)x" () (: (neg-look-ahead bos) #\x)) (test-ssre "(A|B)*?CD" () (: (*? ($ (or #\A #\B))) #\C #\D)) (test-ssre "(A|B)*CD" () (: (* ($ (or #\A #\B))) #\C #\D)) (test-ssre "(?= 0 #\b) #\b #\c)) (test-ssre "ab+bc" () (: #\a (+ #\b) #\b #\c)) (test-ssre "ab{1,}bc" () (: #\a (>= 1 #\b) #\b #\c)) (test-ssre "ab+bc" () (: #\a (+ #\b) #\b #\c)) (test-ssre "ab{1,}bc" () (: #\a (>= 1 #\b) #\b #\c)) (test-ssre "ab{1,3}bc" () (: #\a (** 1 3 #\b) #\b #\c)) (test-ssre "ab{3,4}bc" () (: #\a (** 3 4 #\b) #\b #\c)) (test-ssre "ab{4,5}bc" () (: #\a (** 4 5 #\b) #\b #\c)) (test-ssre "ab?bc" () (: #\a (? #\b) #\b #\c)) (test-ssre "ab{0,1}bc" () (: #\a (** 0 1 #\b) #\b #\c)) (test-ssre "ab?bc" () (: #\a (? #\b) #\b #\c)) (test-ssre "ab?c" () (: #\a (? #\b) #\c)) (test-ssre "ab{0,1}c" () (: #\a (** 0 1 #\b) #\c)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "^abc" () (: bos #\a #\b #\c)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "abc$" () (: #\a #\b #\c eos)) (test-ssre "^" () bos) (test-ssre "$" () eos) (test-ssre "a.c" () (: #\a nonl #\c)) (test-ssre "a.*c" () (: #\a (* nonl) #\c)) (test-ssre "a[bc]d" () (: #\a (or #\b #\c) #\d)) (test-ssre "a[b-d]e" () (: #\a (char-range #\b #\d) #\e)) (test-ssre "a[b-d]" () (: #\a (char-range #\b #\d))) (test-ssre "a[-b]" () (: #\a (or #\- #\b))) (test-ssre "a[b-]" () (: #\a (or #\b #\-))) (test-ssre "a\\]" () (: #\a #\])) (test-ssre "a[]]b" () (: #\a #\] #\b)) (test-ssre "a[^bc]d" () (: #\a (~ (or #\b #\c)) #\d)) (test-ssre "a[^-b]c" () (: #\a (~ (or #\- #\b)) #\c)) (test-ssre "a[^]b]c" () (: #\a (~ (or #\] #\b)) #\c)) (test-ssre "\\ba\\b" () (: (or bow eow) #\a (or bow eow))) (test-ssre "\\by\\b" () (: (or bow eow) #\y (or bow eow))) (test-ssre "\\Ba\\B" () (: nwb #\a nwb)) (test-ssre "\\By\\b" () (: nwb #\y (or bow eow))) (test-ssre "\\by\\B" () (: (or bow eow) #\y nwb)) (test-ssre "\\By\\B" () (: nwb #\y nwb)) (test-ssre "\\w" () (or alnum #\_)) (test-ssre "\\W" () (~ (or alnum #\_))) (test-ssre "a\\sb" () (: #\a space #\b)) (test-ssre "a\\Sb" () (: #\a (~ space) #\b)) (test-ssre "\\d" () numeric) (test-ssre "\\D" () (~ numeric)) (test-ssre "ab|cd" () (or (: #\a #\b) (: #\c #\d))) (test-ssre "()ef" () (: ($ (:)) #\e #\f)) (test-ssre "$b" () (: eos #\b)) (test-ssre "a\\(b" () (: #\a #\( #\b)) (test-ssre "a\\(*b" () (: #\a (* #\() #\b)) (test-ssre "a\\\\b" () (: #\a #\\ #\b)) (test-ssre "((a))" () ($ ($ #\a))) (test-ssre "(a)b(c)" () (: ($ #\a) #\b ($ #\c))) (test-ssre "a+b+c" () (: (+ #\a) (+ #\b) #\c)) (test-ssre "a{1,}b{1,}c" () (: (>= 1 #\a) (>= 1 #\b) #\c)) (test-ssre "a.+?c" () (: #\a (**? 1 #f nonl) #\c)) (test-ssre "(a+|b)*" () (* ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){0,}" () (>= 0 ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b)+" () (+ ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){1,}" () (>= 1 ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b)?" () (? ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){0,1}" () (** 0 1 ($ (or (+ #\a) #\b)))) (test-ssre "[^ab]*" () (* (~ (or #\a #\b)))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "a*" () (* #\a)) (test-ssre "([abc])*d" () (: (* ($ (or #\a #\b #\c))) #\d)) (test-ssre "([abc])*bcd" () (: (* ($ (or #\a #\b #\c))) #\b #\c #\d)) (test-ssre "a|b|c|d|e" () (or #\a #\b #\c #\d #\e)) (test-ssre "(a|b|c|d|e)f" () (: ($ (or #\a #\b #\c #\d #\e)) #\f)) (test-ssre "abcd*efg" () (: #\a #\b #\c (* #\d) #\e #\f #\g)) (test-ssre "ab*" () (: #\a (* #\b))) (test-ssre "(ab|cd)e" () (: ($ (or (: #\a #\b) (: #\c #\d))) #\e)) (test-ssre "[abhgefdc]ij" () (: (or #\a #\b #\h #\g #\e #\f #\d #\c) #\i #\j)) (test-ssre "^(ab|cd)e" () (: bos ($ (or (: #\a #\b) (: #\c #\d))) #\e)) (test-ssre "(abc|)ef" () (: ($ (or (: #\a #\b #\c) (:))) #\e #\f)) (test-ssre "(a|b)c*d" () (: ($ (or #\a #\b)) (* #\c) #\d)) (test-ssre "(ab|ab*)bc" () (: ($ (or (: #\a #\b) (: #\a (* #\b)))) #\b #\c)) (test-ssre "a([bc]*)c*" () (: #\a ($ (* (or #\b #\c))) (* #\c))) (test-ssre "a([bc]*)(c*d)" () (: #\a ($ (* (or #\b #\c))) ($ (: (* #\c) #\d)))) (test-ssre "a([bc]+)(c*d)" () (: #\a ($ (+ (or #\b #\c))) ($ (: (* #\c) #\d)))) (test-ssre "a([bc]*)(c+d)" () (: #\a ($ (* (or #\b #\c))) ($ (: (+ #\c) #\d)))) (test-ssre "a[bcd]*dcdcde" () (: #\a (* (or #\b #\c #\d)) #\d #\c #\d #\c #\d #\e)) (test-ssre "a[bcd]+dcdcde" () (: #\a (+ (or #\b #\c #\d)) #\d #\c #\d #\c #\d #\e)) (test-ssre "(ab|a)b*c" () (: ($ (or (: #\a #\b) #\a)) (* #\b) #\c)) (test-ssre "((a)(b)c)(d)" () (: ($ (: ($ #\a) ($ #\b) #\c)) ($ #\d))) (test-ssre "[a-zA-Z_][a-zA-Z0-9_]*" () (: (or (char-range #\a #\z) (char-range #\A #\Z) #\_) (* (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9) #\_)))) (test-ssre "^a(bc+|b[eh])g|.h$" () (or (: bos #\a ($ (or (: #\b (+ #\c)) (: #\b (or #\e #\h)))) #\g) (: nonl #\h eos))) (test-ssre "(bc+d$|ef*g.|h?i(j|k))" () ($ (or (: #\b (+ #\c) #\d eos) (: #\e (* #\f) #\g nonl) (: (? #\h) #\i ($ (or #\j #\k)))))) (test-ssre "((((((((((a))))))))))" () ($ ($ ($ ($ ($ ($ ($ ($ ($ ($ #\a))))))))))) (test-ssre "(((((((((a)))))))))" () ($ ($ ($ ($ ($ ($ ($ ($ ($ #\a)))))))))) (test-ssre "multiple words of text" () (: #\m #\u #\l #\t #\i #\p #\l #\e #\space #\w #\o #\r #\d #\s #\space #\o #\f #\space #\t #\e #\x #\t)) (test-ssre "multiple words" () (: #\m #\u #\l #\t #\i #\p #\l #\e #\space #\w #\o #\r #\d #\s)) (test-ssre "(.*)c(.*)" () (: ($ (* nonl)) #\c ($ (* nonl)))) (test-ssre "\\((.*), (.*)\\)" () (: #\( ($ (* nonl)) #\, #\space ($ (* nonl)) #\))) (test-ssre "[k]" () #\k) (test-ssre "abcd" () (: #\a #\b #\c #\d)) (test-ssre "a(bc)d" () (: #\a ($ (: #\b #\c)) #\d)) (test-ssre "a[-]?c" () (: #\a (? #\-) #\c)) (test-ssre "a(?!b)." () (: #\a (neg-look-ahead #\b) nonl)) (test-ssre "a(?=d)." () (: #\a (look-ahead #\d) nonl)) (test-ssre "a(?=c|d)." () (: #\a (look-ahead (or #\c #\d)) nonl)) (test-ssre "a(?:b|c|d)(.)" () (: #\a (or #\b #\c #\d) ($ nonl))) (test-ssre "a(?:b|c|d)*(.)" () (: #\a (* (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d)+?(.)" () (: #\a (**? 1 #f (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d)+(.)" () (: #\a (+ (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){2}(.)" () (: #\a (= 2 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){4,5}(.)" () (: #\a (** 4 5 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){4,5}?(.)" () (: #\a (**? 4 5 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){6,7}(.)" () (: #\a (** 6 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){6,7}?(.)" () (: #\a (**? 6 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,6}(.)" () (: #\a (** 5 6 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,6}?(.)" () (: #\a (**? 5 6 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,7}(.)" () (: #\a (** 5 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,7}?(.)" () (: #\a (**? 5 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|(c|e){1,2}?|d)+?(.)" () (: #\a (**? 1 #f (or #\b (**? 1 2 ($ (or #\c #\e))) #\d)) ($ nonl))) (test-ssre "^(.+)?B" () (: bos (? ($ (+ nonl))) #\B)) (test-ssre "^([^a-z])|(\\^)$" () (or (: bos ($ (~ (char-range #\a #\z)))) (: ($ #\^) eos))) (test-ssre "^[<>]&" () (: bos (or #\< #\>) #\&)) (test-ssre "(?<=a)b" () (: (look-behind #\a) #\b)) (test-ssre "(?a+)ab" () (: ($ (: #\> (+ #\a))) #\a #\b)) (test-ssre "b\\z" () (: #\b eos)) (test-ssre "(?<=\\d{3}(?!999))foo" () (: (look-behind (: (= 3 numeric) (neg-look-ahead (: #\9 #\9 #\9)))) #\f #\o #\o)) (test-ssre "(?<=(?!...999)\\d{3})foo" () (: (look-behind (: (neg-look-ahead (: nonl nonl nonl #\9 #\9 #\9)) (= 3 numeric))) #\f #\o #\o)) (test-ssre "(?<=\\d{3}(?!999)...)foo" () (: (look-behind (: (= 3 numeric) (neg-look-ahead (: #\9 #\9 #\9)) nonl nonl nonl)) #\f #\o #\o)) (test-ssre "(?<=\\d{3}...)(?= 0 #\b) (or alnum #\_))) (test-ssre "a*\\d*\\w" () (: (* #\a) (* numeric) (or alnum #\_))) (test-ssre "a*b *\\w" (x) (: (* #\a) (* #\b) (or alnum #\_))) (test-ssre "a* b *\\w" (x) (: (* #\a) (* #\b) (or alnum #\_))) (test-ssre "\\z(?= 2 ($ (** 2 3 #\a)))) #\a)) (test-ssre "(?=C)" () (look-ahead #\C)) (test-ssre "(?:a(? (?')|(?\")) |b(? (?')|(?\")) ) (\\k[a-z]+|[0-9]+)" () (: (or (: #\a (-> quote (or (: #\space (-> apostrophe #\')) (-> realquote #\"))) #\space) (: #\b (-> quote (or (: #\space (-> apostrophe #\')) (-> realquote #\"))) #\space)) #\space ($ (or (: (backref quote) (+ (char-range #\a #\z))) (+ (char-range #\0 #\9)))))) (test-ssre "^(a){2,}+(\\w)" () (: bos (+ (>= 2 ($ #\a))) ($ (or alnum #\_)))) (test-ssre "^(?:a){2,}+(\\w)" () (: bos (+ (>= 2 #\a)) ($ (or alnum #\_)))) (test-ssre "\\A.*?(a|bc)" () (: bos (*? nonl) ($ (or #\a (: #\b #\c))))) (test-ssre "\\A.*?(?:a|bc|d)" () (: bos (*? nonl) (or #\a (: #\b #\c) #\d))) (test-ssre "(?:.*?a)(?<=ba)" () (: (*? nonl) #\a (look-behind (: #\b #\a)))) (test-ssre "a(?=bc).|abd" () (or (: #\a (look-ahead (: #\b #\c)) nonl) (: #\a #\b #\d))) (test-ssre "\\A.*?(?:a|bc)" () (: bos (*? nonl) (or #\a (: #\b #\c)))) (test-ssre "^\\d*\\w{4}" () (: bos (* numeric) (= 4 (or alnum #\_)))) (test-ssre "^[^b]*\\w{4}" () (: bos (* (~ #\b)) (= 4 (or alnum #\_)))) (test-ssre "^a*\\w{4}" () (: bos (* #\a) (= 4 (or alnum #\_)))) (test-ssre "(?:(?foo)|(?bar))\\k" () (: (or (-> n (: #\f #\o #\o)) (-> n (: #\b #\a #\r))) (backref n))) (test-ssre "(?A)(?:(?foo)|(?bar))\\k" () (: (-> n #\A) (or (-> n (: #\f #\o #\o)) (-> n (: #\b #\a #\r))) (backref n))) (test-ssre "^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" () (: bos ($ (+ numeric)) (+ space) #\I #\N (+ space) #\S #\O #\A (+ space) ($ (+ (~ space))) (+ space) ($ (+ (~ space))) (* space) #\( (* space) eos)) (test-ssre "(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc" () (: (or #\x (or (+ ($ (or (: #\x #\x) (: #\y #\y)))) #\x #\x #\x #\x #\x) #\a #\a #\a) #\b #\c)) (test-ssre "\\sabc" () (: space #\a #\b #\c)) (test-ssre "Z*(|d*){216}" () (: (* #\Z) (= 216 ($ (or (:) (* #\d)))))) (test-ssre "(?<=a(B){0}c)X" () (: (look-behind (: #\a (= 0 ($ #\B)) #\c)) #\X)) (test-ssre "a+(?:|b)a" () (: (+ #\a) (or (:) #\b) #\a)) (test-ssre "X?(R||){3335}" () (: (? #\X) (= 3335 ($ (or #\R (:) (:)))))) (test-ssre "(?!(b))c|b" () (or (: (neg-look-ahead ($ #\b)) #\c) #\b)) (test-ssre "(?=(b))b|c" () (or (: (look-ahead ($ #\b)) #\b) #\c)) (test-ssre "<(?x:[a b])>" () (: #\< (or #\a #\space #\b) #\>)) (test-ssre "<(?:[a b])>" () (: #\< (or #\a #\space #\b) #\>)) (test-ssre "<(?xxx:[a b])>" () (: #\< (or #\a #\space #\b) #\>)) (test-ssre "<(?-x:[a b])>" () (: #\< (or #\a #\space #\b) #\>)) (test-ssre "[[:digit:]-]+" () (+ (or numeric #\-))) (test-ssre "(?<=(?=.)?)" () (look-behind (? (look-ahead nonl)))) (test-ssre "(?<=(?=.){4,5})" () (look-behind (** 4 5 (look-ahead nonl)))) (test-ssre "(?<=(?=.){4,5}x)" () (look-behind (: (** 4 5 (look-ahead nonl)) #\x))) (test-ssre " (? \\w+ )* \\. " () (: #\space #\space #\space (* (-> word (: #\space (+ (or alnum #\_)) #\space))) #\space #\space #\space #\space #\. #\space #\space #\space)) (test-ssre "(?<=(?=.(?<=x)))" () (look-behind (look-ahead (: nonl (look-behind #\x))))) (test-ssre "(?<=(?=(?<=a)))b" () (: (look-behind (look-ahead (look-behind #\a))) #\b)) (test-ssre "(?<=ab?c)..." () (: (look-behind (: #\a (? #\b) #\c)) nonl nonl nonl)) (test-ssre "(?<=PQR|ab?c)..." () (: (look-behind (or (: #\P #\Q #\R) (: #\a (? #\b) #\c))) nonl nonl nonl)) (test-ssre "(?<=ab?c|PQR)..." () (: (look-behind (or (: #\a (? #\b) #\c) (: #\P #\Q #\R))) nonl nonl nonl)) (test-ssre "(?<=PQ|ab?c)..." () (: (look-behind (or (: #\P #\Q) (: #\a (? #\b) #\c))) nonl nonl nonl)) (test-ssre "(?<=ab?c|PQ)..." () (: (look-behind (or (: #\a (? #\b) #\c) (: #\P #\Q))) nonl nonl nonl)) (test-ssre "(?<=a(b?c|d?e?e)f)X." () (: (look-behind (: #\a ($ (or (: (? #\b) #\c) (: (? #\d) (? #\e) #\e))) #\f)) #\X nonl)) (test-ssre "(?= 5 (char-range #\a #\z)) #\b) #\x)) (test-ssre "[a-z]{1,6}?s|x" () (or (: (**? 1 6 (char-range #\a #\z)) #\s) #\x)) (test-ssre "[@]" () #\@) (test-ssre "@" () #\@) (test-ssre "@@@xxx" () (: #\@ #\@ #\@ #\x #\x #\x)) (test-ssre "badutf" () (: #\b #\a #\d #\u #\t #\f)) (test-ssre "badutf" () (: #\b #\a #\d #\u #\t #\f)) (test-ssre "shortutf" () (: #\s #\h #\o #\r #\t #\u #\t #\f)) (test-ssre "anything" () (: #\a #\n #\y #\t #\h #\i #\n #\g)) (test-ssre "badutf" () (: #\b #\a #\d #\u #\t #\f)) (test-ssre "(?<=x)badutf" () (: (look-behind #\x) #\b #\a #\d #\u #\t #\f)) (test-ssre "(?<=xx)badutf" () (: (look-behind (: #\x #\x)) #\b #\a #\d #\u #\t #\f)) (test-ssre "(?<=xxxx)badutf" () (: (look-behind (: #\x #\x #\x #\x)) #\b #\a #\d #\u #\t #\f)) (test-ssre "X" () #\X) (test-ssre "a+" () (+ #\a)) (test-ssre "A" () #\A) (test-ssre "x" () #\x) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "X" () #\X) (test-ssre "(?<=.)X" () (: (look-behind nonl) #\X)) (test-ssre "a+" () (+ #\a)) (test-ssre "a" () #\a) (test-ssre "." () nonl) (test-ssre "s" () #\s) (test-ssre "[^s]" () (~ #\s)) (test-ssre "a(?:.)*?a" () (: #\a (*? nonl) #\a)) (test-ssre "(?<=pqr)abc(?=xyz)" () (: (look-behind (: #\p #\q #\r)) #\a #\b #\c (look-ahead (: #\x #\y #\z)))) (test-ssre "a\\b" () (: #\a (or bow eow))) (test-ssre "abc(?=abcde)(?=ab)" () (: #\a #\b #\c (look-ahead (: #\a #\b #\c #\d #\e)) (look-ahead (: #\a #\b)))) (test-ssre "(?<=abc)123" () (: (look-behind (: #\a #\b #\c)) #\1 #\2 #\3)) (test-ssre "\\babc\\b" () (: (or bow eow) #\a #\b #\c (or bow eow))) (test-ssre "(?<=abc)def" () (: (look-behind (: #\a #\b #\c)) #\d #\e #\f)) (test-ssre "abc(?<=bc)def" () (: #\a #\b #\c (look-behind (: #\b #\c)) #\d #\e #\f)) (test-ssre "(?<=ab)cdef" () (: (look-behind (: #\a #\b)) #\c #\d #\e #\f)) (test-ssre "b(?tom|bon)-\\k" () (: (-> A (or (: #\t #\o #\m) (: #\b #\o #\n))) #\- (backref A))) (test-ssre "Xa{2,4}b" () (: #\X (** 2 4 #\a) #\b)) (test-ssre "Xa{2,4}?b" () (: #\X (**? 2 4 #\a) #\b)) (test-ssre "Xa{2,4}+b" () (: #\X (+ (** 2 4 #\a)) #\b)) (test-ssre "X\\d{2,4}b" () (: #\X (** 2 4 numeric) #\b)) (test-ssre "X\\d{2,4}?b" () (: #\X (**? 2 4 numeric) #\b)) (test-ssre "X\\d{2,4}+b" () (: #\X (+ (** 2 4 numeric)) #\b)) (test-ssre "X\\D{2,4}b" () (: #\X (** 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}?b" () (: #\X (**? 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}+b" () (: #\X (+ (** 2 4 (~ numeric))) #\b)) (test-ssre "X[abc]{2,4}b" () (: #\X (** 2 4 (or #\a #\b #\c)) #\b)) (test-ssre "X[abc]{2,4}?b" () (: #\X (**? 2 4 (or #\a #\b #\c)) #\b)) (test-ssre "X[abc]{2,4}+b" () (: #\X (+ (** 2 4 (or #\a #\b #\c))) #\b)) (test-ssre "X[^a]{2,4}b" () (: #\X (** 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}?b" () (: #\X (**? 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}+b" () (: #\X (+ (** 2 4 (~ #\a))) #\b)) (test-ssre "Z(?!)" () (: #\Z (neg-look-ahead (:)))) (test-ssre "dog(sbody)?" () (: #\d #\o #\g (? ($ (: #\s #\b #\o #\d #\y))))) (test-ssre "dog(sbody)??" () (: #\d #\o #\g (?? ($ (: #\s #\b #\o #\d #\y))))) (test-ssre "dog|dogsbody" () (or (: #\d #\o #\g) (: #\d #\o #\g #\s #\b #\o #\d #\y))) (test-ssre "dogsbody|dog" () (or (: #\d #\o #\g #\s #\b #\o #\d #\y) (: #\d #\o #\g))) (test-ssre "\\bthe cat\\b" () (: (or bow eow) #\t #\h #\e #\space #\c #\a #\t (or bow eow))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "(?<=abc)123" () (: (look-behind (: #\a #\b #\c)) #\1 #\2 #\3)) (test-ssre "\\babc\\b" () (: (or bow eow) #\a #\b #\c (or bow eow))) (test-ssre "a?b?" () (: (? #\a) (? #\b))) (test-ssre "^a?b?" () (: bos (? #\a) (? #\b))) (test-ssre "abcd*" () (: #\a #\b #\c (* #\d))) (test-ssre "abc\\d*" () (: #\a #\b #\c (* numeric))) (test-ssre "abc[de]*" () (: #\a #\b #\c (* (or #\d #\e)))) (test-ssre "(?<=abc)def" () (: (look-behind (: #\a #\b #\c)) #\d #\e #\f)) (test-ssre "abc$" () (: #\a #\b #\c eos)) (test-ssre "abc$" () (: #\a #\b #\c eos)) (test-ssre "abc\\z" () (: #\a #\b #\c eos)) (test-ssre "abc\\b" () (: #\a #\b #\c (or bow eow))) (test-ssre "abc\\B" () (: #\a #\b #\c nwb)) (test-ssre ".+" () (+ nonl)) (test-ssre "(?<=(abc)+)X" () (: (look-behind (+ ($ (: #\a #\b #\c)))) #\X)) (test-ssre "(a)b|ac" () (or (: ($ #\a) #\b) (: #\a #\c))) (test-ssre "(a)(b)x|abc" () (or (: ($ #\a) ($ #\b) #\x) (: #\a #\b #\c))) (test-ssre "(?:(foo)|(bar)|(baz))X" () (: (or ($ (: #\f #\o #\o)) ($ (: #\b #\a #\r)) ($ (: #\b #\a #\z))) #\X)) (test-ssre "(ab)x|ab" () (or (: ($ (: #\a #\b)) #\x) (: #\a #\b))) (test-ssre "(((((a)))))" () ($ ($ ($ ($ ($ #\a)))))) (test-ssre "a*?b*?" () (: (*? #\a) (*? #\b))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "a(b)c" () (: #\a ($ #\b) #\c)) (test-ssre "(a)(b)|(c)" () (or (: ($ #\a) ($ #\b)) ($ #\c))) (test-ssre "(?a)|(?b)" () (or (-> A #\a) (-> A #\b))) (test-ssre "a(b)c(d)" () (: #\a ($ #\b) #\c ($ #\d))) (test-ssre "^abc" () (: bos #\a #\b #\c)) (test-ssre ".*\\d" () (: (* nonl) numeric)) (test-ssre "(abc)*" () (* ($ (: #\a #\b #\c)))) (test-ssre "^" () bos) (test-ssre "(?:ab)?(?:ab)(?:ab)" () (: (? (: #\a #\b)) (: #\a #\b) (: #\a #\b))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "(abcd)" () ($ (: #\a #\b #\c #\d))) (test-ssre "abcd" () (: #\a #\b #\c #\d)) (test-ssre "a(b)c" () (: #\a ($ #\b) #\c)) (test-ssre "a[[:punct:]b]" () (: #\a (or punct #\b))) (test-ssre "a[b[:punct:]]" () (: #\a (or #\b punct))) (test-ssre "0b 28 3f 2d 78 29 3a" () (: #\0 #\b #\space #\2 #\8 #\space #\3 #\f #\space #\2 #\d #\space #\7 #\8 #\space #\2 #\9 #\space #\3 #\a)) (test-ssre "a|(b)c" () (or #\a (: ($ #\b) #\c))) (test-ssre "efg" () (: #\e #\f #\g)) (test-ssre "eff" () (: #\e #\f #\f)) (test-ssre "effg" () (: #\e #\f #\f #\g)) (test-ssre "aaa" () (: #\a #\a #\a)) (test-ssre "(?)" () (: #\[ ($ (:)) (= 65535 #\]) (-> A (:)))) (test-ssre "(?<=(?=.(?<=x)))" () (look-behind (look-ahead (: nonl (look-behind #\x))))) (test-ssre "\\z" () eos) (test-ssre "\\Z" () (: (? #\newline) eos)) (test-ssre "(?![ab]).*" () (: (neg-look-ahead (or #\a #\b)) (* nonl))) (test-ssre "abcd" () (: #\a #\b #\c #\d)) (test-ssre "12345(?<=\\d{1,256})X" () (: #\1 #\2 #\3 #\4 #\5 (look-behind (** 1 256 numeric)) #\X)) (test-ssre "(?foo)|(?bar))\\k" () (: (or (-> n (: #\f #\o #\o)) (-> n (: #\b #\a #\r))) (backref n))) (test-ssre "a?b[]xy]*c" () (: (? #\a) #\b (* (or #\] #\x #\y)) #\c)) (test-ssre "f*" () (* #\f)) (test-ssre "foo\\*" () (: #\f #\o #\o #\*)) (test-ssre "foo\\*bar" () (: #\f #\o #\o #\* #\b #\a #\r)) (test-ssre "f\\\\oo" () (: #\f #\\ #\o #\o)) (test-ssre "[ten]" () (or #\t #\e #\n)) (test-ssre "t[a-g]n" () (: #\t (char-range #\a #\g) #\n)) (test-ssre "a[]]b" () (: #\a #\] #\b)) (test-ssre "a[]a-]b" () (: #\a (or #\] #\a #\-) #\b)) (test-ssre "a[]-]b" () (: #\a (or #\] #\-) #\b)) (test-ssre "a[]a-z]b" () (: #\a (or #\] (char-range #\a #\z)) #\b)) (test-ssre "\\]" () #\]) (test-ssre "t[!a-g]n" () (: #\t (or #\! (char-range #\a #\g)) #\n)) (test-ssre "A[+-0]B" () (: #\A (char-range #\+ #\0) #\B)) (test-ssre "a[--0]z" () (: #\a (char-range #\- #\0) #\z)) (test-ssre "a[[:digit:].]z" () (: #\a (or numeric #\.) #\z)) (test-ssre "A\\B\\\\C\\D" () (: #\A nwb #\\ #\C (~ numeric))) (test-ssre "a*b" () (: (* #\a) #\b)) (test-ssre "<[]bc]>" () (: #\< (or #\] #\b #\c) #\>)) (test-ssre "<[^]bc]>" () (: #\< (~ (or #\] #\b #\c)) #\>)) (test-ssre "a*b+c\\+[def](ab)\\(cd\\)" () (: (* #\a) (+ #\b) #\c #\+ (or #\d #\e #\f) ($ (: #\a #\b)) #\( #\c #\d #\))) (test-ssre "how.to how\\.to" () (: #\h #\o #\w nonl #\t #\o #\space #\h #\o #\w #\. #\t #\o)) (test-ssre "^how to \\^how to" () (: bos #\h #\o #\w #\space #\t #\o #\space #\^ #\h #\o #\w #\space #\t #\o)) (test-ssre "^b\\(c^d\\)\\(^e^f\\)" () (: bos #\b #\( #\c bos #\d #\) #\( bos #\e bos #\f #\))) (test-ssre "\\[()\\]{65535}()" () (: #\[ ($ (:)) (= 65535 #\]) ($ (:)))) (test-ssre "^A" () (: bos #\A)) (test-ssre "^\\w+" () (: bos (+ (or alnum #\_)))) (test-ssre "(.+)\\b(.+)" () (: ($ (+ nonl)) (or bow eow) ($ (+ nonl)))) (test-ssre "\\W+" () (+ (~ (or alnum #\_)))) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "a(.{3})b" () (: #\a ($ (= 3 nonl)) #\b)) (test-ssre "a(.*?)(.)" () (: #\a ($ (*? nonl)) ($ nonl))) (test-ssre "a(.*?)(.)" () (: #\a ($ (*? nonl)) ($ nonl))) (test-ssre "a(.*)(.)" () (: #\a ($ (* nonl)) ($ nonl))) (test-ssre "a(.*)(.)" () (: #\a ($ (* nonl)) ($ nonl))) (test-ssre "a(.)(.)" () (: #\a ($ nonl) ($ nonl))) (test-ssre "a(.)(.)" () (: #\a ($ nonl) ($ nonl))) (test-ssre "a(.?)(.)" () (: #\a ($ (? nonl)) ($ nonl))) (test-ssre "a(.?)(.)" () (: #\a ($ (? nonl)) ($ nonl))) (test-ssre "a(.??)(.)" () (: #\a ($ (?? nonl)) ($ nonl))) (test-ssre "a(.??)(.)" () (: #\a ($ (?? nonl)) ($ nonl))) (test-ssre "a(.{3})b" () (: #\a ($ (= 3 nonl)) #\b)) (test-ssre "a(.{3,})b" () (: #\a ($ (>= 3 nonl)) #\b)) (test-ssre "a(.{3,}?)b" () (: #\a ($ (**? 3 #f nonl)) #\b)) (test-ssre "a(.{3,5})b" () (: #\a ($ (** 3 5 nonl)) #\b)) (test-ssre "a(.{3,5}?)b" () (: #\a ($ (**? 3 5 nonl)) #\b)) (test-ssre "(?<=aXb)cd" () (: (look-behind (: #\a #\X #\b)) #\c #\d)) (test-ssre "(?<=(.))X" () (: (look-behind ($ nonl)) #\X)) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "^[^a]{2}" () (: bos (= 2 (~ #\a)))) (test-ssre "^[^a]{2,}" () (: bos (>= 2 (~ #\a)))) (test-ssre "^[^a]{2,}?" () (: bos (**? 2 #f (~ #\a)))) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "^[^a]{2}" () (: bos (= 2 (~ #\a)))) (test-ssre "^[^a]{2,}" () (: bos (>= 2 (~ #\a)))) (test-ssre "^[^a]{2,}?" () (: bos (**? 2 #f (~ #\a)))) (test-ssre "\\D*" () (* (~ numeric))) (test-ssre "\\D*" () (* (~ numeric))) (test-ssre "\\D" () (~ numeric)) (test-ssre ">\\S" () (: #\> (~ space))) (test-ssre "\\d" () numeric) (test-ssre "\\s" () space) (test-ssre "\\D+" () (+ (~ numeric))) (test-ssre "\\D{2,3}" () (** 2 3 (~ numeric))) (test-ssre "\\D{2,3}?" () (**? 2 3 (~ numeric))) (test-ssre "\\d+" () (+ numeric)) (test-ssre "\\d{2,3}" () (** 2 3 numeric)) (test-ssre "\\d{2,3}?" () (**? 2 3 numeric)) (test-ssre "\\S+" () (+ (~ space))) (test-ssre "\\S{2,3}" () (** 2 3 (~ space))) (test-ssre "\\S{2,3}?" () (**? 2 3 (~ space))) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre ">\\s{2,3}<" () (: #\> (** 2 3 space) #\<)) (test-ssre ">\\s{2,3}?<" () (: #\> (**? 2 3 space) #\<)) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\w{2,3}" () (** 2 3 (or alnum #\_))) (test-ssre "\\w{2,3}?" () (**? 2 3 (or alnum #\_))) (test-ssre "\\W+" () (+ (~ (or alnum #\_)))) (test-ssre "\\W{2,3}" () (** 2 3 (~ (or alnum #\_)))) (test-ssre "\\W{2,3}?" () (**? 2 3 (~ (or alnum #\_)))) (test-ssre "^[ac]*b" () (: bos (* (or #\a #\c)) #\b)) (test-ssre "^[^x]*b" () (: bos (* (~ #\x)) #\b)) (test-ssre "^[^x]*b" () (: bos (* (~ #\x)) #\b)) (test-ssre "^\\d*b" () (: bos (* numeric) #\b)) (test-ssre "(|a)" () ($ (or (:) #\a))) (test-ssre "\\S\\S" () (: (~ space) (~ space))) (test-ssre "\\S{2}" () (= 2 (~ space))) (test-ssre "\\W\\W" () (: (~ (or alnum #\_)) (~ (or alnum #\_)))) (test-ssre "\\W{2}" () (= 2 (~ (or alnum #\_)))) (test-ssre "\\S" () (~ space)) (test-ssre "\\D" () (~ numeric)) (test-ssre "\\W" () (~ (or alnum #\_))) (test-ssre ".[^\\S\n]." () (: nonl (~ (or (~ space) #\newline)) nonl)) (test-ssre "^[^d]*?$" () (: bos (*? (~ #\d)) eos)) (test-ssre "^[^d]*?$" () (: bos (*? (~ #\d)) eos)) (test-ssre "^[^d]*?$" () (: bos (*? (~ #\d)) eos)) (test-ssre "A*" () (* #\A)) (test-ssre "." () nonl) (test-ssre "^\\d*\\w{4}" () (: bos (* numeric) (= 4 (or alnum #\_)))) (test-ssre "^[^b]*\\w{4}" () (: bos (* (~ #\b)) (= 4 (or alnum #\_)))) (test-ssre "^[^b]*\\w{4}" () (: bos (* (~ #\b)) (= 4 (or alnum #\_)))) (test-ssre "^.\\B.\\B." () (: bos nonl nwb nonl nwb nonl)) (test-ssre "\\D+" () (+ (~ numeric))) (test-ssre "^\\w+" () (: bos (+ (or alnum #\_)))) (test-ssre "^\\d+" () (: bos (+ numeric))) (test-ssre "^>\\s+" () (: bos #\> (+ space))) (test-ssre "^A\\s+Z" () (: bos #\A (+ space) #\Z)) (test-ssre "[RST]+" () (+ (or #\R #\S #\T))) (test-ssre "[R-T]+" () (+ (char-range #\R #\T))) (test-ssre "[q-u]+" () (+ (char-range #\q #\u))) (test-ssre "^s?c" () (: bos (? #\s) #\c)) (test-ssre "[A-`]" () (char-range #\A #\`)) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\b.+?\\b" () (: (or bow eow) (**? 1 #f nonl) (or bow eow))) (test-ssre "caf\\B.+?\\B" () (: #\c #\a #\f nwb (**? 1 #f nonl) nwb)) (test-ssre "c3 b1" () (: #\c #\3 #\space #\b #\1)) (test-ssre "^A\\s+Z" () (: bos #\A (+ space) #\Z)) (test-ssre "\\W" () (~ (or alnum #\_))) (test-ssre "\\w" () (or alnum #\_)) (test-ssre "Xa{2,4}b" () (: #\X (** 2 4 #\a) #\b)) (test-ssre "Xa{2,4}?b" () (: #\X (**? 2 4 #\a) #\b)) (test-ssre "Xa{2,4}+b" () (: #\X (+ (** 2 4 #\a)) #\b)) (test-ssre "X\\d{2,4}b" () (: #\X (** 2 4 numeric) #\b)) (test-ssre "X\\d{2,4}?b" () (: #\X (**? 2 4 numeric) #\b)) (test-ssre "X\\d{2,4}+b" () (: #\X (+ (** 2 4 numeric)) #\b)) (test-ssre "X\\D{2,4}b" () (: #\X (** 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}?b" () (: #\X (**? 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}+b" () (: #\X (+ (** 2 4 (~ numeric))) #\b)) (test-ssre "X\\D{2,4}b" () (: #\X (** 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}?b" () (: #\X (**? 2 4 (~ numeric)) #\b)) (test-ssre "X\\D{2,4}+b" () (: #\X (+ (** 2 4 (~ numeric))) #\b)) (test-ssre "X[abc]{2,4}b" () (: #\X (** 2 4 (or #\a #\b #\c)) #\b)) (test-ssre "X[abc]{2,4}?b" () (: #\X (**? 2 4 (or #\a #\b #\c)) #\b)) (test-ssre "X[abc]{2,4}+b" () (: #\X (+ (** 2 4 (or #\a #\b #\c))) #\b)) (test-ssre "X[^a]{2,4}b" () (: #\X (** 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}?b" () (: #\X (**? 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}+b" () (: #\X (+ (** 2 4 (~ #\a))) #\b)) (test-ssre "X[^a]{2,4}b" () (: #\X (** 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}?b" () (: #\X (**? 2 4 (~ #\a)) #\b)) (test-ssre "X[^a]{2,4}+b" () (: #\X (+ (** 2 4 (~ #\a))) #\b)) (test-ssre "\\bthe cat\\b" () (: (or bow eow) #\t #\h #\e #\space #\c #\a #\t (or bow eow))) (test-ssre "abcd*" () (: #\a #\b #\c (* #\d))) (test-ssre "abcd*" () (: #\a #\b #\c (* #\d))) (test-ssre "abc\\d*" () (: #\a #\b #\c (* numeric))) (test-ssre "abc[de]*" () (: #\a #\b #\c (* (or #\d #\e)))) (test-ssre "X\\W{3}X" () (: #\X (= 3 (~ (or alnum #\_))) #\X)) (test-ssre "f.*" () (: #\f (* nonl))) (test-ssre "f.*" () (: #\f (* nonl))) (test-ssre "f.*" () (: #\f (* nonl))) (test-ssre "f.*" () (: #\f (* nonl))) (test-ssre "(?ss)|(?kk)) \\k" () (: (or (-> A (: #\s #\s)) (-> A (: #\k #\k))) #\space (backref A))) (test-ssre "(?:(?s)|(?k)) \\k{3,}!" () (: (or (-> A #\s) (-> A #\k)) #\space (>= 3 (backref A)) #\!)) (test-ssre "i" () #\i) (test-ssre "I" () #\I) (test-ssre "[i]" () #\i) (test-ssre "[^i]" () (~ #\i)) (test-ssre "[zi]" () (or #\z #\i)) (test-ssre "[iI]" () (or #\i #\I)) (test-ssre "\\d+" () (+ numeric)) (test-ssre "\\d+" () (+ numeric)) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\bABC\\b" () (: (or bow eow) #\A #\B #\C (or bow eow))) (test-ssre "\\bABC\\b" () (: (or bow eow) #\A #\B #\C (or bow eow))) (test-ssre "(?= 2 #\b) #\x (** 4 5 #\y) #\p (** 0 6 #\q) #\A (>= 0 #\B) #\z #\z)) (test-ssre "^(abc){1,2}zz" () (: bos (** 1 2 ($ (: #\a #\b #\c))) #\z #\z)) (test-ssre "^(b+?|a){1,2}?c" () (: bos (**? 1 2 ($ (or (**? 1 #f #\b) #\a))) #\c)) (test-ssre "^(b+|a){1,2}c" () (: bos (** 1 2 ($ (or (+ #\b) #\a))) #\c)) (test-ssre "^(b+|a){1,2}?bc" () (: bos (**? 1 2 ($ (or (+ #\b) #\a))) #\b #\c)) (test-ssre "^(b*|ba){1,2}?bc" () (: bos (**? 1 2 ($ (or (* #\b) (: #\b #\a)))) #\b #\c)) (test-ssre "^(ba|b*){1,2}?bc" () (: bos (**? 1 2 ($ (or (: #\b #\a) (* #\b)))) #\b #\c)) (test-ssre "^[ab\\]cde]" () (: bos (or #\a #\b #\] #\c #\d #\e))) (test-ssre "^[]cde]" () (: bos (or #\] #\c #\d #\e))) (test-ssre "^[^ab\\]cde]" () (: bos (~ (or #\a #\b #\] #\c #\d #\e)))) (test-ssre "^[^]cde]" () (: bos (~ (or #\] #\c #\d #\e)))) (test-ssre "^@" () (: bos #\@)) (test-ssre "^[0-9]+$" () (: bos (+ (char-range #\0 #\9)) eos)) (test-ssre "^.*nter" () (: bos (* nonl) #\n #\t #\e #\r)) (test-ssre "^xxx[0-9]+$" () (: bos #\x #\x #\x (+ (char-range #\0 #\9)) eos)) (test-ssre "^.+[0-9][0-9][0-9]$" () (: bos (+ nonl) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) eos)) (test-ssre "^.+?[0-9][0-9][0-9]$" () (: bos (**? 1 #f nonl) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) eos)) (test-ssre "^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" () (: bos ($ (+ (~ #\!))) #\! ($ (+ nonl)) #\= #\a #\p #\q #\u #\x #\z #\. #\i #\x #\r #\. #\z #\z #\z #\. #\a #\c #\. #\u #\k eos)) (test-ssre ":" () #\:) (test-ssre "^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" () (: bos (* nonl) #\. ($ (** 1 3 numeric)) #\. ($ (** 1 3 numeric)) #\. ($ (** 1 3 numeric)) eos)) (test-ssre "^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" () (: bos ($ (+ numeric)) (+ space) #\I #\N (+ space) #\S #\O #\A (+ space) ($ (+ (~ space))) (+ space) ($ (+ (~ space))) (* space) #\( (* space) eos)) (test-ssre "^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" () (: bos (or (char-range #\a #\z) (char-range #\A #\Z) numeric) (* (or (char-range #\a #\z) (char-range #\A #\Z) numeric #\-)) (* ($ (: #\. (or (char-range #\a #\z) (char-range #\A #\Z) numeric) (* (or (char-range #\a #\z) (char-range #\A #\Z) numeric #\-))))) #\. eos)) (test-ssre "^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" () (: bos #\* #\. (char-range #\a #\z) (? ($ (: (* (or (char-range #\a #\z) #\- numeric)) (+ (or (char-range #\a #\z) numeric))))) (* ($ (: #\. (char-range #\a #\z) (? ($ (: (* (or (char-range #\a #\z) #\- numeric)) (+ (or (char-range #\a #\z) numeric)))))))) eos)) (test-ssre "^(?=ab(de))(abd)(e)" () (: bos (look-ahead (: #\a #\b ($ (: #\d #\e)))) ($ (: #\a #\b #\d)) ($ #\e))) (test-ssre "^(?!(ab)de|x)(abd)(f)" () (: bos (neg-look-ahead (or (: ($ (: #\a #\b)) #\d #\e) #\x)) ($ (: #\a #\b #\d)) ($ #\f))) (test-ssre "^(?=(ab(cd)))(ab)" () (: bos (look-ahead ($ (: #\a #\b ($ (: #\c #\d))))) ($ (: #\a #\b)))) (test-ssre "^$" () (: bos eos)) (test-ssre "^ a\\ b[c ]d $" (x) (: bos #\a #\space #\b (or #\c #\space) #\d eos)) (test-ssre "^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$" () (: bos ($ (: #\a ($ (: #\b ($ #\c))))) ($ (: #\d ($ (: #\e ($ #\f))))) ($ (: #\h ($ (: #\i ($ #\j))))) ($ (: #\k ($ (: #\l ($ #\m))))) eos)) (test-ssre "^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$" () (: bos (: #\a ($ (: #\b ($ #\c)))) (: #\d ($ (: #\e ($ #\f)))) (: #\h ($ (: #\i ($ #\j)))) (: #\k ($ (: #\l ($ #\m)))) eos)) (test-ssre "^[.^$|()*+?{,}]+" () (: bos (+ (or #\. #\^ #\$ #\| #\( #\) #\* #\+ #\? #\{ #\, #\})))) (test-ssre "^a*\\w" () (: bos (* #\a) (or alnum #\_))) (test-ssre "^a*?\\w" () (: bos (*? #\a) (or alnum #\_))) (test-ssre "^a+\\w" () (: bos (+ #\a) (or alnum #\_))) (test-ssre "^a+?\\w" () (: bos (**? 1 #f #\a) (or alnum #\_))) (test-ssre "^\\d{8}\\w{2,}" () (: bos (= 8 numeric) (>= 2 (or alnum #\_)))) (test-ssre "^[aeiou\\d]{4,5}$" () (: bos (** 4 5 (or #\a #\e #\i #\o #\u numeric)) eos)) (test-ssre "^[aeiou\\d]{4,5}?" () (: bos (**? 4 5 (or #\a #\e #\i #\o #\u numeric)))) (test-ssre "^12.34" () (: bos #\1 #\2 nonl #\3 #\4)) (test-ssre "foo(?!bar)(.*)" () (: #\f #\o #\o (neg-look-ahead (: #\b #\a #\r)) ($ (* nonl)))) (test-ssre "(?:(?!foo)...|^.{0,2})bar(.*)" () (: (or (: (neg-look-ahead (: #\f #\o #\o)) nonl nonl nonl) (: bos (** 0 2 nonl))) #\b #\a #\r ($ (* nonl)))) (test-ssre "^(\\D*)(?=\\d)(?!123)" () (: bos ($ (* (~ numeric))) (look-ahead numeric) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "(?!^)abc" () (: (neg-look-ahead bos) #\a #\b #\c)) (test-ssre "(?=^)abc" () (: (look-ahead bos) #\a #\b #\c)) (test-ssre "ab{1,3}bc" () (: #\a (** 1 3 #\b) #\b #\c)) (test-ssre "([^.]*)\\.([^:]*):[T ]+(.*)" () (: ($ (* (~ #\.))) #\. ($ (* (~ #\:))) #\: (+ (or #\T #\space)) ($ (* nonl)))) (test-ssre "^[W-c]+$" () (: bos (+ (char-range #\W #\c)) eos)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "\\Aabc\\Z" () (: bos #\a #\b #\c (: (? #\newline) eos))) (test-ssre "\\A(.)*\\Z" () (: bos (* ($ nonl)) (: (? #\newline) eos))) (test-ssre "(?:b)|(?::+)" () (or #\b (+ #\:))) (test-ssre "[-az]+" () (+ (or #\- #\a #\z))) (test-ssre "[az-]+" () (+ (or #\a #\z #\-))) (test-ssre "[a\\-z]+" () (+ (or #\a #\- #\z))) (test-ssre "[a-z]+" () (+ (char-range #\a #\z))) (test-ssre "[\\d-]+" () (+ (or numeric #\-))) (test-ssre "abc$" () (: #\a #\b #\c eos)) (test-ssre "a{0}bc" () (: (= 0 #\a) #\b #\c)) (test-ssre "(a|(bc)){0,0}?xyz" () (: (**? 0 0 ($ (or #\a ($ (: #\b #\c))))) #\x #\y #\z)) (test-ssre "[^a]" () (~ #\a)) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "[^k]$" () (: (~ #\k) eos)) (test-ssre "[^k]{2,3}$" () (: (** 2 3 (~ #\k)) eos)) (test-ssre "^\\d{8,}@.+[^k]$" () (: bos (>= 8 numeric) #\@ (+ nonl) (~ #\k) eos)) (test-ssre "[^a]" () (~ #\a)) (test-ssre "[^az]" () (~ (or #\a #\z))) (test-ssre "P[^*]TAIRE[^*]{1,6}?LL" () (: #\P (~ #\*) #\T #\A #\I #\R #\E (**? 1 6 (~ #\*)) #\L #\L)) (test-ssre "P[^*]TAIRE[^*]{1,}?LL" () (: #\P (~ #\*) #\T #\A #\I #\R #\E (**? 1 #f (~ #\*)) #\L #\L)) (test-ssre "(\\.\\d\\d[1-9]?)\\d+" () (: ($ (: #\. numeric numeric (? (char-range #\1 #\9)))) (+ numeric))) (test-ssre "(\\.\\d\\d((?=0)|\\d(?=\\d)))" () ($ (: #\. numeric numeric ($ (or (look-ahead #\0) (: numeric (look-ahead numeric))))))) (test-ssre "foo(.*)bar" () (: #\f #\o #\o ($ (* nonl)) #\b #\a #\r)) (test-ssre "foo(.*?)bar" () (: #\f #\o #\o ($ (*? nonl)) #\b #\a #\r)) (test-ssre "(.*)(\\d+)" () (: ($ (* nonl)) ($ (+ numeric)))) (test-ssre "(.*?)(\\d+)" () (: ($ (*? nonl)) ($ (+ numeric)))) (test-ssre "(.*)(\\d+)$" () (: ($ (* nonl)) ($ (+ numeric)) eos)) (test-ssre "(.*?)(\\d+)$" () (: ($ (*? nonl)) ($ (+ numeric)) eos)) (test-ssre "(.*)\\b(\\d+)$" () (: ($ (* nonl)) (or bow eow) ($ (+ numeric)) eos)) (test-ssre "(.*\\D)(\\d+)$" () (: ($ (: (* nonl) (~ numeric))) ($ (+ numeric)) eos)) (test-ssre "^\\D*(?!123)" () (: bos (* (~ numeric)) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "^(\\D*)(?=\\d)(?!123)" () (: bos ($ (* (~ numeric))) (look-ahead numeric) (neg-look-ahead (: #\1 #\2 #\3)))) (test-ssre "^[W-\\]46]" () (: bos (or (char-range #\W #\]) #\4 #\6))) (test-ssre "word (?:[a-zA-Z0-9]+ ){0,10}otherword" () (: #\w #\o #\r #\d #\space (** 0 10 (: (+ (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9))) #\space)) #\o #\t #\h #\e #\r #\w #\o #\r #\d)) (test-ssre "word (?:[a-zA-Z0-9]+ ){0,300}otherword" () (: #\w #\o #\r #\d #\space (** 0 300 (: (+ (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9))) #\space)) #\o #\t #\h #\e #\r #\w #\o #\r #\d)) (test-ssre "^(a){0,0}" () (: bos (= 0 ($ #\a)))) (test-ssre "^(a){0,1}" () (: bos (** 0 1 ($ #\a)))) (test-ssre "^(a){0,2}" () (: bos (** 0 2 ($ #\a)))) (test-ssre "^(a){0,3}" () (: bos (** 0 3 ($ #\a)))) (test-ssre "^(a){0,}" () (: bos (>= 0 ($ #\a)))) (test-ssre "^(a){1,1}" () (: bos (= 1 ($ #\a)))) (test-ssre "^(a){1,2}" () (: bos (** 1 2 ($ #\a)))) (test-ssre "^(a){1,3}" () (: bos (** 1 3 ($ #\a)))) (test-ssre "^(a){1,}" () (: bos (>= 1 ($ #\a)))) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".{0,}\\.gif" () (: (>= 0 nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*\\.gif" () (: (* nonl) #\. #\g #\i #\f)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre ".*$" () (: (* nonl) eos)) (test-ssre "(.*X|^B)" () ($ (or (: (* nonl) #\X) (: bos #\B)))) (test-ssre "(.*X|^B)" () ($ (or (: (* nonl) #\X) (: bos #\B)))) (test-ssre "(.*X|^B)" () ($ (or (: (* nonl) #\X) (: bos #\B)))) (test-ssre "(.*X|^B)" () ($ (or (: (* nonl) #\X) (: bos #\B)))) (test-ssre "^.*B" () (: bos (* nonl) #\B)) (test-ssre "(?m)^.*B" () (: bol (* nonl) #\B)) (test-ssre "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" () (: bos (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9) (char-range #\0 #\9))) (test-ssre "^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d" () (: bos numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric)) (test-ssre "^[\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d]" () (: bos numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric numeric)) (test-ssre "^[abc]{12}" () (: bos (= 12 (or #\a #\b #\c)))) (test-ssre "^[a-c]{12}" () (: bos (= 12 (char-range #\a #\c)))) (test-ssre "^(a|b|c){12}" () (: bos (= 12 ($ (or #\a #\b #\c))))) (test-ssre "^[abcdefghijklmnopqrstuvwxy0123456789]" () (: bos (or #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))) (test-ssre "abcde{0,0}" () (: #\a #\b #\c #\d (= 0 #\e))) (test-ssre "ab[cd]{0,0}e" () (: #\a #\b (= 0 (or #\c #\d)) #\e)) (test-ssre "ab(c){0,0}d" () (: #\a #\b (= 0 ($ #\c)) #\d)) (test-ssre "a(b*)" () (: #\a ($ (* #\b)))) (test-ssre "ab\\d{0}e" () (: #\a #\b (= 0 numeric) #\e)) (test-ssre "\"([^\\\\\"]+|\\\\.)*\"" () (: #\" (* ($ (or (+ (~ (or #\\ #\"))) (: #\\ nonl)))) #\")) (test-ssre ".*?" () (*? nonl)) (test-ssre "\\b" () (or bow eow)) (test-ssre "\\b" () (or bow eow)) (test-ssre "a[^a]b" () (: #\a (~ #\a) #\b)) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "a[^a]b" () (: #\a (~ #\a) #\b)) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "^(b+?|a){1,2}?c" () (: bos (**? 1 2 ($ (or (**? 1 #f #\b) #\a))) #\c)) (test-ssre "^(b+|a){1,2}?c" () (: bos (**? 1 2 ($ (or (+ #\b) #\a))) #\c)) (test-ssre "(?!\\A)x" () (: (neg-look-ahead bos) #\x)) (test-ssre "(A|B)*CD" () (: (* ($ (or #\A #\B))) #\C #\D)) (test-ssre "(?= 0 #\b) #\b #\c)) (test-ssre "ab+bc" () (: #\a (+ #\b) #\b #\c)) (test-ssre "ab+bc" () (: #\a (+ #\b) #\b #\c)) (test-ssre "ab{1,}bc" () (: #\a (>= 1 #\b) #\b #\c)) (test-ssre "ab{1,3}bc" () (: #\a (** 1 3 #\b) #\b #\c)) (test-ssre "ab{3,4}bc" () (: #\a (** 3 4 #\b) #\b #\c)) (test-ssre "ab{4,5}bc" () (: #\a (** 4 5 #\b) #\b #\c)) (test-ssre "ab?bc" () (: #\a (? #\b) #\b #\c)) (test-ssre "ab{0,1}bc" () (: #\a (** 0 1 #\b) #\b #\c)) (test-ssre "ab?bc" () (: #\a (? #\b) #\b #\c)) (test-ssre "ab?c" () (: #\a (? #\b) #\c)) (test-ssre "ab{0,1}c" () (: #\a (** 0 1 #\b) #\c)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "^abc" () (: bos #\a #\b #\c)) (test-ssre "^abc$" () (: bos #\a #\b #\c eos)) (test-ssre "abc$" () (: #\a #\b #\c eos)) (test-ssre "^" () bos) (test-ssre "$" () eos) (test-ssre "a.c" () (: #\a nonl #\c)) (test-ssre "a.*c" () (: #\a (* nonl) #\c)) (test-ssre "a[bc]d" () (: #\a (or #\b #\c) #\d)) (test-ssre "a[b-d]e" () (: #\a (char-range #\b #\d) #\e)) (test-ssre "a[b-d]" () (: #\a (char-range #\b #\d))) (test-ssre "a[-b]" () (: #\a (or #\- #\b))) (test-ssre "a[b-]" () (: #\a (or #\b #\-))) (test-ssre "a[]]b" () (: #\a #\] #\b)) (test-ssre "a[^bc]d" () (: #\a (~ (or #\b #\c)) #\d)) (test-ssre "a[^-b]c" () (: #\a (~ (or #\- #\b)) #\c)) (test-ssre "a[^]b]c" () (: #\a (~ (or #\] #\b)) #\c)) (test-ssre "\\ba\\b" () (: (or bow eow) #\a (or bow eow))) (test-ssre "\\by\\b" () (: (or bow eow) #\y (or bow eow))) (test-ssre "\\Ba\\B" () (: nwb #\a nwb)) (test-ssre "\\By\\b" () (: nwb #\y (or bow eow))) (test-ssre "\\by\\B" () (: (or bow eow) #\y nwb)) (test-ssre "\\By\\B" () (: nwb #\y nwb)) (test-ssre "\\w" () (or alnum #\_)) (test-ssre "\\W" () (~ (or alnum #\_))) (test-ssre "a\\sb" () (: #\a space #\b)) (test-ssre "a\\Sb" () (: #\a (~ space) #\b)) (test-ssre "\\d" () numeric) (test-ssre "\\D" () (~ numeric)) (test-ssre "ab|cd" () (or (: #\a #\b) (: #\c #\d))) (test-ssre "()ef" () (: ($ (:)) #\e #\f)) (test-ssre "$b" () (: eos #\b)) (test-ssre "a\\(b" () (: #\a #\( #\b)) (test-ssre "a\\(*b" () (: #\a (* #\() #\b)) (test-ssre "a\\\\b" () (: #\a #\\ #\b)) (test-ssre "((a))" () ($ ($ #\a))) (test-ssre "(a)b(c)" () (: ($ #\a) #\b ($ #\c))) (test-ssre "a+b+c" () (: (+ #\a) (+ #\b) #\c)) (test-ssre "a{1,}b{1,}c" () (: (>= 1 #\a) (>= 1 #\b) #\c)) (test-ssre "a.+?c" () (: #\a (**? 1 #f nonl) #\c)) (test-ssre "(a+|b)*" () (* ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){0,}" () (>= 0 ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b)+" () (+ ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){1,}" () (>= 1 ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b)?" () (? ($ (or (+ #\a) #\b)))) (test-ssre "(a+|b){0,1}" () (** 0 1 ($ (or (+ #\a) #\b)))) (test-ssre "[^ab]*" () (* (~ (or #\a #\b)))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "a*" () (* #\a)) (test-ssre "([abc])*d" () (: (* ($ (or #\a #\b #\c))) #\d)) (test-ssre "([abc])*bcd" () (: (* ($ (or #\a #\b #\c))) #\b #\c #\d)) (test-ssre "a|b|c|d|e" () (or #\a #\b #\c #\d #\e)) (test-ssre "(a|b|c|d|e)f" () (: ($ (or #\a #\b #\c #\d #\e)) #\f)) (test-ssre "abcd*efg" () (: #\a #\b #\c (* #\d) #\e #\f #\g)) (test-ssre "ab*" () (: #\a (* #\b))) (test-ssre "(ab|cd)e" () (: ($ (or (: #\a #\b) (: #\c #\d))) #\e)) (test-ssre "[abhgefdc]ij" () (: (or #\a #\b #\h #\g #\e #\f #\d #\c) #\i #\j)) (test-ssre "^(ab|cd)e" () (: bos ($ (or (: #\a #\b) (: #\c #\d))) #\e)) (test-ssre "(abc|)ef" () (: ($ (or (: #\a #\b #\c) (:))) #\e #\f)) (test-ssre "(a|b)c*d" () (: ($ (or #\a #\b)) (* #\c) #\d)) (test-ssre "(ab|ab*)bc" () (: ($ (or (: #\a #\b) (: #\a (* #\b)))) #\b #\c)) (test-ssre "a([bc]*)c*" () (: #\a ($ (* (or #\b #\c))) (* #\c))) (test-ssre "a([bc]*)(c*d)" () (: #\a ($ (* (or #\b #\c))) ($ (: (* #\c) #\d)))) (test-ssre "a([bc]+)(c*d)" () (: #\a ($ (+ (or #\b #\c))) ($ (: (* #\c) #\d)))) (test-ssre "a([bc]*)(c+d)" () (: #\a ($ (* (or #\b #\c))) ($ (: (+ #\c) #\d)))) (test-ssre "a[bcd]*dcdcde" () (: #\a (* (or #\b #\c #\d)) #\d #\c #\d #\c #\d #\e)) (test-ssre "a[bcd]+dcdcde" () (: #\a (+ (or #\b #\c #\d)) #\d #\c #\d #\c #\d #\e)) (test-ssre "(ab|a)b*c" () (: ($ (or (: #\a #\b) #\a)) (* #\b) #\c)) (test-ssre "((a)(b)c)(d)" () (: ($ (: ($ #\a) ($ #\b) #\c)) ($ #\d))) (test-ssre "[a-zA-Z_][a-zA-Z0-9_]*" () (: (or (char-range #\a #\z) (char-range #\A #\Z) #\_) (* (or (char-range #\a #\z) (char-range #\A #\Z) (char-range #\0 #\9) #\_)))) (test-ssre "^a(bc+|b[eh])g|.h$" () (or (: bos #\a ($ (or (: #\b (+ #\c)) (: #\b (or #\e #\h)))) #\g) (: nonl #\h eos))) (test-ssre "(bc+d$|ef*g.|h?i(j|k))" () ($ (or (: #\b (+ #\c) #\d eos) (: #\e (* #\f) #\g nonl) (: (? #\h) #\i ($ (or #\j #\k)))))) (test-ssre "((((((((((a))))))))))" () ($ ($ ($ ($ ($ ($ ($ ($ ($ ($ #\a))))))))))) (test-ssre "(((((((((a)))))))))" () ($ ($ ($ ($ ($ ($ ($ ($ ($ #\a)))))))))) (test-ssre "multiple words of text" () (: #\m #\u #\l #\t #\i #\p #\l #\e #\space #\w #\o #\r #\d #\s #\space #\o #\f #\space #\t #\e #\x #\t)) (test-ssre "multiple words" () (: #\m #\u #\l #\t #\i #\p #\l #\e #\space #\w #\o #\r #\d #\s)) (test-ssre "(.*)c(.*)" () (: ($ (* nonl)) #\c ($ (* nonl)))) (test-ssre "\\((.*), (.*)\\)" () (: #\( ($ (* nonl)) #\, #\space ($ (* nonl)) #\))) (test-ssre "[k]" () #\k) (test-ssre "abcd" () (: #\a #\b #\c #\d)) (test-ssre "a(bc)d" () (: #\a ($ (: #\b #\c)) #\d)) (test-ssre "a[-]?c" () (: #\a (? #\-) #\c)) (test-ssre "a(?!b)." () (: #\a (neg-look-ahead #\b) nonl)) (test-ssre "a(?=d)." () (: #\a (look-ahead #\d) nonl)) (test-ssre "a(?=c|d)." () (: #\a (look-ahead (or #\c #\d)) nonl)) (test-ssre "a(?:b|c|d)(.)" () (: #\a (or #\b #\c #\d) ($ nonl))) (test-ssre "a(?:b|c|d)*(.)" () (: #\a (* (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d)+?(.)" () (: #\a (**? 1 #f (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d)+(.)" () (: #\a (+ (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){2}(.)" () (: #\a (= 2 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){4,5}(.)" () (: #\a (** 4 5 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){4,5}?(.)" () (: #\a (**? 4 5 (or #\b #\c #\d)) ($ nonl))) (test-ssre "((foo)|(bar))*" () (* ($ (or ($ (: #\f #\o #\o)) ($ (: #\b #\a #\r)))))) (test-ssre "a(?:b|c|d){6,7}(.)" () (: #\a (** 6 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){6,7}?(.)" () (: #\a (**? 6 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,6}(.)" () (: #\a (** 5 6 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,6}?(.)" () (: #\a (**? 5 6 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,7}(.)" () (: #\a (** 5 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|c|d){5,7}?(.)" () (: #\a (**? 5 7 (or #\b #\c #\d)) ($ nonl))) (test-ssre "a(?:b|(c|e){1,2}?|d)+?(.)" () (: #\a (**? 1 #f (or #\b (**? 1 2 ($ (or #\c #\e))) #\d)) ($ nonl))) (test-ssre "^(.+)?B" () (: bos (? ($ (+ nonl))) #\B)) (test-ssre "^([^a-z])|(\\^)$" () (or (: bos ($ (~ (char-range #\a #\z)))) (: ($ #\^) eos))) (test-ssre "^[<>]&" () (: bos (or #\< #\>) #\&)) (test-ssre "(?:(f)(o)(o)|(b)(a)(r))*" () (* (or (: ($ #\f) ($ #\o) ($ #\o)) (: ($ #\b) ($ #\a) ($ #\r))))) (test-ssre "(?<=a)b" () (: (look-behind #\a) #\b)) (test-ssre "(?a+)ab" () (: ($ (: #\> (+ #\a))) #\a #\b)) (test-ssre "a\\z" () (: #\a eos)) (test-ssre "(?<=\\d{3}(?!999))foo" () (: (look-behind (: (= 3 numeric) (neg-look-ahead (: #\9 #\9 #\9)))) #\f #\o #\o)) (test-ssre "(?<=(?!...999)\\d{3})foo" () (: (look-behind (: (neg-look-ahead (: nonl nonl nonl #\9 #\9 #\9)) (= 3 numeric))) #\f #\o #\o)) (test-ssre "(?<=\\d{3}(?!999)...)foo" () (: (look-behind (: (= 3 numeric) (neg-look-ahead (: #\9 #\9 #\9)) nonl nonl nonl)) #\f #\o #\o)) (test-ssre "(?<=\\d{3}...)(?= 2 (or #\a #\b))) (test-ssre "[ab]{2,}?" () (**? 2 #f (or #\a #\b))) (test-ssre "abc(?=xyz)" () (: #\a #\b #\c (look-ahead (: #\x #\y #\z)))) (test-ssre "(?<=pqr)abc(?=xyz)" () (: (look-behind (: #\p #\q #\r)) #\a #\b #\c (look-ahead (: #\x #\y #\z)))) (test-ssre "a\\b" () (: #\a (or bow eow))) (test-ssre "abc(?=abcde)(?=ab)" () (: #\a #\b #\c (look-ahead (: #\a #\b #\c #\d #\e)) (look-ahead (: #\a #\b)))) (test-ssre "a*?b*?" () (: (*? #\a) (*? #\b))) (test-ssre "(a)(b)|(c)" () (or (: ($ #\a) ($ #\b)) ($ #\c))) (test-ssre "(?aa)" () (-> A (: #\a #\a))) (test-ssre "a(b)c(d)" () (: #\a ($ #\b) #\c ($ #\d))) (test-ssre "^" () bos) (test-ssre "(02-)?[0-9]{3}-[0-9]{3}" () (: (? ($ (: #\0 #\2 #\-))) (= 3 (char-range #\0 #\9)) #\- (= 3 (char-range #\0 #\9)))) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "abc" () (: #\a #\b #\c)) (test-ssre "abc|bcd" () (or (: #\a #\b #\c) (: #\b #\c #\d))) (test-ssre "(?<=abc|)" () (look-behind (or (: #\a #\b #\c) (:)))) (test-ssre "(?<=abc|)" () (look-behind (or (: #\a #\b #\c) (:)))) (test-ssre "(?<=|abc)" () (look-behind (or (:) (: #\a #\b #\c)))) (test-ssre "[abc]" () (or #\a #\b #\c)) (test-ssre "foobar" () (: #\f #\o #\o #\b #\a #\r)) (test-ssre "foobar" () (: #\f #\o #\o #\b #\a #\r)) (test-ssre "(?<=pqr)abc(?=xyz)" () (: (look-behind (: #\p #\q #\r)) #\a #\b #\c (look-ahead (: #\x #\y #\z)))) (test-ssre "\\z" () eos) (test-ssre "\\Z" () (: (? #\newline) eos)) (test-ssre "(?<=(?=.(?<=x)))" () (look-behind (look-ahead (: nonl (look-behind #\x))))) (test-ssre "(?![ab]).*" () (: (neg-look-ahead (or #\a #\b)) (* nonl))) (test-ssre "[a[]" () (or #\a #\[)) (test-ssre "\\bX" () (: (or bow eow) #\X)) (test-ssre "\\BX" () (: nwb #\X)) (test-ssre "X\\b" () (: #\X (or bow eow))) (test-ssre "X\\B" () (: #\X nwb)) (test-ssre "[^a]" () (~ #\a)) (test-ssre "a.b" () (: #\a nonl #\b)) (test-ssre "a(.{3})b" () (: #\a ($ (= 3 nonl)) #\b)) (test-ssre "a(.*?)(.)" () (: #\a ($ (*? nonl)) ($ nonl))) (test-ssre "a(.*?)(.)" () (: #\a ($ (*? nonl)) ($ nonl))) (test-ssre "a(.*)(.)" () (: #\a ($ (* nonl)) ($ nonl))) (test-ssre "a(.*)(.)" () (: #\a ($ (* nonl)) ($ nonl))) (test-ssre "a(.)(.)" () (: #\a ($ nonl) ($ nonl))) (test-ssre "a(.)(.)" () (: #\a ($ nonl) ($ nonl))) (test-ssre "a(.?)(.)" () (: #\a ($ (? nonl)) ($ nonl))) (test-ssre "a(.?)(.)" () (: #\a ($ (? nonl)) ($ nonl))) (test-ssre "a(.??)(.)" () (: #\a ($ (?? nonl)) ($ nonl))) (test-ssre "a(.??)(.)" () (: #\a ($ (?? nonl)) ($ nonl))) (test-ssre "a(.{3})b" () (: #\a ($ (= 3 nonl)) #\b)) (test-ssre "a(.{3,})b" () (: #\a ($ (>= 3 nonl)) #\b)) (test-ssre "a(.{3,}?)b" () (: #\a ($ (**? 3 #f nonl)) #\b)) (test-ssre "a(.{3,5})b" () (: #\a ($ (** 3 5 nonl)) #\b)) (test-ssre "a(.{3,5}?)b" () (: #\a ($ (**? 3 5 nonl)) #\b)) (test-ssre "(?<=aXb)cd" () (: (look-behind (: #\a #\X #\b)) #\c #\d)) (test-ssre "(?<=(.))X" () (: (look-behind ($ nonl)) #\X)) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "^[^a]{2}" () (: bos (= 2 (~ #\a)))) (test-ssre "^[^a]{2,}" () (: bos (>= 2 (~ #\a)))) (test-ssre "^[^a]{2,}?" () (: bos (**? 2 #f (~ #\a)))) (test-ssre "[^a]+" () (+ (~ #\a))) (test-ssre "^[^a]{2}" () (: bos (= 2 (~ #\a)))) (test-ssre "^[^a]{2,}" () (: bos (>= 2 (~ #\a)))) (test-ssre "^[^a]{2,}?" () (: bos (**? 2 #f (~ #\a)))) (test-ssre "\\D" () (~ numeric)) (test-ssre ">\\S" () (: #\> (~ space))) (test-ssre "\\d" () numeric) (test-ssre "\\s" () space) (test-ssre "\\D+" () (+ (~ numeric))) (test-ssre "\\D{2,3}" () (** 2 3 (~ numeric))) (test-ssre "\\D{2,3}?" () (**? 2 3 (~ numeric))) (test-ssre "\\d+" () (+ numeric)) (test-ssre "\\d{2,3}" () (** 2 3 numeric)) (test-ssre "\\d{2,3}?" () (**? 2 3 numeric)) (test-ssre "\\S+" () (+ (~ space))) (test-ssre "\\S{2,3}" () (** 2 3 (~ space))) (test-ssre "\\S{2,3}?" () (**? 2 3 (~ space))) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre ">\\s{2,3}<" () (: #\> (** 2 3 space) #\<)) (test-ssre ">\\s{2,3}?<" () (: #\> (**? 2 3 space) #\<)) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\w{2,3}" () (** 2 3 (or alnum #\_))) (test-ssre "\\w{2,3}?" () (**? 2 3 (or alnum #\_))) (test-ssre "\\W+" () (+ (~ (or alnum #\_)))) (test-ssre "\\W{2,3}" () (** 2 3 (~ (or alnum #\_)))) (test-ssre "\\W{2,3}?" () (**? 2 3 (~ (or alnum #\_)))) (test-ssre "^[ac]*b" () (: bos (* (or #\a #\c)) #\b)) (test-ssre "^[^x]*b" () (: bos (* (~ #\x)) #\b)) (test-ssre "^[^x]*b" () (: bos (* (~ #\x)) #\b)) (test-ssre "^\\d*b" () (: bos (* numeric) #\b)) (test-ssre "(|a)" () ($ (or (:) #\a))) (test-ssre "abcd*" () (: #\a #\b #\c (* #\d))) (test-ssre "abcd*" () (: #\a #\b #\c (* #\d))) (test-ssre "abc\\d*" () (: #\a #\b #\c (* numeric))) (test-ssre "abc[de]*" () (: #\a #\b #\c (* (or #\d #\e)))) (test-ssre "\\bthe cat\\b" () (: (or bow eow) #\t #\h #\e #\space #\c #\a #\t (or bow eow))) (test-ssre "[\\p{Nd}]" () numeric) (test-ssre "[\\p{Nd}+-]+" () (+ (or numeric #\+ #\-))) (test-ssre "[\\P{Nd}]+" () (+ (~ numeric))) (test-ssre "^[\\p{Vowel}]" () (: bos (or #\A #\E #\I #\O #\U #\Y #\W))) (test-ssre "^[\\p{Any}]X" () (: bos any #\X)) (test-ssre "^[\\P{Any}]X" () (: bos (~ any) #\X)) (test-ssre "^[\\p{Any}]?X" () (: bos (? any) #\X)) (test-ssre "[.\\p{Lu}][.\\p{Ll}][.\\P{Lu}][.\\P{Ll}]" () (: (or #\. upper) (or #\. lower) (or #\. (~ upper)) (or #\. (~ lower)))) (test-ssre "[\\p{L}]" () alpha) (test-ssre "[\\P{L}]" () (~ alpha)) (test-ssre "[\\pLu]" () (or alpha #\u)) (test-ssre "[\\PLu]" () (or (~ alpha) #\u)) (test-ssre "\\p{Nd}" () numeric) (test-ssre "\\p{Nd}+" () (+ numeric)) (test-ssre "\\P{Nd}+" () (+ (~ numeric))) (test-ssre "^\\p{Vowel}" () (: bos (or #\A #\E #\I #\O #\U #\Y #\W))) (test-ssre "^\\p{Any}X" () (: bos any #\X)) (test-ssre "^\\P{Any}X" () (: bos (~ any) #\X)) (test-ssre "^\\p{Any}?X" () (: bos (? any) #\X)) (test-ssre "\\p{L}" () alpha) (test-ssre "\\P{L}" () (~ alpha)) (test-ssre "\\pLu" () (: alpha #\u)) (test-ssre "\\PLu" () (: (~ alpha) #\u)) (test-ssre "\\b...\\B" () (: (or bow eow) nonl nonl nonl nwb)) (test-ssre "\\b...\\B" () (: (or bow eow) nonl nonl nonl nwb)) (test-ssre "\\b...\\B" () (: (or bow eow) nonl nonl nonl nwb)) (test-ssre "ist" () (: #\i #\s #\t)) (test-ssre "is+t" () (: #\i (+ #\s) #\t)) (test-ssre "is+?t" () (: #\i (**? 1 #f #\s) #\t)) (test-ssre "is?t" () (: #\i (? #\s) #\t)) (test-ssre "is{2}t" () (: #\i (= 2 #\s) #\t)) (test-ssre "^A\\s+Z" () (: bos #\A (+ space) #\Z)) (test-ssre "AskZ" () (: #\A #\s #\k #\Z)) (test-ssre "[AskZ]+" () (+ (or #\A #\s #\k #\Z))) (test-ssre "[^s]+" () (+ (~ #\s))) (test-ssre "[^s]+" () (+ (~ #\s))) (test-ssre "[^k]+" () (+ (~ #\k))) (test-ssre "[^k]+" () (+ (~ #\k))) (test-ssre "[^sk]+" () (+ (~ (or #\s #\k)))) (test-ssre "[^sk]+" () (+ (~ (or #\s #\k)))) (test-ssre "i" () #\i) (test-ssre "I" () #\I) (test-ssre "[i]" () #\i) (test-ssre "[zi]" () (or #\z #\i)) (test-ssre "[iI]" () (or #\i #\I)) (test-ssre "\\d+" () (+ numeric)) (test-ssre "\\d+" () (+ numeric)) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre ">\\s+<" () (: #\> (+ space) #\<)) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\w+" () (+ (or alnum #\_))) (test-ssre "\\b.+?\\b" () (: (or bow eow) (**? 1 #f nonl) (or bow eow))) (test-ssre "caf\\B.+?\\B" () (: #\c #\a #\f nwb (**? 1 #f nonl) nwb)) (test-ssre "x{1,3}+" () (+ (** 1 3 #\x))) (test-ssre "[a]" () #\a) (test-ssre "[^a]" () (~ #\a)) (test-ssre "(?<=C\n)^" () (: (look-behind (: #\C #\newline)) bos)) (test-ssre "\\w+(?=\t)" () (: (+ (or alnum #\_)) (look-ahead #\tab))) ;; new set notation tests (test-ssre "{Nd}" () numeric) (test-ssre "{Nd|[+]|[-]}+" () (+ (or numeric #\+ #\-))) (test-ssre "{~Nd}+" () (+ (~ numeric))) (test-ssre "^{Vowel}" () (: bos (or #\A #\E #\I #\O #\U #\Y #\W))) (test-ssre "^{Any}X" () (: bos any #\X)) (test-ssre "^{~Any}X" () (: bos (~ any) #\X)) (test-ssre "^{Any}?X" () (: bos (? any) #\X)) (test-ssre "{[.]|Lu}{[.]|Ll}{[.]|~Lu}{[.]|~Ll}" () (: (or #\. upper) (or #\. lower) (or #\. (~ upper)) (or #\. (~ lower)))) (test-ssre "{L}" () alpha) (test-ssre "{~L}" () (~ alpha)) (test-ssre "{L}u" () (: alpha #\u)) (test-ssre "{~L}u" () (: (~ alpha) #\u)) (test-ssre "{L-Vowel}u" () (: (- alpha (or #\A #\E #\I #\O #\U #\Y #\W)) #\u)) (test-ssre "{Nd}" () numeric) (test-ssre "{Nd}+" () (+ numeric)) (test-ssre "{~Nd}+" () (+ (~ numeric))) (test-ssre "^{Vowel}" () (: bos (or #\A #\E #\I #\O #\U #\Y #\W))) (test-ssre "^{Any}X" () (: bos any #\X)) (test-ssre "^{~Any}X" () (: bos (~ any) #\X)) (test-ssre "^{Any}?X" () (: bos (? any) #\X)) (test-ssre "{u}{l|d}*" () (: upper (* (or lower numeric)))) (test-ssre "{~d}{an|[']}*" () (: (~ numeric) (* (or alnum #\')))) (test-ssre "{<}{u&~Vowel|d}{!b}{an-d}*{>}" () (: bow (or (- upper (or #\A #\E #\I #\O #\U #\Y #\W)) numeric) nwb (* (- alnum numeric)) eow)) (test-ssre "{}\\X*" () (: grapheme (* grapheme))) ;; options tests (test-ssre "A string" (i) (w/nocase (: #\A #\space #\s #\t #\r #\i #\n #\g))) (test-ssre "([^.]*)\\.([^:]*):[T ]+(.*)" (i) (w/nocase (: ($ (* (~ #\.))) #\. ($ (* (~ #\:))) #\: (+ (or #\T #\space)) ($ (* nonl))))) (test-ssre "^[W-c]+$" (i) (w/nocase (: bos (+ (char-range #\W #\c)) eos))) (test-ssre "\\A(.)*\\z" (s) (: bos (* ($ any)) eos)) (test-ssre "[^a]" (i) (w/nocase (~ #\a))) (test-ssre "(?i:saturday|sunday)" () (w/nocase (or (: #\s #\a #\t #\u #\r #\d #\a #\y) (: #\s #\u #\n #\d #\a #\y)))) (test-ssre "(?i:a)b" (i) (w/nocase (: #\a #\b))) (test-ssre "((?i:a))b" (i) (w/nocase (: ($ #\a) #\b))) (test-ssre "(?-i:a)b" (i) (w/nocase (: (w/case #\a) #\b))) (test-ssre "((?-i:a))b" (i) (w/nocase (: ($ (w/case #\a)) #\b))) (test-ssre "(?-i:a)b" (i) (w/nocase (: (w/case #\a) #\b))) (test-ssre "((?-i:a))b" () (: ($ #\a) #\b)) (test-ssre "(?-i:a)b" () (: #\a #\b)) (test-ssre "((?-i:a))b" () (: ($ #\a) #\b)) (test-ssre "((?-i:a.))b" (i s) (w/nocase (: ($ (w/case (: #\a any))) #\b))) ;(test-ssre "^a(?#xxx){3}c" () (: bos "a" "{3}c")) -- (?#comments) not supported (test-ssre "(?m)^b$" () (: bol #\b eol)) (test-ssre "(?ms)^b." () (: bol #\b any)) (test-ssre "([\\w:]+::)?(\\w+)$" (i) (w/nocase (: (? ($ (: (+ (or alnum #\_ #\:)) #\: #\:))) ($ (+ (or alnum #\_))) eos))) (test-ssre "(?x)x y z | a b c" () (or (: #\x #\y #\z) (: #\a #\b #\c))) (test-ssre "(?i)AB(?-i:C)" () (w/nocase (: #\A #\B (w/case #\C)))) (test-ssre "(?i)reg(?:ul(?:[a@]|ae)r|ex)" () (w/nocase (: #\r #\e #\g (or (: #\u #\l (or #\a #\@ (: #\a #\e)) #\r) (: #\e #\x))))) (test-ssre "ab cd (?x: de fg)" () (: #\a #\b #\space #\c #\d #\space (: #\d #\e #\f #\g))) (test-ssre "ab cd(?x: de fg) h" () (: #\a #\b #\space #\c #\d (: #\d #\e #\f #\g) #\space #\h)) (test-ssre "^\\w+=.*(\\\\\n.*)*" (s) (: bos (+ (or alnum #\_)) #\= (* any) (* ($ (: #\\ #\newline (* any)))))) (test-ssre "[^a]*" (i) (w/nocase (* (~ #\a)))) (test-ssre "[^a]*?X" (i) (w/nocase (: (*? (~ #\a)) #\X))) (test-ssre "[^a]+?X" (i) (w/nocase (: (**? 1 #f (~ #\a)) #\X))) (test-ssre "[^a]?X" (i) (w/nocase (: (? (~ #\a)) #\X))) (test-ssre "[^a]??X" (i) (w/nocase (: (?? (~ #\a)) #\X))) (test-ssre "[^a]{2,3}" (i) (w/nocase (** 2 3 (~ #\a)))) (test-ssre "[^a]{2,3}?" (i) (w/nocase (**? 2 3 (~ #\a)))) (test-ssre "(?<=a{2})b" (i) (w/nocase (: (look-behind (= 2 #\a)) #\b))) (test-ssre "(?= 8 (* (or (~ alpha) #\a #\*)))) (test-ssre "(?i)abc" (i) (w/nocase (: #\a #\b #\c))) (test-ssre "(?-i)the end" (i) (w/nocase (w/case (: #\t #\h #\e #\space #\e #\n #\d)))) ; optimise? (test-ssre "([\\da-f:]+)$" (i) (w/nocase (: ($ (+ (or numeric (char-range #\a #\f) #\:))) eos))) (test-ssre "^[\\da-f](\\.[\\da-f])*$" (i) (w/nocase (: bos (or numeric (char-range #\a #\f)) (* ($ (: #\. (or numeric (char-range #\a #\f))))) eos))) (test-ssre "([^.]*)\\.([^:]*):[T ]+(.*)" (i s) (w/nocase (: ($ (* (~ #\.))) #\. ($ (* (~ #\:))) #\: (+ (or #\T #\space)) ($ (* any))))) (test-ssre "([^.]*)\\.([^:]*):[T ]+(.*)" (i s n) (w/nocase (: (* (~ #\.)) #\. (* (~ #\:)) #\: (+ (or #\T #\space)) (* any)))) (test-ssre "^[W-c]+$" (i) (w/nocase (: bos (+ (char-range #\W #\c)) eos))) (test-ssre "^[\x3f;-\x5F;]+$" (i) (w/nocase (: bos (+ (char-range #\? #\_)) eos))) (test-ssre "[^a]" (i) (w/nocase (~ #\a))) (test-ssre "[^a]+" (i) (w/nocase (+ (~ #\a)))) (test-ssre "[^az]" (i) (w/nocase (~ (or #\a #\z)))) (test-ssre "\\b(foo)\\s+(\\w+)" (i) (w/nocase (: (or bow eow) ($ (: #\f #\o #\o)) (+ space) ($ (+ (or alnum #\_)))))) (test-ssre "a(?i:b)c" () (: #\a (w/nocase #\b) #\c)) (test-ssre "a(?i:b)*c" () (: #\a (* (w/nocase #\b)) #\c)) (test-ssre "^(?-u:\\w\\s*\\w)$" (i m) (w/nocase (: bol (w/ascii (: (or alnum #\_) (* space) (or alnum #\_))) eol))) (test-ssre "abc\\X*" (i) (w/nocase (: #\a #\b #\c (* grapheme)))) (test-ssre "((((((((((a))))))))))" (n) #\a) (test-ssre "((((((((?-n:(a)))))))))" (n) ($ #\a)) (test-end)