[plt-scheme] Syntax Reader and Macros
I am having two problems with the way syntax objects are read. I
am currently trying to evaluate expressions found in the middle
of strings, using the #%datum macro. The first problem is that
when I use read-syntax to get a syntax object representing the
expression, I can find no way to attach it to the correct
lexical environment. I get errors on anything I do, since it
seems to be attached to an empty lexical environment, with not
even #%app, #%datum, or #%top defined. If I use read and
datum->syntax-object, I can attach it to the right lexical
environment, but I lose the syntax location information needed
for syntax coloring and error reporting. How can I attach an
already built syntax object to a particular lexical environment?
Also, when I read characters and expressions from a syntax
object converted into a string, I read one character per logical
character in the string. In the code, however, a character such
as a newline can be represented as a newline directly in the
input, \n, \12, \012, \xA, or \x0A. This makes it rather
difficult to predict how many characters in the input file
correspond to one character in the string, which makes it hard
to calculate offsets for highlighting and error reporting in
various parts of that string. Is there any way to tell how many
characters one character in a string corresponded to originally?
Would it be possible to attach some table to string syntax
objects that tells you which characters in that string
correspond to multiple characters in the source? Or does anyone
else have any other suggestions?
Thanks,
Brian