Update the preprocessor state for a character.
(update-ppstate-for-char char new-bytes
new-position size-decrement ppstate)
→
new-ppstateThis is used when pread-char
reads a character from the data bytes (not from the unread characters).
The
Function:
(defun update-ppstate-for-char (char new-bytes new-position size-decrement ppstate) (declare (xargs :stobjs (ppstate))) (declare (xargs :guard (and (natp char) (byte-listp new-bytes) (positionp new-position) (posp size-decrement) (ppstatep ppstate)))) (declare (xargs :guard (and (< (ppstate->chars-read ppstate) (ppstate->chars-length ppstate)) (>= (ppstate->size ppstate) size-decrement)))) (b* ((position (ppstate->position ppstate)) (chars-read (ppstate->chars-read ppstate)) (size (ppstate->size ppstate)) (new-size (- size (pos-fix size-decrement))) (char+pos (make-char+position :char char :position position)) (ppstate (update-ppstate->bytes new-bytes ppstate)) (ppstate (update-ppstate->char chars-read char+pos ppstate)) (ppstate (update-ppstate->chars-read (1+ chars-read) ppstate)) (ppstate (update-ppstate->position new-position ppstate)) (ppstate (update-ppstate->size new-size ppstate))) ppstate))
Theorem:
(defthm ppstatep-of-update-ppstate-for-char (implies (ppstatep ppstate) (b* ((new-ppstate (update-ppstate-for-char char new-bytes new-position size-decrement ppstate))) (ppstatep new-ppstate))) :rule-classes :rewrite)
Theorem:
(defthm ppstate->size-of-update-ppstate-for-char (implies (>= (ppstate->size ppstate) (pos-fix size-decrement)) (b* ((?new-ppstate (update-ppstate-for-char char new-bytes new-position size-decrement ppstate))) (equal (ppstate->size new-ppstate) (- (ppstate->size ppstate) (pos-fix size-decrement))))))