Try to read a
(vl-read-octal-string-escape echars) → (mv char/nil prefix remainder)
This can fail for two reasons.
BOZO consider revamping this to return an error msg instead of printing.
Function:
(defun vl-read-octal-string-escape (echars) (declare (xargs :guard (and (vl-echarlist-p echars) (consp echars) (consp (cdr echars)) (eql (vl-echar->char (first echars)) #\\)))) (let ((__function__ 'vl-read-octal-string-escape)) (declare (ignorable __function__)) (b* ((echar1 (first echars)) (echar2 (second echars)) (val2 (vl-echar-digit-value echar2 8)) ((unless val2) (mv nil nil echars)) ((unless (consp (cddr echars))) (mv (cw "Lexer error (~s0): EOF during string escape sequence: ~s1<EOF>~%" (vl-location-string (vl-echar->loc (car echars))) (vl-echarlist->string (list echar1 echar2))) nil echars)) (echar3 (third echars)) ((when (or (vl-z-digit-echar-p echar3) (vl-x-digit-echar-p echar3))) (mv (cw "Lexer error (~s0): invalid string escape sequence: ~s1 ~ (x, z, and ? digits aren't allowed here)~%" (vl-location-string (vl-echar->loc (car echars))) (vl-echarlist->string (list echar1 echar2 echar3))) nil echars)) (val3 (vl-echar-digit-value echar3 8)) ((unless val3) (mv (code-char val2) (list echar1 echar2) (cddr echars))) ((unless (consp (cdddr echars))) (mv (cw "Lexer error (~s0): EOF during string escape sequence: ~s1<EOF>~%" (vl-location-string (vl-echar->loc (car echars))) (vl-echarlist->string (list echar1 echar2 echar3))) nil echars)) (echar4 (fourth echars)) ((when (or (vl-z-digit-echar-p echar4) (vl-x-digit-echar-p echar4))) (mv (cw "Lexer error (~s0): invalid string escape sequence: ~s1 ~ (x, z, and ? digits aren't allowed here)~%" (vl-location-string (vl-echar->loc (car echars))) (vl-echarlist->string (list echar1 echar2 echar3 echar4))) nil echars)) (val4 (vl-echar-digit-value echar4 8)) ((unless val4) (mv (code-char (the (unsigned-byte 8) (+ (the (unsigned-byte 8) (* 8 (the (unsigned-byte 8) val2))) (the (unsigned-byte 8) val3)))) (list echar1 echar2 echar3) (cdddr echars))) ((the (unsigned-byte 12) value) (+ (the (unsigned-byte 12) (* 64 (the (unsigned-byte 8) val2))) (the (unsigned-byte 8) (+ (the (unsigned-byte 8) (* 8 (the (unsigned-byte 8) val3))) (the (unsigned-byte 8) val4))))) ((unless (< value 256)) (mv (cw "Lexer error (~s0): invalid escape sequence: ~s1. ~ (characters beyond \\377 aren't valid)~%" (vl-location-string (vl-echar->loc (car echars))) (vl-echarlist->string (list echar1 echar2 echar3 echar4))) nil echars))) (mv (code-char value) (list echar1 echar2 echar3 echar4) (cddddr echars)))))
Theorem:
(defthm return-type-of-vl-read-octal-string-escape.char/nil (b* (((mv ?char/nil ?prefix ?remainder) (vl-read-octal-string-escape echars))) (equal (characterp char/nil) (if char/nil t nil))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-read-octal-string-escape.prefix (b* (((mv ?char/nil ?prefix ?remainder) (vl-read-octal-string-escape echars))) (iff prefix char/nil)) :rule-classes :rewrite)