Open disnet opened 7 years ago
So you're saying this should be tokenized as foo$
and {...}
?
If so, I would find this behavior surprising as it is at odds w/ template literal syntax.
I also would find that behavior surprising...it's the current behavior :)
syntax m = function (ctx) {
return #`foo${x}`;
}
m
expands to:
foo$;
{
x;
}
Sorry for the unclear issue description. Was in a rush the other day.
Haha! The title is a directive, not a description.
I know what's going on and think I have a solution. I'll check it out tonight.
It's never as easy as I think. The source of the problem is simple. Syntax templates are being lexed as regular source strings, bookended by LSYNTAX
and RSYNTAX
tokens. They are then parsed and the identifier $
coming before {...}
is consumed. This doesn't work for foo${...}
as foo$
is a valid identifier.
My first thought was to make $
a terminating character. But that fails unless it's followed by {
.
Another strategy is to tokenize syntax templates just as we do string templates. Then do a second pass and run the template elements through the reader. This might work as a hack, but source information (line & column number) is gonna be all messed up.
The "correct" answer is probably to add multi-character dispatch. It looks like more and more weight is building up to a rewrite of the reader.
As soon as things die down a bit at work I plan to prototype something in PureScript using parser combinators.
eg: