Make module reader not return negative span when port location changes.

This commit is contained in:
Eric Dobson 2014-02-04 23:58:55 -08:00
parent 021328fa6d
commit ec4793ad16

View File

@ -188,7 +188,7 @@
[body (wrap-module-begin body)] [body (wrap-module-begin body)]
[all-loc (vector src line col pos [all-loc (vector src line col pos
(let-values ([(l c p) (port-next-location port)]) (let-values ([(l c p) (port-next-location port)])
(and p pos (- p pos))))] (and p pos (max 0 (- p pos)))))]
[p-name (object-name port)] [p-name (object-name port)]
[name (if (path? p-name) [name (if (path? p-name)
(let-values ([(base name dir?) (split-path p-name)]) (let-values ([(base name dir?) (split-path p-name)])
@ -199,9 +199,10 @@
(if stx? (if stx?
(datum->syntax (datum->syntax
#f v (vector src line col pos #f v (vector src line col pos
(and pos (- (or (syntax-position modpath) (and pos (max 0
(add1 pos)) (- (or (syntax-position modpath)
pos)))) (add1 pos))
pos)))))
v))] v))]
[r `(,(tag-src 'module) ,(tag-src name) ,lang ,body)]) [r `(,(tag-src 'module) ,(tag-src name) ,lang ,body)])
(if stx? (datum->syntax #f r all-loc) r))) (if stx? (datum->syntax #f r all-loc) r)))
@ -249,7 +250,7 @@
(datum->syntax #f (datum->syntax #f
guarded-spec guarded-spec
(vector src spec-line spec-col spec-pos (vector src spec-line spec-col spec-pos
(- spec-end-pos spec-pos))) (max 0 (- spec-end-pos spec-pos))))
guarded-spec)) guarded-spec))
(loop (cdr specs)))) (loop (cdr specs))))
(bad spec #f)))))) (bad spec #f))))))