Skip to content

Commit 4a63113

Browse files
authored
fix(tokeniser): update comment regex as the spec says (#566)
The old regex was needlessly complex with an additional requirement (didn't allow `*` to exist without another preceding `*`).
1 parent 093133c commit 4a63113

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/tokeniser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const tokenRe = {
1111
identifier: /[_-]?[A-Za-z][0-9A-Z_a-z-]*/y,
1212
string: /"[^"]*"/y,
1313
whitespace: /[\t\n\r ]+/y,
14-
comment: /((\/(\/.*|\*([^*]|\*[^/])*\*\/)[\t\n\r ]*)+)/y,
14+
comment: /\/\/.*|\/\*(.|\n)*?\*\//y,
1515
other: /[^\t\n\r 0-9A-Za-z]/y,
1616
};
1717

test/syntax/baseline/comment.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"type": "eof",
4+
"value": "",
5+
"trivia": "/** 25 **/\n"
6+
}
7+
]

test/syntax/idl/comment.webidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** 25 **/

0 commit comments

Comments
 (0)