File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
main/java/org/prorefactor/proparse
test/java/org/prorefactor/proparse Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 2626import java .util .Locale ;
2727import java .util .Map ;
2828import java .util .Set ;
29+ import java .util .regex .Pattern ;
2930
3031import javax .annotation .CheckForNull ;
3132import javax .annotation .Nonnull ;
6263 */
6364public class Lexer implements IPreprocessor {
6465 private static final Logger LOGGER = LoggerFactory .getLogger (Lexer .class );
65-
66+ private static final Pattern SCIENTIFIC_NOTATION = Pattern . compile ( " \\ d+( \\ . \\ d+)?e[+-] \\ d+" );
6667 private static final int SKIP_CHAR = -100 ;
6768 private static final int PROPARSE_DIRECTIVE = -101 ;
6869 private static final int INCLUDE_DIRECTIVE = -102 ;
@@ -771,6 +772,8 @@ private ProToken digitStart(boolean hex) {
771772 stop = true ;
772773 }
773774 }
775+ if (SCIENTIFIC_NOTATION .matcher (currText ).matches ())
776+ ttype = ABLNodeType .NUMBER ;
774777
775778 return makeToken (ttype );
776779 }
Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ public void setUp() throws IOException {
5252 session = new RefactorSession (new UnitTestProparseSettings (), new SportsSchema ());
5353 }
5454
55+ @ Test
56+ public void testScientificNotation01 () {
57+ final var source = "6.02214076 6.02214076e+23 1.456e-3 4.246e+4 6779.0 23766e-1 .23e-1 " ;
58+ var lexer = new ABLLexer (session , ByteSource .wrap (source .getBytes ()), true );
59+
60+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "6.02214076" );
61+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "6.02214076e+23" );
62+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "1.456e-3" );
63+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "4.246e+4" );
64+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "6779.0" );
65+ assertNextTokenTypeWS (lexer , ABLNodeType .NUMBER , "23766e-1" );
66+ assertNextTokenTypeWS (lexer , ABLNodeType .FILENAME , ".23e-1" );
67+ }
68+
5569 @ Test
5670 public void testDecimalNumber01 () {
5771 final String source = "rct1:height = 0.1\n rct1:row " ;
You can’t perform that action at this time.
0 commit comments