aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-09-27 15:45:30 -0400
committerGravatar Peter McGoron 2024-09-27 15:45:30 -0400
commit3c0508211ffacb65dca63dad37a1009ca792275d (patch)
tree4067c6ac057fb5d5b6b14454d18a7451ced76e99
parentread: hash constants and directives (diff)
read: bytevectors
-rw-r--r--read.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/read.scm b/read.scm
index df2f97c..bb84f0c 100644
--- a/read.scm
+++ b/read.scm
@@ -442,6 +442,7 @@
readtable:read-improper-cdr)
port)))
+;;; Read strictly a proper list. This assumes that BOL has been read.
(define readtable:read-proper-list
(lambda (table port)
(readtable:read-list-loop (readtable:table-for-list
@@ -451,6 +452,12 @@
"expected proper list"))
port)))
+(define readtable:expect-proper-list
+ (lambda (table port)
+ (if (not (eqv? (port 'read) %bol))
+ (error 'expect-port-list 'no-list-found)
+ (readtable:read-proper-list table port))))
+
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Reader for stuff that start with "#"
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -600,6 +607,9 @@
(cons "false" (lambda unused #f))
(cons "t" (lambda unused #t))
(cons "f" (lambda unused #f))
+ (cons "u8" (lambda (toplevel port)
+ (list 'bytevector
+ (readtable:expect-proper-list toplevel port))))
(cons "!fold-case"
(lambda (toplevel port)
(port 'fold-case! #t)
@@ -736,4 +746,4 @@
(read-all "#0=(#0# not unix)")
(read-all "#!no-fold-case #!fold-case #!NO-FOLD-CASE #false")
(read-all "#!fold-case #TRUE")
-
+(read-all "#u8(x y z w)")