-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance support for floating point numbers
Floating points numbers (eg. `2.34`, `.54`) were not being matched correctly. This patch splits the number class regex in different variants to make things clearer and also adds variants to better match floating points, including the `_` character, and also the special case of version numbers (eg. v5.38). Markup test for the new number class was also added.
- Loading branch information
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<span class="hljs-keyword">use</span> <span class="hljs-number">v5.38</span>; | ||
<span class="hljs-keyword">use</span> <span class="hljs-number">5.0020</span>; | ||
|
||
<span class="hljs-keyword">my</span> $number = <span class="hljs-number">9</span>; | ||
$number = <span class="hljs-number">0</span>; | ||
$number = 0_; | ||
$number = <span class="hljs-number">0.99</span>; | ||
$number = <span class="hljs-number">99</span>; | ||
$number = <span class="hljs-number">00</span>; | ||
$number = 99__; | ||
$number = <span class="hljs-number">99.9</span>; | ||
$number = <span class="hljs-number">99.99</span>; | ||
$number = .99_; | ||
$number = ._99; | ||
$number = <span class="hljs-number">0x99FF</span>; | ||
$number = <span class="hljs-number">0x99_EE_FF</span>; | ||
$number = 0x99_EE_FF_; | ||
$number = 0x_99_FF; | ||
$number = <span class="hljs-number">0b00101011</span>; | ||
$number = 0b00101011_; | ||
$number = <span class="hljs-number">0b0010_1011</span>; | ||
$number = 0b_0010_1011; | ||
$number = <span class="hljs-number">0777</span>; | ||
$number = <span class="hljs-number">07_7_7</span>; | ||
$number = 0_777; | ||
$number = 07_7_7_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use v5.38; | ||
use 5.0020; | ||
|
||
my $number = 9; | ||
$number = 0; | ||
$number = 0_; | ||
$number = 0.99; | ||
$number = 99; | ||
$number = 00; | ||
$number = 99__; | ||
$number = 99.9; | ||
$number = 99.99; | ||
$number = .99_; | ||
$number = ._99; | ||
$number = 0x99FF; | ||
$number = 0x99_EE_FF; | ||
$number = 0x99_EE_FF_; | ||
$number = 0x_99_FF; | ||
$number = 0b00101011; | ||
$number = 0b00101011_; | ||
$number = 0b0010_1011; | ||
$number = 0b_0010_1011; | ||
$number = 0777; | ||
$number = 07_7_7; | ||
$number = 0_777; | ||
$number = 07_7_7_; |