Lex zero or more characters in a header name between double quotes.
(lex-*-q-char parstate) → (mv erp qchars closing-dquote-pos new-parstate)
That is, lex a
This is called when we expect a header name, after reading the opening double quote of a header name. If successful, this reads up to and including the closing double quote, and returns the position of the latter, along with the sequence of characters.
We read the next character; it is an error if there is none. It is also an error if the character is a new-line. If the character is a closing double quote, we end the recursion and return. In all other cases, we take the character as is, we read zero or more additional characters and escape sequences, and we combine them with the character.
Function:
(defun lex-*-q-char (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'lex-*-q-char)) (declare (ignorable __function__)) (b* (((reterr) nil (irr-position) parstate) ((erp char pos parstate) (read-char parstate)) ((unless char) (reterr-msg :where (position-to-msg pos) :expected "any character other than ~ greater-than or new-line" :found (char-to-msg char))) ((when (utf8-= char (char-code #\"))) (retok nil pos parstate)) ((when (utf8-= char 10)) (reterr-msg :where (position-to-msg pos) :expected "any character other than ~ greater-than or new-line" :found (char-to-msg char))) (qchar (q-char char)) ((erp qchars closing-dquote-pos parstate) (lex-*-q-char parstate))) (retok (cons qchar qchars) closing-dquote-pos parstate))))
Theorem:
(defthm q-char-listp-of-lex-*-q-char.qchars (b* (((mv acl2::?erp ?qchars ?closing-dquote-pos ?new-parstate) (lex-*-q-char parstate))) (q-char-listp qchars)) :rule-classes :rewrite)
Theorem:
(defthm positionp-of-lex-*-q-char.closing-dquote-pos (b* (((mv acl2::?erp ?qchars ?closing-dquote-pos ?new-parstate) (lex-*-q-char parstate))) (positionp closing-dquote-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-*-q-char.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?qchars ?closing-dquote-pos ?new-parstate) (lex-*-q-char parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-*-q-char-uncond (b* (((mv acl2::?erp ?qchars ?closing-dquote-pos ?new-parstate) (lex-*-q-char parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-*-q-char-cond (b* (((mv acl2::?erp ?qchars ?closing-dquote-pos ?new-parstate) (lex-*-q-char parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (- (parsize parstate) (len qchars)))))) :rule-classes :linear)