Given a tree under :nonleaf literal, return the appropriate literal AST node.
(cst2ast-literal-kind tree) → ast-node?
Function:
(defun cst2ast-literal-kind (tree) (declare (xargs :guard (abnf::treep tree))) (let ((__function__ 'cst2ast-literal-kind)) (declare (ignorable __function__)) (b* (((unless (abnf::tree-case tree :nonleaf)) nil) (rulename-option (abnf::tree-nonleaf->rulename? tree)) ((unless (abnf::rulenamep rulename-option)) nil) (rulestring (abnf::rulename->get rulename-option))) (cond ((equal rulestring "decimal-number") (cst2ast-decimal-number tree)) ((equal rulestring "hex-number") (cst2ast-hex-number tree)) ((equal rulestring "boolean") (cst2ast-boolean tree)) ((equal rulestring "string-literal") (cst2ast-string-literal tree)) ((equal rulestring "hex-string") (cst2ast-hex-string tree)) (t nil)))))
Theorem:
(defthm literal-optionp-of-cst2ast-literal-kind (b* ((ast-node? (cst2ast-literal-kind tree))) (literal-optionp ast-node?)) :rule-classes :rewrite)