properly compose readtables
This commit is contained in:
parent
443f998531
commit
74d5706c20
|
@ -6,11 +6,9 @@
|
||||||
[2d-read-syntax read-syntax]
|
[2d-read-syntax read-syntax]
|
||||||
[2d-get-info get-info]))
|
[2d-get-info get-info]))
|
||||||
|
|
||||||
(define 2d-readtable (make-2d-readtable))
|
|
||||||
|
|
||||||
(define (wrap-reader p)
|
(define (wrap-reader p)
|
||||||
(lambda args
|
(lambda args
|
||||||
(parameterize ([current-readtable 2d-readtable])
|
(parameterize ([current-readtable (make-2d-readtable)])
|
||||||
(apply p args))))
|
(apply p args))))
|
||||||
|
|
||||||
(define-values (2d-read 2d-read-syntax 2d-get-info)
|
(define-values (2d-read 2d-read-syntax 2d-get-info)
|
||||||
|
|
|
@ -23,13 +23,13 @@ example uses:
|
||||||
(provide make-2d-readtable)
|
(provide make-2d-readtable)
|
||||||
|
|
||||||
(define (make-2d-readtable)
|
(define (make-2d-readtable)
|
||||||
(define previous-readtable (current-readtable))
|
|
||||||
(make-readtable
|
(make-readtable
|
||||||
#f
|
#f
|
||||||
#\2
|
#\2
|
||||||
'dispatch-macro
|
'dispatch-macro
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(char port)
|
[(char port)
|
||||||
|
(define previous-readtable (current-readtable))
|
||||||
(define-values (line col pos) (port-next-location port))
|
(define-values (line col pos) (port-next-location port))
|
||||||
|
|
||||||
;; the "-2"s here are because the initial line and column
|
;; the "-2"s here are because the initial line and column
|
||||||
|
@ -40,6 +40,7 @@ example uses:
|
||||||
(and pos (- pos 2))
|
(and pos (- pos 2))
|
||||||
read/recursive previous-readtable)]
|
read/recursive previous-readtable)]
|
||||||
[(char port source _line _col _pos)
|
[(char port source _line _col _pos)
|
||||||
|
(define previous-readtable (current-readtable))
|
||||||
(dispatch-proc char port source _line _col _pos
|
(dispatch-proc char port source _line _col _pos
|
||||||
(λ (a b c) (read-syntax/recursive source a b c))
|
(λ (a b c) (read-syntax/recursive source a b c))
|
||||||
previous-readtable)])))
|
previous-readtable)])))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user