Valid types:
For any other directive, we assume the directive has the form
~[char2][char3]
For instance,
For these directives, we return char2 as TYPE and char3 as VAL.
Function:
(defun vl-basic-fmt-parse-tilde (x n xl) (declare (xargs :guard (and (stringp x) (natp n) (eql xl (length x))))) (declare (xargs :guard (< n xl))) (let ((__function__ 'vl-basic-fmt-parse-tilde)) (declare (ignorable __function__)) (b* ((n (lnfix n)) (xl (lnfix xl)) ((the character char1) (mbe :logic (char-fix (char x n)) :exec (char x n))) ((when (not (eql char1 #\~))) (mv :normal char1 (+ n 1))) ((when (eql (+ n 1) xl)) (prog2$ (raise "The format string ~x0 ends with a lone tilde." x) (mv :normal char1 (+ n 1)))) ((the character char2) (mbe :logic (char-fix (char x (+ n 1))) :exec (char x (+ n 1)))) ((when (eql char2 #\~)) (mv :normal #\~ (+ n 2))) ((when (eql char2 #\%)) (mv :normal #\Newline (+ n 2))) ((when (eql char2 #\Space)) (mv :hard-space #\Space (+ n 2))) ((when (eql char2 #\|)) (mv :cbreak #\Newline (+ n 2))) ((when (eql char2 #\Newline)) (mv :skip #\Space (vl-skip-ws x (+ n 2) xl))) ((when (eql (+ n 2) xl)) (prog2$ (raise "The format string ~x0 ends with ~x1, but this directive needs argument." x (implode (list char1 char2))) (mv :normal char1 (+ n 1)))) ((the character char3) (mbe :logic (char-fix (char x (+ n 2))) :exec (char x (+ n 2))))) (mv char2 char3 (+ n 3)))))
Theorem:
(defthm characterp-of-vl-basic-fmt-parse-tilde.val (b* (((mv common-lisp::?type ?val ?n-prime) (vl-basic-fmt-parse-tilde x n xl))) (characterp val)) :rule-classes :type-prescription)
Theorem:
(defthm natp-of-vl-basic-fmt-parse-tilde.n-prime (b* (((mv common-lisp::?type ?val ?n-prime) (vl-basic-fmt-parse-tilde x n xl))) (natp n-prime)) :rule-classes :type-prescription)
Theorem:
(defthm upper-bound-of-vl-basic-fmt-parse-tilde-nprime (implies (and (< (nfix n) (nfix xl))) (<= (mv-nth 2 (vl-basic-fmt-parse-tilde x n xl)) (nfix xl))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm lower-bound-of-vl-basic-fmt-parse-tilde-nprime (< (nfix n) (mv-nth 2 (vl-basic-fmt-parse-tilde x n xl))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm vl-basic-fmt-parse-tilde-of-str-fix-x (equal (vl-basic-fmt-parse-tilde (str-fix x) n xl) (vl-basic-fmt-parse-tilde x n xl)))
Theorem:
(defthm vl-basic-fmt-parse-tilde-streqv-congruence-on-x (implies (streqv x x-equiv) (equal (vl-basic-fmt-parse-tilde x n xl) (vl-basic-fmt-parse-tilde x-equiv n xl))) :rule-classes :congruence)
Theorem:
(defthm vl-basic-fmt-parse-tilde-of-nfix-n (equal (vl-basic-fmt-parse-tilde x (nfix n) xl) (vl-basic-fmt-parse-tilde x n xl)))
Theorem:
(defthm vl-basic-fmt-parse-tilde-nat-equiv-congruence-on-n (implies (acl2::nat-equiv n n-equiv) (equal (vl-basic-fmt-parse-tilde x n xl) (vl-basic-fmt-parse-tilde x n-equiv xl))) :rule-classes :congruence)