;;; #\^ must appear anywhere except as the first character in the set.
(define (re-compile-char-set pattern negate?)
+ (receive (scalar-values negate?*)
+ (re-char-pattern->scalar-values pattern)
+ (let ((char-set (scalar-values->char-set scalar-values)))
+ (if (if negate? (not negate?*) negate?*)
+ (char-set-invert char-set)
+ char-set))))
+
+(define (re-char-pattern->scalar-values pattern)
(define (loop pattern scalar-values)
(if (pair? pattern)
(if (and (pair? (cdr pattern))
scalar-values))
(let ((pattern (string->list pattern)))
- (receive (pattern negate?)
- (if (and (pair? pattern)
- (char=? (car pattern) #\^))
- (values (cdr pattern) (not negate?))
- (values pattern negate?))
- (let ((char-set (scalar-values->char-set (loop pattern '()))))
- (if negate?
- char-set
- (char-set-invert char-set))))))
+ (if (and (pair? pattern)
+ (char=? (car pattern) #\^))
+ (values (loop (cdr pattern) '()) #t)
+ (values (loop pattern '()) #f))))
\f
;;;; Translation Tables
compiled-regexp/byte-stream
compiled-regexp/translation-table
condition-type:re-compile-pattern
+ re-char-pattern->scalar-values
re-compile-char
re-compile-char-set
re-compile-pattern