(rx (| numeric alphabetic)) yields a char-set: but

(rx (| ,(rx numeric) ,(rx alphabetic))) doesn't:, even
though the "type-checking rules" for char-sets says
that it should:

> (rx (| numeric alphabetic))
'#{re-char-set}
> (rx (| ,(rx numeric) ,(rx alphabetic)))
'#{Re-choice}

The following patch fixes this but I'm not sure if
make-re-choice is the right place to tackle this problem:

This fixes bug report #1063781
This commit is contained in:
mainzelm 2005-10-18 14:01:50 +00:00
parent cfcb6a1b05
commit f4fbe4c986
1 changed files with 10 additions and 8 deletions

View File

@ -133,14 +133,16 @@
(really-make-re-choice elts tsm (new-cre posix-str tvec))) (really-make-re-choice elts tsm (new-cre posix-str tvec)))
(define (make-re-choice res) (define (make-re-choice res)
(make-re-choice/tsm res (if (every re-char-set? res)
(fold (lambda (re sm-count) (make-re-char-set (apply char-set-union (map re-char-set:cset res)))
(let ((maybe-tsm (re-tsm re))) (make-re-choice/tsm res
(if (and (number? maybe-tsm) (fold (lambda (re sm-count)
(number? sm-count)) (let ((maybe-tsm (re-tsm re)))
(+ maybe-tsm sm-count) (if (and (number? maybe-tsm)
(unspecific)))) (number? sm-count))
0 res))) (+ maybe-tsm sm-count)
(unspecific))))
0 res))))
;;; Slightly smart choice constructor: ;;; Slightly smart choice constructor:
;;; - Flattens nested choices ;;; - Flattens nested choices