Abstract a
(abs-primary-expression tree) → expr-or-err
Function:
(defun abs-primary-expression (tree) (declare (xargs :guard (abnf::treep tree))) (let ((__function__ 'abs-primary-expression)) (declare (ignorable __function__)) (b* (((okf tree) (check-tree-nonleaf-1-1 tree "primary-expression")) ((okf rulename?) (check-tree-nonleaf? tree))) (cond ((equal rulename? "identifier") (let ((id-or-err (abs-identifier tree))) (if (stringp id-or-err) (make-expression-var :name id-or-err) id-or-err))) ((equal rulename? "integer") (let ((int-or-err (abs-integer tree))) (if (integerp int-or-err) (make-expression-const :value int-or-err) int-or-err))) (t (reserrf (list :found-subtree (tree-info-for-error tree))))))))
Theorem:
(defthm expression-resultp-of-abs-primary-expression (b* ((expr-or-err (abs-primary-expression tree))) (expression-resultp expr-or-err)) :rule-classes :rewrite)
Theorem:
(defthm abs-primary-expression-of-tree-fix-tree (equal (abs-primary-expression (abnf::tree-fix tree)) (abs-primary-expression tree)))
Theorem:
(defthm abs-primary-expression-tree-equiv-congruence-on-tree (implies (abnf::tree-equiv tree tree-equiv) (equal (abs-primary-expression tree) (abs-primary-expression tree-equiv))) :rule-classes :congruence)