Lex a header name.
(lex-header-name parstate) → (mv erp hname span new-parstate)
This is called when we expect a header name. We read the next character, which must be present. Then we read the two kinds of header names, based on whether the next character is greater-than or double quote. If it is neither, lexing fails.
Function:
(defun lex-header-name (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'lex-header-name)) (declare (ignorable __function__)) (b* (((reterr) (irr-header-name) (irr-span) parstate) ((erp char first-pos parstate) (read-char parstate))) (cond ((not char) (reterr-msg :where (position-to-msg first-pos) :expected "a greater-than ~ or a double quote" :found (char-to-msg char))) ((utf8-= char (char-code #\<)) (b* (((erp hchars closing-angle-pos parstate) (lex-*-h-char parstate)) (span (make-span :start first-pos :end closing-angle-pos)) ((unless hchars) (reterr-msg :where (position-to-msg closing-angle-pos) :expected "one or more characters" :found "none"))) (retok (header-name-angles hchars) span parstate))) ((utf8-= char (char-code #\")) (b* (((erp qchars closing-dquote-pos parstate) (lex-*-q-char parstate)) (span (make-span :start first-pos :end closing-dquote-pos)) ((unless qchars) (reterr-msg :where (position-to-msg closing-dquote-pos) :expected "one or more characters" :found "none"))) (retok (header-name-quotes qchars) span parstate))) (t (reterr-msg :where (position-to-msg first-pos) :expected "a greater-than ~ or a double quote" :found (char-to-msg char)))))))
Theorem:
(defthm header-namep-of-lex-header-name.hname (b* (((mv acl2::?erp ?hname ?span ?new-parstate) (lex-header-name parstate))) (header-namep hname)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-lex-header-name.span (b* (((mv acl2::?erp ?hname ?span ?new-parstate) (lex-header-name parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-header-name.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?hname ?span ?new-parstate) (lex-header-name parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-header-name-uncond (b* (((mv acl2::?erp ?hname ?span ?new-parstate) (lex-header-name parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-header-name-cond (b* (((mv acl2::?erp ?hname ?span ?new-parstate) (lex-header-name parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)