From 06fcc23c24c17b7284350b2696a0fb5e65f7dbd2 Mon Sep 17 00:00:00 2001 From: "William J. Bowman" Date: Sun, 24 Nov 2013 18:20:32 -0500 Subject: [PATCH] * Parameterized comment-reader over 'unsyntax, for use with RACKETBLOCK pkgs/scribble-pkgs/scribble-lib/scribble/comment-reader.rkt original commit: 57dd977cb7acc0d1442c46a2e6059b48a13e95eb --- .../scribble-lib/scribble/comment-reader.rkt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/comment-reader.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/comment-reader.rkt index 8be38ec2..4ca0df39 100644 --- a/pkgs/scribble-pkgs/scribble-lib/scribble/comment-reader.rkt +++ b/pkgs/scribble-pkgs/scribble-lib/scribble/comment-reader.rkt @@ -1,18 +1,29 @@ - (module comment-reader scheme/base (provide (rename-out [*read read] [*read-syntax read-syntax]) make-comment-readtable) + (define unsyntaxer (make-parameter 'unsyntax)) + (define (*read [inp (current-input-port)]) - (parameterize ([current-readtable (make-comment-readtable)]) + (parameterize ([unsyntaxer (read-unsyntaxer inp)] + [current-readtable (make-comment-readtable)]) (read/recursive inp))) (define (*read-syntax src [port (current-input-port)]) - (parameterize ([current-readtable (make-comment-readtable)]) + (parameterize ([unsyntaxer (read-unsyntaxer port)] + [current-readtable (make-comment-readtable)]) (read-syntax/recursive src port))) + (define (read-unsyntaxer port) + (let-values ([(l c p) (port-next-location port)]) + (if (eq? (read port) '#:unsyntax) + (read port) + (begin + (set-port-next-location! port l c p) + 'unsyntax)))) + (define (make-comment-readtable #:readtable [rt (current-readtable)]) (make-readtable rt #\; 'terminating-macro @@ -35,7 +46,7 @@ (when (equal? #\space (peek-char port)) (read-char port)) `(code:comment - (unsyntax + (,(unsyntaxer) (t ,@(append-strings (let loop () @@ -71,5 +82,3 @@ (list `(hspace ,(- (cdar m) (caar m)))) (preserve-space (substring s (cdar m)))) (list s))))) - -