Unread a token.
(punread-token ppstate) → new-ppstate
We move the token from the sequence of read lexemes to the sequence of unread lexemes.
It is an internal error if
Function:
(defun punread-token (ppstate) (declare (xargs :stobjs (ppstate))) (declare (xargs :guard (ppstatep ppstate))) (let ((__function__ 'punread-token)) (declare (ignorable __function__)) (b* ((ppstate.lexemes-read (ppstate->lexemes-read ppstate)) (ppstate.lexemes-unread (ppstate->lexemes-unread ppstate)) (ppstate.size (ppstate->size ppstate)) ((unless (> ppstate.lexemes-read 0)) (raise "Internal error: no token to unread.") (b* ((ppstate (update-ppstate->lexemes-unread (1+ ppstate.lexemes-unread) ppstate)) (ppstate (update-ppstate->size (1+ ppstate.size) ppstate))) ppstate)) (ppstate (update-ppstate->lexemes-unread (1+ ppstate.lexemes-unread) ppstate)) (ppstate (update-ppstate->lexemes-read (1- ppstate.lexemes-read) ppstate)) (ppstate (update-ppstate->size (1+ ppstate.size) ppstate))) ppstate)))
Theorem:
(defthm ppstatep-of-punread-token (implies (ppstatep ppstate) (b* ((new-ppstate (punread-token ppstate))) (ppstatep new-ppstate))) :rule-classes :rewrite)
Theorem:
(defthm ppstate->size-of-unread-token (b* ((?new-ppstate (punread-token ppstate))) (equal (ppstate->size new-ppstate) (1+ (ppstate->size ppstate)))))