Simplified number regexes (#5430)

This commit is contained in:
Daniel X Moore 2022-10-25 09:23:39 -07:00 committed by GitHub
parent 5748210ea8
commit 98a23315d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 20 additions and 14 deletions

View File

@ -2605,9 +2605,9 @@ NUMBER = <span class="hljs-regexp">///
^ 0b[01](?:_?[01])*n? | <span class="hljs-comment"># binary</span>
^ 0o[0-7](?:_?[0-7])*n? | <span class="hljs-comment"># octal</span>
^ 0x[\da-f](?:_?[\da-f])*n? | <span class="hljs-comment"># hex</span>
^ \d+n | <span class="hljs-comment"># decimal bigint</span>
^ (?:\d(?:_?\d)*)? \.? (?:\d(?:_?\d)*)+ <span class="hljs-comment"># decimal</span>
(?:e[+-]? (?:\d(?:_?\d)*)+ )?
^ \d+(?:_\d+)*n | <span class="hljs-comment"># decimal bigint</span>
^ (?:\d+(?:_\d+)*)? \.? \d+(?:_\d+)* <span class="hljs-comment"># decimal</span>
(?:e[+-]? \d+(?:_\d+)* )?
</span></pre></div></div>
</li>

View File

@ -10237,7 +10237,7 @@ LEVEL_ACCESS = <span class="hljs-number">6</span> <span class="hljs-comment">#
<div class="content"><div class='highlight'><pre>TAB = <span class="hljs-string">&#x27; &#x27;</span>
SIMPLENUM = <span class="hljs-regexp">/^[+-]?(?:\d(?:_?\d)*)+$/</span>
SIMPLENUM = <span class="hljs-regexp">/^[+-]?\d+(?:_\d+)*$/</span>
SIMPLE_STRING_OMIT = <span class="hljs-regexp">/\s*\n\s*/g</span>
LEADING_BLANK_LINE = <span class="hljs-regexp">/^[^\n\S]*\n/</span>
TRAILING_BLANK_LINE = <span class="hljs-regexp">/\n[^\n\S]*$/</span>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29389,6 +29389,9 @@ test "BigInt exists", ->
test "Parser recognizes decimal BigInt literals", ->
eq 42n, BigInt 42
test "Parser recognizes decimal BigInt literals with separator", ->
eq 1_000n, BigInt 1000
test "Parser recognizes binary BigInt literals", ->
eq 42n, 0b101010n

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1806,7 +1806,7 @@
// Is this an attribute with a value?
}(?:\\s*:\\s*${JSX_IDENTIFIER_PART})?)([^\\S]*=(?!=))?`);
NUMBER = /^0b[01](?:_?[01])*n?|^0o[0-7](?:_?[0-7])*n?|^0x[\da-f](?:_?[\da-f])*n?|^\d+n|^(?:\d(?:_?\d)*)?\.?(?:\d(?:_?\d)*)+(?:e[+-]?(?:\d(?:_?\d)*)+)?/i; // binary
NUMBER = /^0b[01](?:_?[01])*n?|^0o[0-7](?:_?[0-7])*n?|^0x[\da-f](?:_?[\da-f])*n?|^\d+(?:_\d+)*n|^(?:\d+(?:_\d+)*)?\.?\d+(?:_\d+)*(?:e[+-]?\d+(?:_\d+)*)?/i; // binary
// octal
// hex
// decimal bigint

View File

@ -8758,7 +8758,7 @@
// Tabs are two spaces for pretty printing.
TAB = ' ';
SIMPLENUM = /^[+-]?(?:\d(?:_?\d)*)+$/;
SIMPLENUM = /^[+-]?\d+(?:_\d+)*$/;
SIMPLE_STRING_OMIT = /\s*\n\s*/g;

View File

@ -1310,9 +1310,9 @@ NUMBER = ///
^ 0b[01](?:_?[01])*n? | # binary
^ 0o[0-7](?:_?[0-7])*n? | # octal
^ 0x[\da-f](?:_?[\da-f])*n? | # hex
^ \d+n | # decimal bigint
^ (?:\d(?:_?\d)*)? \.? (?:\d(?:_?\d)*)+ # decimal
(?:e[+-]? (?:\d(?:_?\d)*)+ )?
^ \d+(?:_\d+)*n | # decimal bigint
^ (?:\d+(?:_\d+)*)? \.? \d+(?:_\d+)* # decimal
(?:e[+-]? \d+(?:_\d+)* )?
# decimal without support for numeric literal separators for reference:
# \d*\.?\d+ (?:e[+-]?\d+)?
///i

View File

@ -5772,7 +5772,7 @@ LEVEL_ACCESS = 6 # ...[0]
# Tabs are two spaces for pretty printing.
TAB = ' '
SIMPLENUM = /^[+-]?(?:\d(?:_?\d)*)+$/
SIMPLENUM = /^[+-]?\d+(?:_\d+)*$/
SIMPLE_STRING_OMIT = /\s*\n\s*/g
LEADING_BLANK_LINE = /^[^\n\S]*\n/
TRAILING_BLANK_LINE = /\n[^\n\S]*$/

View File

@ -7,6 +7,9 @@ test "BigInt exists", ->
test "Parser recognizes decimal BigInt literals", ->
eq 42n, BigInt 42
test "Parser recognizes decimal BigInt literals with separator", ->
eq 1_000n, BigInt 1000
test "Parser recognizes binary BigInt literals", ->
eq 42n, 0b101010n