(if (digit-char-p ,char (max *read-base* 10))
(if (digit-char-p ,char *read-base*)
+char-attr-constituent-digit+
- +char-attr-constituent+)
+ +char-attr-constituent-decimal-digit+)
att))))
\f
;;;; token fetching
(case (char-class3 char attribute-table)
(#.+char-attr-constituent-sign+ (go SIGN))
(#.+char-attr-constituent-digit+ (go LEFTDIGIT))
+ (#.+char-attr-constituent-decimal-digit+ (go LEFTDECIMALDIGIT))
(#.+char-attr-constituent-dot+ (go FRONTDOT))
(#.+char-attr-escape+ (go ESCAPE))
(#.+char-attr-package-delimiter+ (go COLON))
possibly-float t)
(case (char-class3 char attribute-table)
(#.+char-attr-constituent-digit+ (go LEFTDIGIT))
+ (#.+char-attr-constituent-decimal-digit+ (go LEFTDECIMALDIGIT))
(#.+char-attr-constituent-dot+ (go SIGNDOT))
(#.+char-attr-escape+ (go ESCAPE))
(#.+char-attr-package-delimiter+ (go COLON))
(unless char (return (make-integer)))
(case (char-class3 char attribute-table)
(#.+char-attr-constituent-digit+ (go LEFTDIGIT))
+ (#.+char-attr-constituent-decimal-digit+ (if possibly-float
+ (go LEFTDECIMALDIGIT)
+ (go SYMBOL)))
(#.+char-attr-constituent-dot+ (if possibly-float
(go MIDDLEDOT)
(go SYMBOL)))
(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
(#.+char-attr-package-delimiter+ (go COLON))
(t (go SYMBOL)))
+ LEFTDECIMALDIGIT ; saw "[sign] {decimal-digit}+"
+ (aver possibly-float)
+ (ouch-read-buffer char)
+ (setq char (read-char stream nil nil))
+ (unless char (go RETURN-SYMBOL))
+ (case (char-class3 char attribute-table)
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go LEFTDECIMALDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go LEFTDECIMALDIGIT))
+ (#.+char-attr-constituent-dot+ (go MIDDLEDOT))
+ (#.+char-attr-constituent-expt+ (go EXPONENT))
+ (#.+char-attr-constituent-slash+ (aver (not possibly-rational))
+ (go SYMBOL))
+ (#.+char-attr-delimiter+ (unread-char char stream)
+ (go RETURN-SYMBOL))
+ (#.+char-attr-escape+ (go ESCAPE))
+ (#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
+ (#.+char-attr-package-delimiter+ (go COLON))
+ (t (go SYMBOL)))
MIDDLEDOT ; saw "[sign] {digit}+ dot"
(ouch-read-buffer char)
(setq char (read-char stream nil nil))
(unless char (return (let ((*read-base* 10))
(make-integer))))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go RIGHTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go RIGHTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go RIGHTDIGIT))
(#.+char-attr-constituent-expt+ (go EXPONENT))
(#.+char-attr-delimiter+
(unread-char char stream)
(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
(#.+char-attr-package-delimiter+ (go COLON))
(t (go SYMBOL)))
- RIGHTDIGIT ; saw "[sign] {digit}* dot {digit}+"
+ RIGHTDIGIT ; saw "[sign] {decimal-digit}* dot {digit}+"
(ouch-read-buffer char)
(setq char (read-char stream nil nil))
(unless char (return (make-float stream)))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go RIGHTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go RIGHTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go RIGHTDIGIT))
(#.+char-attr-constituent-expt+ (go EXPONENT))
(#.+char-attr-delimiter+
(unread-char char stream)
(setq char (read-char stream nil nil))
(unless char (go RETURN-SYMBOL))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go RIGHTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go RIGHTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go RIGHTDIGIT))
(#.+char-attr-delimiter+ (unread-char char stream) (go RETURN-SYMBOL))
(#.+char-attr-escape+ (go ESCAPE))
(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
(setq char (read-char stream nil nil))
(unless char (%reader-error stream "dot context error"))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go RIGHTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go RIGHTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go RIGHTDIGIT))
(#.+char-attr-constituent-dot+ (go DOTS))
(#.+char-attr-delimiter+ (%reader-error stream "dot context error"))
(#.+char-attr-escape+ (go ESCAPE))
(ouch-read-buffer char)
(setq char (read-char stream nil nil))
(unless char (go RETURN-SYMBOL))
+ (setq possibly-float t)
(case (char-class char attribute-table)
(#.+char-attr-constituent-sign+ (go EXPTSIGN))
- (#.+char-attr-constituent-digit+ (go EXPTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go EXPTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go EXPTDIGIT))
(#.+char-attr-delimiter+ (unread-char char stream) (go RETURN-SYMBOL))
(#.+char-attr-escape+ (go ESCAPE))
(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
(setq char (read-char stream nil nil))
(unless char (go RETURN-SYMBOL))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go EXPTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go EXPTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go EXPTDIGIT))
(#.+char-attr-delimiter+ (unread-char char stream) (go RETURN-SYMBOL))
(#.+char-attr-escape+ (go ESCAPE))
(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
(setq char (read-char stream nil nil))
(unless char (return (make-float stream)))
(case (char-class char attribute-table)
- (#.+char-attr-constituent-digit+ (go EXPTDIGIT))
+ (#.+char-attr-constituent-digit+ (if possibly-float
+ (go EXPTDIGIT)
+ (go SYMBOL)))
+ (#.+char-attr-constituent-decimal-digit+ (go EXPTDIGIT))
(#.+char-attr-delimiter+
(unread-char char stream)
(return (make-float stream)))
(assert (equal (multiple-value-list
(parse-integer string))
'(123 6))))
+
+(let ((*read-base* *read-base*))
+ (dolist (float-string '(".9" ".9e9" ".9e+9" ".9e-9"
+ "-.9" "-.9e9" "-.9e+9" "-.9e-9"
+ "+.9" "+.9e9" "+.9e+9" "+.9e-9"
+ "0.9" "0.9e9" "0.9e+9" "0.9e-9"
+ "9.09" "9.09e9" "9.09e+9" "9.09e-9"
+ "9e9" "9e+9" "9e-9"))
+ (loop for i from 2 to 36
+ do (setq *read-base* i)
+ do (assert (typep (read-from-string float-string)
+ *read-default-float-format*))
+ do (assert (typep
+ (read-from-string (substitute #\E #\e float-string))
+ *read-default-float-format*))
+ if (position #\e float-string)
+ do (assert (typep
+ (read-from-string (substitute #\s #\e float-string))
+ 'short-float))
+ and do (assert (typep
+ (read-from-string (substitute #\S #\e float-string))
+ 'short-float))
+ and do (assert (typep
+ (read-from-string (substitute #\f #\e float-string))
+ 'single-float))
+ and do (assert (typep
+ (read-from-string (substitute #\F #\e float-string))
+ 'single-float))
+ and do (assert (typep
+ (read-from-string (substitute #\d #\e float-string))
+ 'double-float))
+ and do (assert (typep
+ (read-from-string (substitute #\D #\e float-string))
+ 'double-float))
+ and do (assert (typep
+ (read-from-string (substitute #\d #\e float-string))
+ 'long-float))
+ and do (assert (typep
+ (read-from-string (substitute #\D #\e float-string))
+ 'long-float)))))
+
+(let ((*read-base* *read-base*))
+ (dolist (integer-string '("1." "2." "3." "4." "5." "6." "7." "8." "9." "0."))
+ (loop for i from 2 to 36
+ do (setq *read-base* i)
+ do (assert (typep (read-from-string integer-string) 'integer)))))
+
+(let ((*read-base* *read-base*))
+ (dolist (symbol-string '("A." "a." "Z." "z."
+
+ "+.9eA" "+.9ea"
+
+ "0.A" "0.a" "0.Z" "0.z"
+
+ "9eA" "9ea" "9e+A" "9e+a" "9e-A" "9e-a"
+ "Ae9" "ae9" "Ae+9" "ae+9" "Ae-9" "ae-9"
+
+ "A.0" "A.0e10" "a.0" "a.0e10"))
+ (loop for i from 2 to 36
+ do (setq *read-base* i)
+ do (assert (typep (read-from-string symbol-string) 'symbol)))))