Skip to content
Permalink
Browse files

Allow "D" suffix on literal double expressions.

  • Loading branch information...
archiecobbs committed Oct 29, 2019
1 parent 2b6721a commit f3cef8c0cb7bb0d8e8dbcfb19420395b2623c65b
@@ -101,7 +101,7 @@ else if ((matcher = ctx.tryPattern("(?si)(\\+|-|)([1-9][0-9]*)(L)?")) != null)
}
}
final Matcher doubleMatch = ctx.tryPattern(
"(" + Primitive.DOUBLE.getParsePattern() + ")(?![.\\p{javaJavaIdentifierPart}])");
"(" + Primitive.DOUBLE.getParsePattern() + ")[dD]?(?![.\\p{javaJavaIdentifierPart}])");
if (doubleMatch != null) {
try {
return new LiteralNode(Primitive.DOUBLE.parseValue(doubleMatch.group()));
@@ -122,7 +122,10 @@ public void testExprParse(String expr, Object expected) {
{ "0", 0 },
{ "0L", 0L },
{ "123.45f", 123.45f },
{ "123.45F", 123.45f },
{ "123.45", 123.45 },
{ "123.45d", 123.45 },
{ "123.45D", 123.45 },
{ "'a'", 'a' },
{ "'\\''", '\'' },
{ "'\u1234'", '\u1234' },
@@ -136,6 +139,8 @@ public void testExprParse(String expr, Object expected) {
{ "\"foo", PARSE_FAIL },
{ "6fa", PARSE_FAIL },
{ "123.45fabc", PARSE_FAIL },
{ "123.45defe", PARSE_FAIL },
{ "123.45d.e", PARSE_FAIL },

// Idents and variables
{ "foobar", PARSE_FAIL },

0 comments on commit f3cef8c

Please sign in to comment.
You can’t perform that action at this time.