Function: rx--intervals-to-alt

rx--intervals-to-alt is a byte-compiled function defined in rx.el.gz.

Signature

(rx--intervals-to-alt NEGATED INTERVALS)

Documentation

Generate a character alternative from an interval set.

Return (REGEXP . PRECEDENCE). INTERVALS is a sorted list of disjoint intervals. If NEGATED, negate the sense.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/rx.el.gz
(defun rx--intervals-to-alt (negated intervals)
  "Generate a character alternative from an interval set.
Return (REGEXP . PRECEDENCE).
INTERVALS is a sorted list of disjoint intervals.
If NEGATED, negate the sense."
  ;; Detect whether the interval set is better described in
  ;; complemented form.  This is not just a matter of aesthetics: any
  ;; range from ASCII to raw bytes will automatically exclude the
  ;; entire non-ASCII Unicode range by the regexp engine.
  (if (rx--every (lambda (iv) (not (<= (car iv) #x3ffeff (cdr iv))))
                 intervals)
      (rx--generate-alt negated intervals nil)
    (rx--generate-alt
     (not negated) (rx--complement-intervals intervals) nil)))