diff options
| author | 2024-10-13 10:48:30 -0400 | |
|---|---|---|
| committer | 2024-10-13 10:48:30 -0400 | |
| commit | 0dab772a779e13a9c7f4b5ec1577c443ad70ad38 (patch) | |
| tree | 00d37f41e31fb89ea0d3de2272acdde37f0375ce | |
| parent | fix signs, make radix push more precise (diff) | |
add decimal number to toplevel readtable
| -rw-r--r-- | read.scm | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -34,6 +34,16 @@ ;;; ;;; All tokens are procedure-encapsulated objects, since the reader should ;;; never return a literal procedure. Each procedure has a TYPE message. +;;; +;;; ;;;;;;;;;;;;;;; +;;; Possible Improvements +;;; ;;;;;;;;;;;;;;; +;;; +;;; * A coherent API. +;;; * regex-based lexer. +;;; * A way to load readtables and read functions when the function is run, +;;; and not when functions are defined, without sacrificing performance. +;;; * Better Unicode handling. (load "chez-compat.scm") (load "util.scm") @@ -948,6 +958,14 @@ port))) (list readtable:update %bol readtable:vector))) +;;; Read a decimal number without prefixes. +(define readtable:create-number + (lambda (toplevel number-char _ port) + (readtable:act readtable:read-sign + number-char + (read:number-builder readtable:for-dec) + port))) + ;;; ;;;;;;;;;;;;;;;; ;;; Toplevel reader. ;;; ;;;;;;;;;;;;;;;; @@ -963,6 +981,8 @@ (list readtable:update %eol (readtable:error 'top "unbalanced list")) (list readtable:update #\# (readtable:next/old-as-acc readtable:hash)) + (list readtable:update '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) + readtable:create-number) (list readtable:update #\; (readtable:jump-discard readtable:read-to-newline))))) @@ -1061,3 +1081,4 @@ (read-all "#e10.5") (read-all "#d10.24f12") (read-all "#d-i") +(read-all "100i") |
