Pretty-print an object declarator.
(pprint-obj-declor declor) → part
This requires a bit of care, because we may need to print parentheses for proper grouping. This is similar to the pretty-printing of expressions, but much simpler, so we do can put all the logic into this pretty-printing function, avoiding all the structure needed for expressions (which need that structure due to their greater complexity). The idea is the same, though.
Array declarators bind tighter than pointer declarators.
E.g.
So, analogously to the treatment of expressions, we need to take the relative precendence of pointer and array declarators when pretty-printing them:
Function:
(defun pprint-obj-declor (declor) (declare (xargs :guard (obj-declorp declor))) (let ((__function__ 'pprint-obj-declor)) (declare (ignorable __function__)) (obj-declor-case declor :ident (pprint-ident declor.get) :pointer (msg "*~@0" (pprint-obj-declor declor.decl)) :array (b* ((sub (pprint-obj-declor declor.decl))) (if (obj-declor-case declor.decl :pointer) (msg "(~@0)[~@1]" sub (if declor.size (pprint-iconst declor.size) "")) (msg "~@0[~@1]" sub (if declor.size (pprint-iconst declor.size) "")))))))
Theorem:
(defthm msgp-of-pprint-obj-declor (b* ((part (pprint-obj-declor declor))) (msgp part)) :rule-classes :rewrite)
Theorem:
(defthm pprint-obj-declor-of-obj-declor-fix-declor (equal (pprint-obj-declor (obj-declor-fix declor)) (pprint-obj-declor declor)))
Theorem:
(defthm pprint-obj-declor-obj-declor-equiv-congruence-on-declor (implies (obj-declor-equiv declor declor-equiv) (equal (pprint-obj-declor declor) (pprint-obj-declor declor-equiv))) :rule-classes :congruence)