(parse-charset-atom x index) → (mv err char new-index)
Function:
(defun parse-charset-atom (x index) (declare (xargs :guard (and (stringp x) (natp index)))) (declare (xargs :guard (<= index (strlen x)))) (let ((__function__ 'parse-charset-atom)) (declare (ignorable __function__)) (b* ((x (lstrfix x)) (index (lnfix index)) ((unless (< index (strlen x))) (mv "String ended inside charset" (code-char 0) index)) (char1 (char x index)) (index (+ 1 index)) ((when (eql char1 #\])) (mv "End of charset" (code-char 0) index)) ((unless (eql char1 #\\)) (mv nil char1 index)) ((unless (< index (strlen x))) (mv "String ended inside charset" (code-char 0) index)) (char2 (char x index)) (index (+ 1 index))) (case char2 ((#\\ #\] #\-) (mv nil char2 index)) (#\n (mv nil #\Newline index)) (#\t (mv nil #\Tab index)) (#\r (mv nil #\Return index)) (#\f (mv nil #\Page index)) (#\o (parse-octal-charcode x index)) (#\x (parse-hex-charcode x index)) (t (mv (str::cat "Unrecognized escape sequence in charset: " (coerce (list char1 char2) 'string)) (code-char 0) index))))))
Theorem:
(defthm maybe-stringp-of-parse-charset-atom.err (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (acl2::maybe-stringp err)) :rule-classes :type-prescription)
Theorem:
(defthm characterp-of-parse-charset-atom.char (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (characterp char)) :rule-classes :rewrite)
Theorem:
(defthm natp-of-parse-charset-atom.new-index (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (natp new-index)) :rule-classes :type-prescription)
Theorem:
(defthm new-index-of-parse-charset-atom (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (<= (nfix index) new-index)) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-charset-atom-strong (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (implies (not err) (< (nfix index) new-index))) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-charset-atom-less-than-length (b* (((mv ?err common-lisp::?char ?new-index) (parse-charset-atom x index))) (implies (<= (nfix index) (len (acl2::explode x))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm parse-charset-atom-of-str-fix-x (equal (parse-charset-atom (acl2::str-fix x) index) (parse-charset-atom x index)))
Theorem:
(defthm parse-charset-atom-streqv-congruence-on-x (implies (acl2::streqv x x-equiv) (equal (parse-charset-atom x index) (parse-charset-atom x-equiv index))) :rule-classes :congruence)
Theorem:
(defthm parse-charset-atom-of-nfix-index (equal (parse-charset-atom x (nfix index)) (parse-charset-atom x index)))
Theorem:
(defthm parse-charset-atom-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (parse-charset-atom x index) (parse-charset-atom x index-equiv))) :rule-classes :congruence)