preserves/implementations/racket/preserves/preserves/main.rkt

39 lines
1.4 KiB
Racket
Raw Normal View History

2018-08-19 21:13:42 +00:00
#lang racket/base
2018-08-27 09:24:11 +00:00
;; Preserve, as in Fruit Preserve, as in a remarkably weak pun on pickling/dehydration etc
2018-08-19 21:13:42 +00:00
2020-12-30 15:43:18 +00:00
(provide (all-from-out "record.rkt")
(all-from-out "float.rkt")
(all-from-out "annotation.rkt")
(all-from-out "order.rkt")
2018-08-19 21:13:42 +00:00
2020-12-30 15:43:18 +00:00
(all-from-out "read-binary.rkt")
(all-from-out "read-text.rkt")
(all-from-out "write-binary.rkt")
(all-from-out "write-text.rkt")
2020-12-30 15:43:18 +00:00
read-preserve)
2020-12-30 15:43:18 +00:00
(require "record.rkt")
(require "float.rkt")
(require "annotation.rkt")
(require "order.rkt")
2020-12-30 15:43:18 +00:00
(require "read-binary.rkt")
(require "read-text.rkt")
(require "write-binary.rkt")
(require "write-text.rkt")
2020-12-30 15:43:18 +00:00
(define (read-preserve [in-port (current-input-port)]
#:read-syntax? [read-syntax? #f]
2021-01-29 11:03:28 +00:00
#:decode-pointer [decode-pointer #f]
2020-12-30 15:43:18 +00:00
#:source [source (object-name in-port)])
(define b (peek-byte in-port))
(cond [(eof-object? b) b]
2021-01-29 11:03:28 +00:00
[(<= #x80 b #xBF) (read-preserve/binary in-port
#:read-syntax? read-syntax?
#:decode-pointer decode-pointer)]
[else (read-preserve/text in-port
#:read-syntax? read-syntax?
#:decode-pointer decode-pointer
#:source source)]))