properly compose readtables
This commit is contained in:
parent
443f998531
commit
74d5706c20
|
@ -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)
|
||||
|
|
|
@ -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)])))
|
||||
|
|
Loading…
Reference in New Issue
Block a user