Read a specific punctuator token.
This is called when we expect a specific punctuator. We pass the string for the punctuator, and we read the next token, ensuring it exists and it is that punctuator.
Function:
(defun read-punctuator (punct parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (and (stringp punct) (parstatep parstate)))) (let ((__function__ 'read-punctuator)) (declare (ignorable __function__)) (b* (((reterr) (irr-span) parstate) ((erp token span parstate) (read-token parstate)) ((unless (token-punctuatorp token punct)) (reterr-msg :where (position-to-msg (span->start span)) :expected (msg "the punctuator ~x0" punct) :found (token-to-msg token)))) (retok span parstate))))
Theorem:
(defthm spanp-of-read-punctuator.span (b* (((mv acl2::?erp ?span ?new-parstate) (read-punctuator punct parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-read-punctuator.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?span ?new-parstate) (read-punctuator punct parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-read-punctuator-uncond (b* (((mv acl2::?erp ?span ?new-parstate) (read-punctuator punct parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-read-punctuator-cond (b* (((mv acl2::?erp ?span ?new-parstate) (read-punctuator punct parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)