Lex a string literal.
(lex-stringlit eprefix? first-pos parstate) → (mv erp lexeme span new-parstate)
This is called when we expect a string literal, after the opening double quote, and the prefix before that if present, have already been read. We read zero or more characters and escape sequences. In the process of reading those characters and escape sequences, we read up to the closing double quote (see lex-*-s-char), whose position we use as the ending one of the span we return. The starting position of the span is passed to this function as input.
Function:
(defun lex-stringlit (eprefix? first-pos parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (and (eprefix-optionp eprefix?) (positionp first-pos) (parstatep parstate)))) (let ((__function__ 'lex-stringlit)) (declare (ignorable __function__)) (b* (((reterr) (irr-lexeme) (irr-span) parstate) ((erp schars closing-dquote-pos parstate) (lex-*-s-char parstate)) (span (make-span :start first-pos :end closing-dquote-pos))) (retok (lexeme-token (token-string (stringlit eprefix? schars))) span parstate))))
Theorem:
(defthm lexemep-of-lex-stringlit.lexeme (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-stringlit eprefix? first-pos parstate))) (lexemep lexeme)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-lex-stringlit.span (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-stringlit eprefix? first-pos parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-stringlit.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-stringlit eprefix? first-pos parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-stringlit-uncond (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-stringlit eprefix? first-pos parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-stringlit-cond (b* (((mv acl2::?erp ?lexeme ?span ?new-parstate) (lex-stringlit eprefix? first-pos parstate))) (implies (not erp) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)