properly compose readtables

This commit is contained in:
Robby Findler 2013-03-11 18:52:10 -05:00
parent 443f998531
commit 74d5706c20
2 changed files with 3 additions and 4 deletions

View File

@ -6,11 +6,9 @@
[2d-read-syntax read-syntax]
[2d-get-info get-info]))
(define 2d-readtable (make-2d-readtable))
(define (wrap-reader p)
(lambda args
(parameterize ([current-readtable 2d-readtable])
(parameterize ([current-readtable (make-2d-readtable)])
(apply p args))))
(define-values (2d-read 2d-read-syntax 2d-get-info)

View File

@ -23,13 +23,13 @@ example uses:
(provide make-2d-readtable)
(define (make-2d-readtable)
(define previous-readtable (current-readtable))
(make-readtable
#f
#\2
'dispatch-macro
(case-lambda
[(char port)
(define previous-readtable (current-readtable))
(define-values (line col pos) (port-next-location port))
;; the "-2"s here are because the initial line and column
@ -40,6 +40,7 @@ example uses:
(and pos (- pos 2))
read/recursive previous-readtable)]
[(char port source _line _col _pos)
(define previous-readtable (current-readtable))
(dispatch-proc char port source _line _col _pos
(λ (a b c) (read-syntax/recursive source a b c))
previous-readtable)])))