Main lexer loop: completely tokenize the entire input stream.
(lex* sin) → (mv okp tokens sin)
Function:
(defun lex* (sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard t)) (let ((__function__ 'lex*)) (declare (ignorable __function__)) (mbe :logic (b* (((when (sin-endp sin)) (mv t nil sin)) ((mv tok1 sin) (lex1 sin)) ((unless tok1) (mv nil nil sin)) ((mv okp rest-tokens sin) (lex* sin)) (ans (cons tok1 rest-tokens))) (mv okp ans sin)) :exec (b* (((mv okp acc sin) (lex*-exec sin nil))) (mv okp (reverse acc) sin)))))
Theorem:
(defthm booleanp-of-lex*.okp (b* (((mv ?okp ?tokens ?sin) (lex* sin))) (booleanp okp)) :rule-classes :type-prescription)
Theorem:
(defthm tokenlist-p-of-lex*.tokens (b* (((mv ?okp ?tokens ?sin) (lex* sin))) (tokenlist-p tokens)) :rule-classes :rewrite)
Theorem:
(defthm lex*-exec-removal (b* (((mv okp tokens new-sin) (lex* sin))) (equal (lex*-exec sin acc) (mv okp (revappend tokens acc) new-sin))))
Theorem:
(defthm true-listp-of-lex*-tokens (true-listp (mv-nth 1 (lex* sin))) :rule-classes :type-prescription)
Theorem:
(defthm tokenlist-all-text-of-lex* (b* (((mv okp tokens ?new-sin) (lex* sin))) (implies okp (equal (tokenlist-all-text tokens) (implode (strin-left sin))))))