Lex a floating suffix, if present.
(lex-?-floating-suffix parstate) → (mv erp fsuffix? last/next-pos new-parstate)
If a suffix is found,
the
If there is no next character, there is no suffix. Otherwise, there are four possibilities for suffixes. If the next character is not part of any suffix, we unread the character and return no suffix.
If GCC extensions are enabled,
we allow the
Function:
(defun lex-?-floating-suffix (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'lex-?-floating-suffix)) (declare (ignorable __function__)) (b* (((reterr) nil (irr-position) parstate) ((erp char pos parstate) (read-char parstate))) (cond ((not char) (retok nil pos parstate)) ((utf8-= char (char-code #\f)) (b* (((unless (parstate->gcc parstate)) (retok (fsuffix-locase-f) pos parstate)) ((erp digits digits-last-pos & parstate) (lex-*-digit pos parstate))) (cond (digits (b* ((n (str::dec-digit-chars-value digits)) ((unless (member-equal n '(16 32 64 128))) (reterr-msg :where (position-to-msg pos) :expected "one of ~ f16, f32, f64, f128, ~ f16x, f32x, f64x, f128x" :found (msg "f~x0" n))) ((erp charx posx parstate) (read-char parstate))) (cond ((eql charx (char-code #\x)) (b* ((fsuffix (case n (16 (fsuffix-locase-f16 t)) (32 (fsuffix-locase-f32 t)) (64 (fsuffix-locase-f64 t)) (128 (fsuffix-locase-f128 t))))) (retok fsuffix posx parstate))) (t (b* ((parstate (if charx (unread-char parstate) parstate)) (fsuffix (case n (16 (fsuffix-locase-f16 nil)) (32 (fsuffix-locase-f32 nil)) (64 (fsuffix-locase-f64 nil)) (128 (fsuffix-locase-f128 nil))))) (retok fsuffix digits-last-pos parstate)))))) (t (retok (fsuffix-locase-f) pos parstate))))) ((utf8-= char (char-code #\F)) (b* (((unless (parstate->gcc parstate)) (retok (fsuffix-upcase-f) pos parstate)) ((erp digits digits-last-pos & parstate) (lex-*-digit pos parstate))) (cond (digits (b* ((n (str::dec-digit-chars-value digits)) ((unless (member-equal n '(16 32 64 128))) (reterr-msg :where (position-to-msg pos) :expected "one of ~ f16, f32, f64, f128, ~ f16x, f32x, f64x, f128x" :found (msg "f~x0" n))) ((erp charx posx parstate) (read-char parstate))) (cond ((eql charx (char-code #\x)) (b* ((fsuffix (case n (16 (fsuffix-upcase-f16 t)) (32 (fsuffix-upcase-f32 t)) (64 (fsuffix-upcase-f64 t)) (128 (fsuffix-upcase-f128 t))))) (retok fsuffix posx parstate))) (t (b* ((parstate (if charx (unread-char parstate) parstate)) (fsuffix (case n (16 (fsuffix-upcase-f16 nil)) (32 (fsuffix-upcase-f32 nil)) (64 (fsuffix-upcase-f64 nil)) (128 (fsuffix-upcase-f128 nil))))) (retok fsuffix digits-last-pos parstate)))))) (t (retok (fsuffix-upcase-f) pos parstate))))) ((utf8-= char (char-code #\l)) (retok (fsuffix-locase-l) pos parstate)) ((utf8-= char (char-code #\L)) (retok (fsuffix-upcase-l) pos parstate)) (t (b* ((parstate (unread-char parstate))) (retok nil pos parstate)))))))
Theorem:
(defthm fsuffix-optionp-of-lex-?-floating-suffix.fsuffix? (b* (((mv acl2::?erp ?fsuffix? ?last/next-pos ?new-parstate) (lex-?-floating-suffix parstate))) (fsuffix-optionp fsuffix?)) :rule-classes :rewrite)
Theorem:
(defthm positionp-of-lex-?-floating-suffix.last/next-pos (b* (((mv acl2::?erp ?fsuffix? ?last/next-pos ?new-parstate) (lex-?-floating-suffix parstate))) (positionp last/next-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-lex-?-floating-suffix.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?fsuffix? ?last/next-pos ?new-parstate) (lex-?-floating-suffix parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-lex-?-floating-suffix-uncond (b* (((mv acl2::?erp ?fsuffix? ?last/next-pos ?new-parstate) (lex-?-floating-suffix parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)
Theorem:
(defthm parsize-of-lex-?-floating-suffix-cond (b* (((mv acl2::?erp ?fsuffix? ?last/next-pos ?new-parstate) (lex-?-floating-suffix parstate))) (implies (and (not erp) fsuffix?) (<= (parsize new-parstate) (1- (parsize parstate))))) :rule-classes :linear)