[plt-scheme] Changing source location information

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Aug 4 10:44:59 EDT 2009

On Aug  4, Jens Axel Søgaard wrote:
> 
> > To make it work better, you'll want to scan the resulting syntax,
> > and adjust source information from the string to correspond to the
> > location in the real source.
> 
> That's exactly what I was hoping to avoid,
> 
> I am now experimeting a little with relocate-input-port.

I was about to take back the scan+change and suggest the relocated
thing (I had a vague memory of something relevant, and took a while to
reconstruct) -- but I'm not sure that it will work.

You'll need to grab the source information from the string, and use
that to do the relocation.  This will require one hack, where you'd
distinguish Scheme strings from at-exp strings, since the latter
includes the quotation marks -- or better than that, just forbid
Scheme strings.  But things will also not work right when the string
contents is not in direct correspondence with the source, like when
you have escapes, or in the at-exp case, when you have an indented
body.  So maybe the scan+change is unavoidable, or implement a custom
port that can change locations information dynamically.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.