Match punctuation characters to create a :punctuation token.
(lex-punctuation sin) → (mv tok sin)
It's important to put the
Function:
(defun lex-punctuation (sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard t)) (let ((__function__ 'lex-punctuation)) (declare (ignorable __function__)) (b* (((mv match sin) (sin-match-some-lit '("++" "--" ";" "+" "-" "*" "/") sin)) ((unless match) (mv nil sin))) (mv (make-token :type :punctuation :text match) sin))))
Theorem:
(defthm return-type-of-lex-punctuation.tok (b* (((mv ?tok ?sin) (lex-punctuation sin))) (equal (token-p tok) (if tok t nil))) :rule-classes :rewrite)
Theorem:
(defthm lex-punctuation-progress-weak (mv-let (tok new-sin) (lex-punctuation sin) (declare (ignorable tok new-sin)) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex-punctuation-progress-strong (mv-let (tok new-sin) (lex-punctuation sin) (declare (ignorable tok new-sin)) (implies tok (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lex-punctuation-reconstruction (b* (((mv tok new-sin) (lex-punctuation sin))) (implies tok (equal (append (explode (token->text tok)) (strin-left new-sin)) (strin-left sin)))))