Validate a character constant.
(valid-cconst cconst ienv) → (mv erp type)
We check the characters that form the constant,
with respect to the prefix (if any).
If validation is successful, we return the type of the constant.
According to [C17:6.4.4.4/10],
a character constant without prefix has type
The types
Function:
(defun valid-cconst (cconst ienv) (declare (xargs :guard (and (cconstp cconst) (ienvp ienv)))) (let ((__function__ 'valid-cconst)) (declare (ignorable __function__)) (b* (((reterr) (irr-type)) ((cconst cconst) cconst) ((erp &) (valid-c-char-list cconst.cchars cconst.prefix? ienv))) (if cconst.prefix? (retok (type-unknown)) (retok (type-sint))))))
Theorem:
(defthm maybe-msgp-of-valid-cconst.erp (b* (((mv acl2::?erp ?type) (valid-cconst cconst ienv))) (maybe-msgp erp)) :rule-classes :rewrite)
Theorem:
(defthm typep-of-valid-cconst.type (b* (((mv acl2::?erp ?type) (valid-cconst cconst ienv))) (typep type)) :rule-classes :rewrite)
Theorem:
(defthm valid-cconst-of-cconst-fix-cconst (equal (valid-cconst (cconst-fix cconst) ienv) (valid-cconst cconst ienv)))
Theorem:
(defthm valid-cconst-cconst-equiv-congruence-on-cconst (implies (cconst-equiv cconst cconst-equiv) (equal (valid-cconst cconst ienv) (valid-cconst cconst-equiv ienv))) :rule-classes :congruence)
Theorem:
(defthm valid-cconst-of-ienv-fix-ienv (equal (valid-cconst cconst (c::ienv-fix ienv)) (valid-cconst cconst ienv)))
Theorem:
(defthm valid-cconst-ienv-equiv-congruence-on-ienv (implies (c::ienv-equiv ienv ienv-equiv) (equal (valid-cconst cconst ienv) (valid-cconst cconst ienv-equiv))) :rule-classes :congruence)