Simplified number regexes (#5430)
This commit is contained in:
parent
5748210ea8
commit
98a23315d7
|
@ -2605,9 +2605,9 @@ NUMBER = <span class="hljs-regexp">///
|
||||||
^ 0b[01](?:_?[01])*n? | <span class="hljs-comment"># binary</span>
|
^ 0b[01](?:_?[01])*n? | <span class="hljs-comment"># binary</span>
|
||||||
^ 0o[0-7](?:_?[0-7])*n? | <span class="hljs-comment"># octal</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>
|
^ 0x[\da-f](?:_?[\da-f])*n? | <span class="hljs-comment"># hex</span>
|
||||||
^ \d+n | <span class="hljs-comment"># decimal bigint</span>
|
^ \d+(?:_\d+)*n | <span class="hljs-comment"># decimal bigint</span>
|
||||||
^ (?:\d(?:_?\d)*)? \.? (?:\d(?:_?\d)*)+ <span class="hljs-comment"># decimal</span>
|
^ (?:\d+(?:_\d+)*)? \.? \d+(?:_\d+)* <span class="hljs-comment"># decimal</span>
|
||||||
(?:e[+-]? (?:\d(?:_?\d)*)+ )?
|
(?:e[+-]? \d+(?:_\d+)* )?
|
||||||
</span></pre></div></div>
|
</span></pre></div></div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -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">' '</span>
|
<div class="content"><div class='highlight'><pre>TAB = <span class="hljs-string">' '</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>
|
SIMPLE_STRING_OMIT = <span class="hljs-regexp">/\s*\n\s*/g</span>
|
||||||
LEADING_BLANK_LINE = <span class="hljs-regexp">/^[^\n\S]*\n/</span>
|
LEADING_BLANK_LINE = <span class="hljs-regexp">/^[^\n\S]*\n/</span>
|
||||||
TRAILING_BLANK_LINE = <span class="hljs-regexp">/\n[^\n\S]*$/</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
|
@ -29389,6 +29389,9 @@ test "BigInt exists", ->
|
||||||
test "Parser recognizes decimal BigInt literals", ->
|
test "Parser recognizes decimal BigInt literals", ->
|
||||||
eq 42n, BigInt 42
|
eq 42n, BigInt 42
|
||||||
|
|
||||||
|
test "Parser recognizes decimal BigInt literals with separator", ->
|
||||||
|
eq 1_000n, BigInt 1000
|
||||||
|
|
||||||
test "Parser recognizes binary BigInt literals", ->
|
test "Parser recognizes binary BigInt literals", ->
|
||||||
eq 42n, 0b101010n
|
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
|
@ -1806,7 +1806,7 @@
|
||||||
// Is this an attribute with a value?
|
// Is this an attribute with a value?
|
||||||
}(?:\\s*:\\s*${JSX_IDENTIFIER_PART})?)([^\\S]*=(?!=))?`);
|
}(?:\\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
|
// octal
|
||||||
// hex
|
// hex
|
||||||
// decimal bigint
|
// decimal bigint
|
||||||
|
|
|
@ -8758,7 +8758,7 @@
|
||||||
// Tabs are two spaces for pretty printing.
|
// Tabs are two spaces for pretty printing.
|
||||||
TAB = ' ';
|
TAB = ' ';
|
||||||
|
|
||||||
SIMPLENUM = /^[+-]?(?:\d(?:_?\d)*)+$/;
|
SIMPLENUM = /^[+-]?\d+(?:_\d+)*$/;
|
||||||
|
|
||||||
SIMPLE_STRING_OMIT = /\s*\n\s*/g;
|
SIMPLE_STRING_OMIT = /\s*\n\s*/g;
|
||||||
|
|
||||||
|
|
|
@ -1310,9 +1310,9 @@ NUMBER = ///
|
||||||
^ 0b[01](?:_?[01])*n? | # binary
|
^ 0b[01](?:_?[01])*n? | # binary
|
||||||
^ 0o[0-7](?:_?[0-7])*n? | # octal
|
^ 0o[0-7](?:_?[0-7])*n? | # octal
|
||||||
^ 0x[\da-f](?:_?[\da-f])*n? | # hex
|
^ 0x[\da-f](?:_?[\da-f])*n? | # hex
|
||||||
^ \d+n | # decimal bigint
|
^ \d+(?:_\d+)*n | # decimal bigint
|
||||||
^ (?:\d(?:_?\d)*)? \.? (?:\d(?:_?\d)*)+ # decimal
|
^ (?:\d+(?:_\d+)*)? \.? \d+(?:_\d+)* # decimal
|
||||||
(?:e[+-]? (?:\d(?:_?\d)*)+ )?
|
(?:e[+-]? \d+(?:_\d+)* )?
|
||||||
# decimal without support for numeric literal separators for reference:
|
# decimal without support for numeric literal separators for reference:
|
||||||
# \d*\.?\d+ (?:e[+-]?\d+)?
|
# \d*\.?\d+ (?:e[+-]?\d+)?
|
||||||
///i
|
///i
|
||||||
|
|
|
@ -5772,7 +5772,7 @@ LEVEL_ACCESS = 6 # ...[0]
|
||||||
# Tabs are two spaces for pretty printing.
|
# Tabs are two spaces for pretty printing.
|
||||||
TAB = ' '
|
TAB = ' '
|
||||||
|
|
||||||
SIMPLENUM = /^[+-]?(?:\d(?:_?\d)*)+$/
|
SIMPLENUM = /^[+-]?\d+(?:_\d+)*$/
|
||||||
SIMPLE_STRING_OMIT = /\s*\n\s*/g
|
SIMPLE_STRING_OMIT = /\s*\n\s*/g
|
||||||
LEADING_BLANK_LINE = /^[^\n\S]*\n/
|
LEADING_BLANK_LINE = /^[^\n\S]*\n/
|
||||||
TRAILING_BLANK_LINE = /\n[^\n\S]*$/
|
TRAILING_BLANK_LINE = /\n[^\n\S]*$/
|
||||||
|
|
|
@ -7,6 +7,9 @@ test "BigInt exists", ->
|
||||||
test "Parser recognizes decimal BigInt literals", ->
|
test "Parser recognizes decimal BigInt literals", ->
|
||||||
eq 42n, BigInt 42
|
eq 42n, BigInt 42
|
||||||
|
|
||||||
|
test "Parser recognizes decimal BigInt literals with separator", ->
|
||||||
|
eq 1_000n, BigInt 1000
|
||||||
|
|
||||||
test "Parser recognizes binary BigInt literals", ->
|
test "Parser recognizes binary BigInt literals", ->
|
||||||
eq 42n, 0b101010n
|
eq 42n, 0b101010n
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue