blah. feeling all drained, should probably go to bed but depression, y'know?
I'm having trouble with comments in the lang formatter. I can easily grab them in the scanner, the problem is what to do next.
I can create a new token for the comment, but the grammar isn't expecting "or comment" everywhere, so the parser needs updating, and I don't want to do the brute force work that implies.
I want to end up with a comment node in the AST. I can nearly treat comments as statements, except that:
a + // neat
b;
is a legal expression with an embedded comment.
Of course, it's my language and I can just take the easy way out and say that comments can only appear where a statement is valid, although then:
if (false)
// Don't call
explodeKitten();
stops working. (Also, I'd probably need to update the C version, and I'm trying to avoid that)
I also tried attaching the comment to the previous token, but that failed in a couple of ways, not least of which is that my sample script starts with two leading comments.
I'm fairly sure that creating a comment token and updating the parser to deal with it is the right approach, I'm just having trouble working out what 'deal with it' looks like.