Match identifier characters to create an
(lex-id/keyword sin) → (mv tok sin)
Function:
(defun lex-id/keyword (sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard t)) (let ((__function__ 'lex-id/keyword)) (declare (ignorable __function__)) (b* (((when (sin-endp sin)) (mv nil sin)) (car (sin-car sin)) ((unless (char-in-charset-p car (letter-chars))) (mv nil sin)) ((mv match sin) (sin-match-charset* (idtail-chars) sin)) ((when (or (equal match "void") (equal match "int") (equal match "float"))) (mv (make-token :type :keyword :text match) sin))) (mv (make-token :type :id :text match) sin))))
Theorem:
(defthm return-type-of-lex-id/keyword.tok (b* (((mv ?tok ?sin) (lex-id/keyword sin))) (equal (token-p tok) (if tok t nil))) :rule-classes :rewrite)
Theorem:
(defthm lex-id/keyword-progress-weak (mv-let (tok new-sin) (lex-id/keyword sin) (declare (ignorable tok new-sin)) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex-id/keyword-progress-strong (mv-let (tok new-sin) (lex-id/keyword sin) (declare (ignorable tok new-sin)) (implies tok (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex-id/keyword-reconstruction (b* (((mv tok new-sin) (lex-id/keyword sin))) (implies tok (equal (append (explode (token->text tok)) (strin-left new-sin)) (strin-left sin)))))