scanner: skip whitespace before check block comment
This commit is contained in:
parent
9828b023cd
commit
7a7c699be2
1 changed files with 18 additions and 15 deletions
|
@ -54,6 +54,12 @@ namespace {
|
||||||
lexer->advance(lexer, true);
|
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) {
|
bool is_text_block_end(TSLexer *lexer) {
|
||||||
vector<int16_t>::reverse_iterator
|
vector<int16_t>::reverse_iterator
|
||||||
iter = escape_char_stack.rbegin(),
|
iter = escape_char_stack.rbegin(),
|
||||||
|
@ -85,9 +91,7 @@ namespace {
|
||||||
lexer->result_symbol = TEXT_BLOCK_START;
|
lexer->result_symbol = TEXT_BLOCK_START;
|
||||||
lexer->mark_end(lexer);
|
lexer->mark_end(lexer);
|
||||||
|
|
||||||
while (lexer->lookahead != 0 && iswspace(lexer->lookahead)) {
|
skip_whitespaces(lexer);
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lexer->lookahead != '|') {
|
if (lexer->lookahead != '|') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,9 +118,7 @@ namespace {
|
||||||
lexer->result_symbol = TEXT_BLOCK_END;
|
lexer->result_symbol = TEXT_BLOCK_END;
|
||||||
lexer->mark_end(lexer);
|
lexer->mark_end(lexer);
|
||||||
|
|
||||||
while (lexer->lookahead != 0 && iswspace(lexer->lookahead)) {
|
skip_whitespaces(lexer);
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_text_block_end(lexer)) {
|
if (is_text_block_end(lexer)) {
|
||||||
lexer->mark_end(lexer);
|
lexer->mark_end(lexer);
|
||||||
|
@ -137,6 +139,7 @@ namespace {
|
||||||
lexer->result_symbol = BLOCK_COMMENT;
|
lexer->result_symbol = BLOCK_COMMENT;
|
||||||
lexer->mark_end(lexer);
|
lexer->mark_end(lexer);
|
||||||
|
|
||||||
|
skip_whitespaces(lexer);
|
||||||
// Check start of block comment
|
// Check start of block comment
|
||||||
if (!is_triple_double_quote(lexer)) {
|
if (!is_triple_double_quote(lexer)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue