Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#86 rx-choice doesn't create char-sets

closed-duplicate
Mike Sperber
run-time (53)
5
2005-11-02
2004-11-10
No

(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:

Index: re.scm

RCS file: /cvsroot/scsh/scsh/scsh/rx/re.scm,v
retrieving revision 1.8
diff -u -c -r1.8 re.scm
*** re.scm 30 Oct 2002 12:33:51 -0000 1.8
--- re.scm 10 Nov 2004 12:48:25 -0000
***************
*** 133,146 ****
(really-make-re-choice elts tsm (new-cre posix-str
tvec)))

(define (make-re-choice res)
! (make-re-choice/tsm res
! (fold (lambda (re sm-count)
! (let ((maybe-tsm (re-tsm re)))
! (if (and (number? maybe-tsm)
! (number? sm-count))
! (+ maybe-tsm sm-count)
! (unspecific))))
! 0 res)))

;;; Slightly smart choice constructor:
;;; - Flattens nested choices
--- 133,148 ----
(really-make-re-choice elts tsm (new-cre posix-str
tvec)))

(define (make-re-choice res)
! (if (every re-char-set? res)
! (make-re-char-set (apply char-set-union (map
re-char-set:cset res)))
! (make-re-choice/tsm res
! (fold (lambda (re sm-count)
! (let ((maybe-tsm
(re-tsm re)))
! (if (and (number?
maybe-tsm)
! (number?
sm-count))
! (+ maybe-tsm
sm-count)
! (unspecific))))
! 0 res))))

;;; Slightly smart choice constructor:
;;; - Flattens nested choices

Discussion

  • Logged In: YES
    user_id=17553

    I've committed the above patch to CVS. It will be in 0.6.7.

     
    • status: open --> pending-duplicate
     
    • status: pending-duplicate --> closed-duplicate
     
  • Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).