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,19 +54,25 @@ 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(),
|
||||||
end = escape_char_stack.rend();
|
end = escape_char_stack.rend();
|
||||||
|
|
||||||
for (; iter != end; ++iter) {
|
for (; iter != end; ++iter) {
|
||||||
if (lexer->lookahead != *iter) {
|
if (lexer->lookahead != *iter) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
advance(lexer);
|
|
||||||
}
|
}
|
||||||
|
advance(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_triple_double_quote(TSLexer *lexer) {
|
bool is_triple_double_quote(TSLexer *lexer) {
|
||||||
|
@ -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