Read an identifier token.
This is called when we expect an identifier token. We read the next token, ensuring it exists and is an identifier. We return the identifier if successful.
Function:
(defun read-identifier (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'read-identifier)) (declare (ignorable __function__)) (b* (((reterr) (irr-ident) (irr-span) parstate) ((erp token span parstate) (read-token parstate)) ((unless (and token (token-case token :ident))) (reterr-msg :where (position-to-msg (span->start span)) :expected "an identifier" :found (token-to-msg token))) (ident (token-ident->unwrap token))) (retok ident span parstate))))
Theorem:
(defthm identp-of-read-identifier.ident (b* (((mv acl2::?erp ?ident ?span ?new-parstate) (read-identifier parstate))) (identp ident)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-read-identifier.span (b* (((mv acl2::?erp ?ident ?span ?new-parstate) (read-identifier parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-read-identifier.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?ident ?span ?new-parstate) (read-identifier parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-read-ident-uncond (b* (((mv acl2::?erp ?ident ?span ?new-parstate) (read-identifier parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-read-ident-cond (b* (((mv acl2::?erp ?ident ?span ?new-parstate) (read-identifier parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)