read: bytevectors

This commit is contained in:
Peter McGoron 2024-09-27 15:45:30 -04:00
parent b94e12ee33
commit 3c0508211f
1 changed files with 11 additions and 1 deletions

View File

@ -442,6 +442,7 @@
readtable:read-improper-cdr) readtable:read-improper-cdr)
port))) port)))
;;; Read strictly a proper list. This assumes that BOL has been read.
(define readtable:read-proper-list (define readtable:read-proper-list
(lambda (table port) (lambda (table port)
(readtable:read-list-loop (readtable:table-for-list (readtable:read-list-loop (readtable:table-for-list
@ -451,6 +452,12 @@
"expected proper list")) "expected proper list"))
port))) 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 "#" ;;; Reader for stuff that start with "#"
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -600,6 +607,9 @@
(cons "false" (lambda unused #f)) (cons "false" (lambda unused #f))
(cons "t" (lambda unused #t)) (cons "t" (lambda unused #t))
(cons "f" (lambda unused #f)) (cons "f" (lambda unused #f))
(cons "u8" (lambda (toplevel port)
(list 'bytevector
(readtable:expect-proper-list toplevel port))))
(cons "!fold-case" (cons "!fold-case"
(lambda (toplevel port) (lambda (toplevel port)
(port 'fold-case! #t) (port 'fold-case! #t)
@ -736,4 +746,4 @@
(read-all "#0=(#0# not unix)") (read-all "#0=(#0# not unix)")
(read-all "#!no-fold-case #!fold-case #!NO-FOLD-CASE #false") (read-all "#!no-fold-case #!fold-case #!NO-FOLD-CASE #false")
(read-all "#!fold-case #TRUE") (read-all "#!fold-case #TRUE")
(read-all "#u8(x y z w)")