From 3c0508211ffacb65dca63dad37a1009ca792275d Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Fri, 27 Sep 2024 15:45:30 -0400 Subject: [PATCH] read: bytevectors --- read.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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)")