Skip to content

Commit

Permalink
feature #3182 Add support for exponential numbers (fabpot)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.x branch.

Discussion
----------

Add support for exponential numbers

Commits
-------

6092135 Add support for exponential numbers
  • Loading branch information
fabpot committed Nov 7, 2019
2 parents 2024406 + 6092135 commit 8f9c0b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
@@ -1,6 +1,6 @@
* 1.42.4 (2019-XX-XX)

* 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
--TEMPLATE--
{{ 1.99E+3 }}
--DATA--
return []
--EXPECT--
1990

0 comments on commit 8f9c0b3

Please sign in to comment.