Lex a line comment.
(lex-line-comment first-pos parstate) → (mv erp lexeme span new-parstate)
This is called when we expect a line comment,
after reading the initial
We read characters in a loop until
either we find a new-line character (success)
or we find end of file (failure).
In case of success, we return
a lexeme that currently contains no information
(but that may change in the future),
and a span calculated from
the position of the first
Function:
(defun lex-line-comment-loop (first-pos parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (and (positionp first-pos) (parstatep parstate)))) (let ((__function__ 'lex-line-comment-loop)) (declare (ignorable __function__)) (b* (((reterr) (irr-position) parstate) ((erp char pos parstate) (read-char parstate))) (cond ((not char) (reterr-msg :where (position-to-msg pos) :expected "a character" :found (char-to-msg char) :extra (msg "The line comment starting at ~@1 ~ never ends." (position-to-msg first-pos)))) ((= char 10) (retok pos parstate)) (t (lex-line-comment-loop first-pos parstate))))))
Theorem:
(defthm positionp-of-lex-line-comment-loop.last-pos (b* (((mv acl2::?erp ?last-pos ?new-parstate) (lex-line-comment-loop first-pos parstate))) (positionp last-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-line-comment-loop.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?last-pos ?new-parstate) (lex-line-comment-loop first-pos parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-line-comment-loop-uncond (b* (((mv acl2::?erp ?last-pos ?new-parstate) (lex-line-comment-loop first-pos parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-line-comment-loop-cond (b* (((mv acl2::?erp ?last-pos ?new-parstate) (lex-line-comment-loop first-pos parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)
Function:
(defun lex-line-comment (first-pos parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (and (positionp first-pos) (parstatep parstate)))) (let ((__function__ 'lex-line-comment)) (declare (ignorable __function__)) (b* (((reterr) (irr-lexeme) (irr-span) parstate) ((erp last-pos parstate) (lex-line-comment-loop first-pos parstate))) (retok (lexeme-comment) (make-span :start first-pos :end last-pos) parstate))))
Theorem:
(defthm lexemep-of-lex-line-comment.lexeme (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-line-comment first-pos parstate))) (lexemep lexeme)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-lex-line-comment.span (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-line-comment first-pos parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-line-comment.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-line-comment first-pos parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-line-comment-uncond (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-line-comment first-pos parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-line-comment-cond (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-line-comment first-pos parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)