Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f9d449

Browse filesBrowse files
committed
feature #34028 [ExpressionLanguage][Lexer] Exponential format for number (tigr1991)
This PR was merged into the 4.4 branch. Discussion ---------- [ExpressionLanguage][Lexer] Exponential format for number Exponential format has been added for numbers. Ex: 1.99E+3 === 1990, Ex: expression (1 + 1.99E+3) = 1991 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | Exponential format has been added for numbers. Ex: 1.99E+3 === 1990, Expressions: 0.1e+2 = 10 1e-2 = 0.01 (1 + 1.99E+3) = 1991 and etc... Commits ------- 430ec32 [ExpressionLanguage][Lexer] Exponential format for number
2 parents 2931227 + 430ec32 commit 4f9d449
Copy full SHA for 4f9d449

File tree

Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed

‎src/Symfony/Component/ExpressionLanguage/Lexer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/Lexer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function tokenize($expression)
4242
continue;
4343
}
4444

45-
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, 0, $cursor)) {
45+
if (preg_match('/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A', $expression, $match, 0, $cursor)) {
4646
// numbers
4747
$number = (float) $match[0]; // floats
4848
if (preg_match('/^[0-9]+$/', $match[0]) && $number <= PHP_INT_MAX) {

‎src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ public function getTokenizeData()
9797
new Token('punctuation', '[', 25),
9898
new Token('number', '4', 26),
9999
new Token('punctuation', ']', 27),
100+
new Token('operator', '-', 29),
101+
new Token('number', '1990', 31),
100102
],
101-
'(3 + 5) ~ foo("bar").baz[4]',
103+
'(3 + 5) ~ foo("bar").baz[4] - 1.99E+3',
102104
],
103105
[
104106
[new Token('operator', '..', 1)],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.