Fix a case with an empty body with comment(s)

This commit is contained in:
Andrew Hlynskyi
2023-04-08 15:26:24 +03:00
committed by Michael Hoffmann
parent 9903dc0b57
commit 4e33af0710
2 changed files with 25 additions and 6 deletions

View File

@@ -98,6 +98,8 @@ public:
return false;
}
if (valid_symbols[SHIM]) {
lexer->mark_end(lexer);
while(skip_comment(lexer));
if (lexer->lookahead != '}') {
return accept_inplace(lexer, SHIM);
}
@@ -271,6 +273,20 @@ private:
return iswxdigit(lexer->lookahead);
}
bool skip_comment(TSLexer* lexer) {
while (iswspace(lexer->lookahead)) {
skip(lexer);
}
if (lexer->lookahead != '#') {
return false;
}
skip(lexer);
while (lexer->lookahead != '\n') {
skip(lexer);
}
return true;
}
bool in_context_type(ContextType type) {
if (context_stack.empty()) {
return false;