Lex a single token from the input stream.
(lex1 sin) → (mv tok sin)
Function:
(defun lex1 (sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard (not (sin-endp sin)))) (let ((__function__ 'lex1)) (declare (ignorable __function__)) (b* ((char1 (sin-car sin)) ((when (char-in-charset-p char1 (whitespace-chars))) (lex-whitespace sin)) ((when (char-in-charset-p char1 (letter-chars))) (lex-id/keyword sin)) ((when (sin-matches-p "//" sin)) (lex-comment sin))) (lex-punctuation sin))))
Theorem:
(defthm return-type-of-lex1.tok (b* (((mv ?tok ?sin) (lex1 sin))) (equal (token-p tok) (if tok t nil))) :rule-classes :rewrite)
Theorem:
(defthm lex1-progress-weak (mv-let (tok new-sin) (lex1 sin) (declare (ignorable tok new-sin)) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex1-progress-strong (mv-let (tok new-sin) (lex1 sin) (declare (ignorable tok new-sin)) (implies tok (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex1-reconstruction (b* (((mv tok new-sin) (lex1 sin))) (implies tok (equal (append (explode (token->text tok)) (strin-left new-sin)) (strin-left sin)))))