Desk icon indicating copy to clipboard operation
Desk copied to clipboard

Support comments right after `,` or `;`

Open ryo33 opened this issue 3 years ago • 0 comments

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]*//";

ryo33 avatar Jan 06 '23 12:01 ryo33