Lex a sign, if present.
(lex-sign-if-present parstate) → (mv erp sign? last/next-pos new-parstate)
If a sign is found, the
If there is no next character, there is no sign. Otherwise, we read the next character, and return a sign if appropriate, otherwise no sign and we put back the character.
Function:
(defun lex-sign-if-present (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'lex-sign-if-present)) (declare (ignorable __function__)) (b* (((reterr) nil (irr-position) parstate) ((erp char pos parstate) (read-char parstate))) (cond ((not char) (retok nil pos parstate)) ((= char (char-code #\+)) (retok (sign-plus) pos parstate)) ((= char (char-code #\-)) (retok (sign-minus) pos parstate)) (t (b* ((parstate (unread-char parstate))) (retok nil pos parstate)))))))
Theorem:
(defthm sign-optionp-of-lex-sign-if-present.sign? (b* (((mv acl2::?erp ?sign? ?last/next-pos ?new-parstate) (lex-sign-if-present parstate))) (sign-optionp sign?)) :rule-classes :rewrite)
Theorem:
(defthm positionp-of-lex-sign-if-present.last/next-pos (b* (((mv acl2::?erp ?sign? ?last/next-pos ?new-parstate) (lex-sign-if-present parstate))) (positionp last/next-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-sign-if-present.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?sign? ?last/next-pos ?new-parstate) (lex-sign-if-present parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-sign-if-present-ucond (b* (((mv acl2::?erp ?sign? ?last/next-pos ?new-parstate) (lex-sign-if-present parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-sign-if-present-cond (b* (((mv acl2::?erp ?sign? ?last/next-pos ?new-parstate) (lex-sign-if-present parstate))) (implies (and (not erp) sign?) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)