Unread a character during preprocessing.
(punread-char ppstate) → new-ppstate
We move the character from the sequence of read characters
to the sequence of unread characters,
by incrementing
It is an internal error if
Function:
(defun punread-char (ppstate) (declare (xargs :stobjs (ppstate))) (declare (xargs :guard (ppstatep ppstate))) (let ((__function__ 'punread-char)) (declare (ignorable __function__)) (b* ((ppstate.chars-read (ppstate->chars-read ppstate)) (ppstate.chars-unread (ppstate->chars-unread ppstate)) (ppstate.size (ppstate->size ppstate)) ((unless (> ppstate.chars-read 0)) (raise "Internal error: no character to unread.") (b* ((ppstate (update-ppstate->chars-unread (1+ ppstate.chars-unread) ppstate)) (ppstate (update-ppstate->size (1+ ppstate.size) ppstate))) ppstate)) (ppstate (update-ppstate->chars-read (1- ppstate.chars-read) ppstate)) (ppstate (update-ppstate->chars-unread (1+ ppstate.chars-unread) ppstate)) (ppstate (update-ppstate->size (1+ ppstate.size) ppstate))) ppstate)))
Theorem:
(defthm ppstatep-of-punread-char (implies (ppstatep ppstate) (b* ((new-ppstate (punread-char ppstate))) (ppstatep new-ppstate))) :rule-classes :rewrite)
Theorem:
(defthm ppstate->size-of-punread-char (b* ((?new-ppstate (punread-char ppstate))) (equal (ppstate->size new-ppstate) (1+ (ppstate->size ppstate)))))
Theorem:
(defthm punread-char-of-ppstate-fix-ppstate (equal (punread-char (ppstate-fix ppstate)) (punread-char ppstate)))
Theorem:
(defthm punread-char-ppstate-equiv-congruence-on-ppstate (implies (ppstate-equiv ppstate ppstate-equiv) (equal (punread-char ppstate) (punread-char ppstate-equiv))) :rule-classes :congruence)