Skip to content

Commit c99692d

Browse files
committed
Fix overly greedy digits
This fixes several rules that were using greedy repetition operators. The problem with `(DIGIT|_)* DIGIT` is that the first repetition consumes all of the digits. I actually don't know exactly why the original rules were written in this particular way. I'm guessing they were intending to express that there must be at least one digit. However, just having `_`* should be sufficient.
1 parent 11f84ce commit c99692d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tokens.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ INTEGER_LITERAL ->
445445
446446
DEC_LITERAL -> DEC_DIGIT (DEC_DIGIT|`_`)*
447447
448-
BIN_LITERAL -> `0b` (BIN_DIGIT|`_`)* BIN_DIGIT (BIN_DIGIT|`_`)*
448+
BIN_LITERAL -> `0b` `_`* BIN_DIGIT (BIN_DIGIT|`_`)*
449449
450-
OCT_LITERAL -> `0o` (OCT_DIGIT|`_`)* OCT_DIGIT (OCT_DIGIT|`_`)*
450+
OCT_LITERAL -> `0o` `_`* OCT_DIGIT (OCT_DIGIT|`_`)*
451451
452-
HEX_LITERAL -> `0x` (HEX_DIGIT|`_`)* HEX_DIGIT (HEX_DIGIT|`_`)*
452+
HEX_LITERAL -> `0x` `_`* HEX_DIGIT (HEX_DIGIT|`_`)*
453453
454454
BIN_DIGIT -> [`0`-`1`]
455455
@@ -561,7 +561,7 @@ FLOAT_LITERAL ->
561561
| DEC_LITERAL (`.` DEC_LITERAL)? FLOAT_EXPONENT SUFFIX?
562562
563563
FLOAT_EXPONENT ->
564-
(`e`|`E`) (`+`|`-`)? (DEC_DIGIT|`_`)* DEC_DIGIT (DEC_DIGIT|`_`)*
564+
(`e`|`E`) (`+`|`-`)? `_`* DEC_DIGIT (DEC_DIGIT|`_`)*
565565
```
566566

567567
r[lex.token.literal.float.form]

0 commit comments

Comments
 (0)