Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow auto-semicolon insertion before prefix-less decimal literals #327

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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: 5 additions & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo

switch (lexer->lookahead) {
case ',':
case '.':
case ':':
case ';':
case '*':
Expand All @@ -148,6 +147,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