rely on syntax objects preserving source locations
Rely on the representation of source locations in syntax objects, so that its marshaling can take care of problems with absolute paths.
This commit is contained in:
parent
6b8490b78b
commit
904f83ecf3
|
@ -68,31 +68,26 @@
|
||||||
[(_ s e)
|
[(_ s e)
|
||||||
(if (string? (syntax-e #'s))
|
(if (string? (syntax-e #'s))
|
||||||
#'s
|
#'s
|
||||||
(with-syntax ([src (syntax-source #'e)]
|
(with-syntax ([loc (datum->syntax #f 'loc #'e)])
|
||||||
[line (syntax-line #'e)]
|
#'(check-pre-part e (quote-syntax loc))))]))
|
||||||
[col (syntax-column #'e)]
|
|
||||||
[pos (syntax-position #'e)]
|
|
||||||
[span (syntax-column #'e)])
|
|
||||||
#'(check-pre-part e (vector 'src 'line 'col 'pos 'span))))]))
|
|
||||||
|
|
||||||
(define (check-pre-part v s)
|
(define (check-pre-part v loc-stx)
|
||||||
(if (pre-part? v)
|
(if (pre-part? v)
|
||||||
v
|
v
|
||||||
(error
|
(error
|
||||||
(format
|
(format
|
||||||
"~a: not valid in document body (need a pre-part for decode) in: ~e"
|
"~a: not valid in document body (need a pre-part for decode) in: ~e"
|
||||||
(cond
|
(cond
|
||||||
[(and (vector-ref s 0)
|
[(and (syntax-source loc-stx)
|
||||||
(vector-ref s 1))
|
(syntax-line loc-stx))
|
||||||
(format "~a:~a:~a"
|
(format "~a:~a:~a"
|
||||||
(vector-ref s 0)
|
(syntax-source loc-stx)
|
||||||
(vector-ref s 1)
|
(syntax-line loc-stx)
|
||||||
(vector-ref s 2))]
|
(syntax-column loc-stx))]
|
||||||
[(and (vector-ref s 0)
|
[(and (syntax-source loc-stx)
|
||||||
(vector-ref s 3))
|
(syntax-position loc-stx))
|
||||||
(format "~a:::~a"
|
(format "~a:::~a"
|
||||||
(vector-ref s 0)
|
(syntax-source loc-stx)
|
||||||
(vector-ref s 1)
|
(syntax-position loc-stx))]
|
||||||
(vector-ref s 3))]
|
|
||||||
[else 'document])
|
[else 'document])
|
||||||
v))))
|
v))))
|
||||||
|
|
|
@ -3,20 +3,6 @@
|
||||||
|
|
||||||
(provide quote-syntax/loc)
|
(provide quote-syntax/loc)
|
||||||
|
|
||||||
(define-syntax (quote-syntax/loc stx)
|
;; Source locations are now preserved in the bytecode form of `quote-syntax`:
|
||||||
(syntax-case stx ()
|
(define-syntax-rule (quote-syntax/loc d)
|
||||||
[(_ id)
|
(quote-syntax d))
|
||||||
(with-syntax ([loc (let ([s #'id])
|
|
||||||
(vector (syntax-source s)
|
|
||||||
(syntax-line s)
|
|
||||||
(syntax-column s)
|
|
||||||
(syntax-position s)
|
|
||||||
(syntax-span s)))])
|
|
||||||
#'(let ([s (*quote-syntax/loc id)])
|
|
||||||
(datum->syntax s (syntax-e s) 'loc s)))]))
|
|
||||||
|
|
||||||
(define-syntax *quote-syntax/loc
|
|
||||||
(syntax-rules ()
|
|
||||||
[(_ (sub ...)) (datum->syntax #f (list (quote-syntax/loc sub) ...))]
|
|
||||||
[(_ id) (quote-syntax id)]))
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user