Function: combobulate-production-rules-get
combobulate-production-rules-get is a natively compiled function
defined in combobulate-procedure.el.
Signature
(combobulate-production-rules-get NODE-TYPE &optional FIELDS)
Documentation
Get production rules for NODE-TYPE and possibly FIELDS.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-procedure.el
(defun combobulate-production-rules-get (node-type &optional fields)
"Get production rules for NODE-TYPE and possibly FIELDS."
(setq fields (or fields '(:all t)))
(let* ((rules (cadr (assoc-string node-type (combobulate-production-rules-get-rules))))
(supertypes (combobulate-production-rules-get-supertypes))
(all-keys (map-keys rules)))
(if rules
;; some node types are supertypes, meaning they exist outside
;; the actual parse tree TS can generate. However, the rules
;; for these supertypes are defined and used in the parser and
;; exported in the node rules also. If we encounter a
;; supertype, we expand it inline.
(mapcan
(lambda (n)
;; check if n is a supertype; if it is, expand it.
(if (member n supertypes)
(combobulate-production-rules-get n)
(list n)))
(apply
#'append
(mapcar (lambda (prop)
(if (plist-member rules prop)
(plist-get rules prop)
(error "Rule `%s' has no field named `%s'. Known fields: `%s'"
node-type prop all-keys)))
(cond
((null fields) '(:*unnamed*))
((plist-get fields :all) all-keys)
(t fields)))))
(when combobulate-debug
(error "Cannot find any rules named `%s'" node-type)))))