diff --git a/read.scm b/read.scm index a2b7166..29ab362 100644 --- a/read.scm +++ b/read.scm @@ -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")