Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ static inline void advance(TSLexer *lexer) { lexer->advance(lexer, false); }

static inline void skip(TSLexer *lexer) { lexer->advance(lexer, true); }

static inline bool is_identifier_char(int32_t c) { return iswalnum(c) || c == '_' || c == '$'; }

static bool scan_template_chars(TSLexer *lexer) {
lexer->result_symbol = TEMPLATE_CHARS;
for (bool has_content = false;; has_content = true) {
Expand Down Expand Up @@ -199,7 +201,7 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo
}
skip(lexer);

if (!iswalpha(lexer->lookahead)) {
if (!is_identifier_char(lexer->lookahead)) {
return false;
}

Expand All @@ -210,7 +212,7 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo
skip(lexer);
}

if (!iswalpha(lexer->lookahead)) {
if (!is_identifier_char(lexer->lookahead)) {
return false;
}
break;
Expand Down
24 changes: 24 additions & 0 deletions test/corpus/semicolon_insertion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ a
a
instanceofX;

a
in_b;

a
in1;

a
in$;

a
instanceof_;

---

(program
Expand All @@ -146,6 +158,18 @@ a

(expression_statement (binary_expression (identifier) (identifier)))

(expression_statement (identifier))
(expression_statement (identifier))

(expression_statement (identifier))
(expression_statement (identifier))

(expression_statement (identifier))
(expression_statement (identifier))

(expression_statement (identifier))
(expression_statement (identifier))

(expression_statement (identifier))
(expression_statement (identifier)))

Expand Down