Lex a binary exponent.
This is called when we expect a binary exponent.
We try to read a
Function:
(defun lex-bin-expo (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'lex-bin-expo)) (declare (ignorable __function__)) (b* (((reterr) (irr-bin-expo) (irr-position) parstate) ((erp char pos parstate) (read-char parstate))) (cond ((not char) (reterr-msg :where (position-to-msg pos) :expected "a character in {p, P}" :found (char-to-msg char))) ((or (= char (char-code #\p)) (= char (char-code #\P))) (b* ((prefix (if (= char (char-code #\p)) (bin-expo-prefix-locase-p) (bin-expo-prefix-upcase-p))) ((erp sign? sign-last-pos parstate) (lex-sign-if-present parstate)) ((erp digits digits-last-pos digits-next-pos parstate) (lex-*-digit sign-last-pos parstate)) ((unless digits) (reterr-msg :where (position-to-msg digits-next-pos) :expected "one or more digits" :found "none"))) (retok (make-bin-expo :prefix prefix :sign? sign? :digits digits) digits-last-pos parstate))) (t (reterr-msg :where (position-to-msg pos) :expected "a character in {p, P}" :found (char-to-msg char)))))))
Theorem:
(defthm bin-expop-of-lex-bin-expo.expo (b* (((mv acl2::?erp ?expo ?last-pos ?new-parstate) (lex-bin-expo parstate))) (bin-expop expo)) :rule-classes :rewrite)
Theorem:
(defthm positionp-of-lex-bin-expo.last-pos (b* (((mv acl2::?erp ?expo ?last-pos ?new-parstate) (lex-bin-expo parstate))) (positionp last-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-bin-expo.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?expo ?last-pos ?new-parstate) (lex-bin-expo parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-bin-expo-uncond (b* (((mv acl2::?erp ?expo ?last-pos ?new-parstate) (lex-bin-expo parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-bin-expo-cond (b* (((mv acl2::?erp ?expo ?last-pos ?new-parstate) (lex-bin-expo parstate))) (implies (and (not erp) expo?) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)