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