[private] rx: allow \ between [...]
This commit is contained in:
parent
6f2089c29d
commit
f18c207d11
|
@ -13,6 +13,13 @@
|
||||||
|
|
||||||
;; -- regexps, from the world
|
;; -- regexps, from the world
|
||||||
|
|
||||||
|
(let ([str "dont care"]) ;; from `tests/racket/contract/multi-file.rkt`
|
||||||
|
(check-equal?
|
||||||
|
(ann
|
||||||
|
(regexp-match: #rx"[/\\]([-a-z0-9.]*)[^/\\]*$" str)
|
||||||
|
(U #f (List String String)))
|
||||||
|
#f))
|
||||||
|
|
||||||
(let ([l "dont care"]) ;; from `morse-code-table.rkt`
|
(let ([l "dont care"]) ;; from `morse-code-table.rkt`
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(ann
|
(ann
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
(define (unescaped-pos* str c*)
|
(define (unescaped-pos* str c*)
|
||||||
(define L (string-length str))
|
(define L (string-length str))
|
||||||
(define escaped? (box #f))
|
(define escaped? (box #f))
|
||||||
|
(define most-recent-char (box #f))
|
||||||
(define (have-char-at-index? c i hist)
|
(define (have-char-at-index? c i hist)
|
||||||
(memv i (hash-ref hist c)))
|
(memv i (hash-ref hist c)))
|
||||||
(define h-rev
|
(define h-rev
|
||||||
|
@ -157,7 +158,8 @@
|
||||||
(define char (unsafe-string-ref str i))
|
(define char (unsafe-string-ref str i))
|
||||||
(cond
|
(cond
|
||||||
[(unbox escaped?)
|
[(unbox escaped?)
|
||||||
(unless (eq? #\\ char)
|
(when (or (not (eq? #\\ char))
|
||||||
|
(eq? #\[ (unbox most-recent-char)))
|
||||||
(set-box! escaped? #f))
|
(set-box! escaped? #f))
|
||||||
hist]
|
hist]
|
||||||
[(eq? #\\ char)
|
[(eq? #\\ char)
|
||||||
|
@ -173,7 +175,9 @@
|
||||||
[else
|
[else
|
||||||
(let ([i* (hash-ref hist char #f)])
|
(let ([i* (hash-ref hist char #f)])
|
||||||
(if i*
|
(if i*
|
||||||
(hash-set hist char (cons i i*))
|
(begin
|
||||||
|
(set-box! most-recent-char char)
|
||||||
|
(hash-set hist char (cons i i*)))
|
||||||
hist))])))
|
hist))])))
|
||||||
;; -- reverse all saved lists
|
;; -- reverse all saved lists
|
||||||
(for/hasheq ([(c i*) (in-hash h-rev)])
|
(for/hasheq ([(c i*) (in-hash h-rev)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user