Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exponential numbers #3182

Merged
merged 1 commit into from Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
@@ -1,6 +1,6 @@
* 1.42.4 (2019-XX-XX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be changed to 1.43 as this is a new feature.


* n/a
* added supported for exponential numbers

* 1.42.3 (2019-08-24)

Expand Down
2 changes: 1 addition & 1 deletion src/Lexer.php
Expand Up @@ -47,7 +47,7 @@ class Lexer implements \Twig_LexerInterface
const STATE_INTERPOLATION = 4;

const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A';
const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
const REGEX_DQ_STRING_DELIM = '/"/A';
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/expressions/exponential_numbers.test
@@ -0,0 +1,8 @@
--TEST--
Twig manages exponentiel numbers correctly
fabpot marked this conversation as resolved.
Show resolved Hide resolved
--TEMPLATE--
{{ 1.99E+3 }}
--DATA--
return []
--EXPECT--
1990