Desk
Desk copied to clipboard
Support comments right after `,` or `;`
Syntax
?, // hahaha
?; // yeah
Why?
Sometimes it’s slightly or super annoying to write a comment for an expression.
For example;
// Here is a comment for whole let expression
$ /* Here is a comment for the hole */ ?;
to be:
// Here is a comment for the whole let expression
$ ?; // Here is a comment for the hole
And
*<
1,
2,
// Here is a comment for 3
3,
>
to be:
*<
1,
2,
3, // Here is a comment for 3
>
How to avoid ambiguity?
Answer: We introduce new tokens, CommaComment and StmtEndComment.
CommaComment: ",[\s--\r\n]*//";
StmtEndComment: ";[\s--\r\n]*//";