Skip to content

Commit

Permalink
fix: automatic semicolon should be inserted given a number decimal a …
Browse files Browse the repository at this point in the history
…newline
  • Loading branch information
jackschu committed Jul 5, 2024
1 parent f5af62c commit 12e4537
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo

switch (lexer->lookahead) {
case ',':
case '.':
case ':':
case ';':
case '*':
Expand All @@ -169,6 +168,11 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo
case '/':
return false;

// Insert a semicolon before decimals literals but not otherwise.
case '.':
skip(lexer);
return iswdigit(lexer->lookahead);

// Insert a semicolon before `--` and `++`, but not before binary `+` or `-`.
case '+':
skip(lexer);
Expand Down
2 changes: 2 additions & 0 deletions test/corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Numbers
0b1_000_000
1_2_3
12_3.4_5e6_7
.4_5e6_7
0b1_000_000n
01
00000123
Expand All @@ -33,6 +34,7 @@ Numbers
(expression_statement (number))
(expression_statement (number))
(expression_statement (number))
(expression_statement (number))
(expression_statement (number)))

============================================
Expand Down

0 comments on commit 12e4537

Please sign in to comment.