simplify reader-base

pull/9/head
Matthew Butterick 11 years ago
parent 6a25de6462
commit 62a4d504c7

@ -1,18 +1,19 @@
#lang racket/base #lang racket/base
(require (only-in scribble/reader make-at-reader) (require (only-in scribble/reader make-at-reader) pollen/world)
pollen/world)
(provide (all-defined-out) (all-from-out pollen/world)) (provide make-reader-with-mode (all-from-out pollen/world))
(define read-inner (define read-inner (make-at-reader
(make-at-reader #:command-char EXPRESSION_DELIMITER #:syntax? #t #:inside? #t)) #:command-char EXPRESSION_DELIMITER
#:syntax? #t
#:inside? #t))
(define (make-pollen-read pollen-read-syntax-proc) (define (make-custom-read custom-read-syntax-proc)
(λ(p) (λ(p)
(syntax->datum (syntax->datum
(pollen-read-syntax-proc (object-name p) p)))) (custom-read-syntax-proc (object-name p) p))))
(define (make-pollen-read-syntax reader-mode) (define (make-custom-read-syntax reader-mode)
(λ (path-string p) (λ (path-string p)
(define file-contents (read-inner path-string p)) (define file-contents (read-inner path-string p))
(datum->syntax file-contents (datum->syntax file-contents
@ -24,6 +25,6 @@
(define-syntax-rule (make-reader-with-mode mode) (define-syntax-rule (make-reader-with-mode mode)
(begin (begin
(define reader-mode mode) (define reader-mode mode)
(define pollen-read-syntax (make-pollen-read-syntax reader-mode)) (define custom-read-syntax (make-custom-read-syntax reader-mode))
(define pollen-read (make-pollen-read pollen-read-syntax)) (define custom-read (make-custom-read custom-read-syntax))
(provide (rename-out [pollen-read read] [pollen-read-syntax read-syntax]) read-inner))) (provide (rename-out [custom-read read] [custom-read-syntax read-syntax]))))

Loading…
Cancel
Save