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