Function: rx--parse-any
rx--parse-any is a byte-compiled function defined in rx.el.gz.
Signature
(rx--parse-any BODY)
Documentation
Parse arguments of an (any ...) construct.
Return (INTERVALS . CLASSES), where INTERVALS is a sorted list of disjoint nonadjacent intervals (each a cons of chars), and CLASSES a list of named character classes in the order they occur in BODY.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/rx.el.gz
(defun rx--parse-any (body)
"Parse arguments of an (any ...) construct.
Return (INTERVALS . CLASSES), where INTERVALS is a sorted list of
disjoint nonadjacent intervals (each a cons of chars), and CLASSES
a list of named character classes in the order they occur in BODY."
(let ((classes nil)
(strings nil)
(conses nil))
;; Collect strings, conses and characters, and classes in separate bins.
(dolist (arg body)
(cond ((stringp arg)
(push arg strings))
((and (consp arg)
(characterp (car arg))
(characterp (cdr arg))
(<= (car arg) (cdr arg)))
;; Copy the cons, in case we need to modify it.
(push (cons (car arg) (cdr arg)) conses))
((characterp arg)
(push (cons arg arg) conses))
((and (symbolp arg)
(let ((class (cdr (assq arg rx--char-classes))))
(and class
(or (memq class classes)
(progn (push class classes) t))))))
(t (error "Invalid rx `any' argument: %s" arg))))
(cons (rx--condense-intervals
(sort (append conses
(mapcan #'rx--string-to-intervals strings))
#'car-less-than-car))
(nreverse classes))))