Skip to content

Commit 8f1e626

Browse files
committed
fix: πŸ› syntax error on multiline class constant with comment
βœ… Closes: glayzzle#1151
1 parent b1168db commit 8f1e626

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

β€Žsrc/parser/class.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ module.exports = {
358358
this.next();
359359
}
360360

361-
if (this.peek() === "=") {
361+
if (this.peekSkipComments() === "=") {
362362
return [false, null];
363363
}
364364

@@ -386,6 +386,21 @@ module.exports = {
386386
return [nullable, type];
387387
},
388388

389+
peekSkipComments: function () {
390+
const lexerState = this.lexer.getState();
391+
let nextToken;
392+
393+
do {
394+
nextToken = this.lexer.lex();
395+
} while (
396+
nextToken === this.tok.T_COMMENT ||
397+
nextToken === this.tok.T_WHITESPACE
398+
);
399+
400+
this.lexer.setState(lexerState);
401+
return nextToken;
402+
},
403+
389404
/*
390405
* reading an interface
391406
* ```ebnf

0 commit comments

Comments
Β (0)