Function: combobulate-procedure-expand-rules-1
combobulate-procedure-expand-rules-1 is a natively compiled function
defined in combobulate-procedure.el.
Signature
(combobulate-procedure-expand-rules-1 RULES)
Documentation
Internal function that expands RULES into a set of node types.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-procedure.el
(defun combobulate-procedure-expand-rules-1 (rules)
"Internal function that expands RULES into a set of node types."
(let ((collected-node-types))
(dolist (element (ensure-list rules))
(pcase element
;; Match a regular expression against the node types and
;; expand each matching production rule with `(rule TYPE)'
(`(rule-rx . ,regexp)
(setq collected-node-types
(append collected-node-types
(mapcan (lambda (n)
(combobulate-procedure-expand-rules
(list 'rule n)))
(combobulate-procedure-expand-rules
`(rx ,@(ensure-list regexp)))))))
;; Match a regular expression against the node types and
;; collect the matching node types.
(`(rx . ,regexp)
(setq collected-node-types
(append collected-node-types
(seq-filter (lambda (node-type)
(string-match-p (rx-to-string `(: ,@regexp)) node-type))
(combobulate-production-rules-get-types)))))
;; A production rule with optional fields which defaults to
;; nil, because `production-rules-get' interprets that to mean
;; all fields.
((or `(rule ,rule-name . ,fields)
(and `(rule ,rule-name) (let fields nil)))
(setq collected-node-types
(append collected-node-types
(apply #'combobulate-production-rules-get rule-name (list (ensure-list fields))))))
;; An inverted production rule that uses the inverse
;; production rule table instead.
(`(irule ,inverted-rule-name)
(setq collected-node-types
(append collected-node-types
(combobulate-production-rules-get-inverted inverted-rule-name))))
;; String nodes are pushed directly onto the list.
((and (pred stringp) node-type)
(push node-type collected-node-types))
;; Lists of strings are treated as a list of node types and
;; merged with the already-collected node types.
((and (pred list-of-strings-p) node-types)
(setq collected-node-types (append collected-node-types node-types)))
;; The value `t' is a special case that, along with `(all)',
;; matches all node types
((or '(all) 't '(t))
(setq collected-node-types (append collected-node-types (combobulate-production-rules-get-types))))
;; Exclusions are expanded recursively and the result is
;; subtracted from the already-collected node types.
(`(exclude ,inclusions . ,exclusions)
(setq collected-node-types
(append collected-node-types
(seq-difference (combobulate-procedure-expand-rules inclusions)
(combobulate-procedure-expand-rules exclusions)))))
(_ (error "Invalid node qualifier: %s" element))))
(seq-uniq collected-node-types)))