scanner: skip whitespace before check block comment

This commit is contained in:
Dmitriy Pleshevskiy 2023-06-16 18:32:09 +03:00
parent 9828b023cd
commit 7a7c699be2
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985

View file

@ -54,6 +54,12 @@ namespace {
lexer->advance(lexer, true);
}
void skip_whitespaces(TSLexer *lexer) {
while (lexer->lookahead != 0 && iswspace(lexer->lookahead)) {
skip(lexer);
}
}
bool is_text_block_end(TSLexer *lexer) {
vector<int16_t>::reverse_iterator
iter = escape_char_stack.rbegin(),
@ -85,9 +91,7 @@ namespace {
lexer->result_symbol = TEXT_BLOCK_START;
lexer->mark_end(lexer);
while (lexer->lookahead != 0 && iswspace(lexer->lookahead)) {
skip(lexer);
}
skip_whitespaces(lexer);
if (lexer->lookahead != '|') {
return false;
@ -114,9 +118,7 @@ namespace {
lexer->result_symbol = TEXT_BLOCK_END;
lexer->mark_end(lexer);
while (lexer->lookahead != 0 && iswspace(lexer->lookahead)) {
skip(lexer);
}
skip_whitespaces(lexer);
if (is_text_block_end(lexer)) {
lexer->mark_end(lexer);
@ -137,6 +139,7 @@ namespace {
lexer->result_symbol = BLOCK_COMMENT;
lexer->mark_end(lexer);
skip_whitespaces(lexer);
// Check start of block comment
if (!is_triple_double_quote(lexer)) {
return false;