Skip to content

Commit

Permalink
move to returning 'did scan single-line block comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jackschu committed Jun 30, 2024
1 parent 19d6fcb commit 69556fc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static bool scan_template_chars(TSLexer *lexer) {
}
}

static bool scan_whitespace_and_comments(TSLexer *lexer, bool *scanned_comment, bool *saw_block_newline) {
static bool scan_whitespace_and_comments(TSLexer *lexer, bool *scanned_comment, bool *saw_single_block_comment) {
bool saw_block_newline = false;
for (;;) {
while (iswspace(lexer->lookahead)) {
skip(lexer);
Expand All @@ -70,12 +71,13 @@ static bool scan_whitespace_and_comments(TSLexer *lexer, bool *scanned_comment,
skip(lexer);
if (lexer->lookahead == '/') {
skip(lexer);
*saw_single_block_comment = !saw_block_newline;
*scanned_comment = true;
break;
}
} else if (lexer->lookahead == '\n' || lexer->lookahead == 0x2028 ||
lexer->lookahead == 0x2029) {
*saw_block_newline = true;
saw_block_newline = true;
skip(lexer);
} else {
skip(lexer);
Expand All @@ -94,19 +96,19 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo
lexer->result_symbol = AUTOMATIC_SEMICOLON;
lexer->mark_end(lexer);

bool saw_comment_newline = false;
bool saw_single_block_comment = true;
for (;;) {
if (lexer->lookahead == 0) {
return true;
}

if (lexer->lookahead == '/') {
if (!scan_whitespace_and_comments(lexer, scanned_comment, &saw_comment_newline)) {
if (!scan_whitespace_and_comments(lexer, scanned_comment, &saw_single_block_comment)) {
return false;
}

if (comment_condition && lexer->lookahead != ',' && lexer->lookahead != '=') {
return saw_comment_newline;
return !saw_single_block_comment;
}
}

Expand All @@ -133,7 +135,7 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo



if (!scan_whitespace_and_comments(lexer, scanned_comment, &saw_comment_newline)) {
if (!scan_whitespace_and_comments(lexer, scanned_comment, &saw_single_block_comment)) {
return false;
}

Expand Down

0 comments on commit 69556fc

Please sign in to comment.