This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch JEXL-411-leading-zeroes
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit a4b5751a80cc9be7903f2d6de5e742af9f17b4be
Author: Henrib <[email protected]>
AuthorDate: Wed Aug 12 14:30:17 2026 +0200

    JEXL-411: move isAllDigits to JexlParser;
    - update changes.xml;
---
 src/changes/changes.xml                            |  3 +++
 .../apache/commons/jexl3/parser/JexlParser.java    | 23 ++++++++++++++++++++++
 .../org/apache/commons/jexl3/parser/Parser.jjt     | 21 --------------------
 .../org/apache/commons/jexl3/ArithmeticTest.java   |  2 ++
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f79a5b79..904785ca 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -29,7 +29,10 @@
     <body>
         <release version="3.7.1" date="YYYY-MM-DD" description="This is a 
feature and maintenance release. Java 8 or later is required.">
             <!-- ADD -->
+            <action dev="henrib" type="add" issue="JEXL-467">IntelliJ and 
VSCode editors (TextMate bundle) support for JEXL.</action>
             <!-- FIX -->
+            <action dev="henrib" type="fix" 
issue="JEXL-466">IllegalStateException parsing a template with string 
interpolation.</action>
+            <action dev="NikRom5531" due-to="Felix Rudolphi" type="fix" 
issue="JEXL-411">Leading zeroes in floating point numbers should be 
optional.</action>
             <action dev="ggregory" type="fix" due-to="Gary Gregory">Pick up 
commons.jacoco.version from the parent POM.</action>
             <action dev="ggregory" type="fix" due-to="Gary Gregory">Add 
messages when throwing NullPointerException.</action>
             <!-- UPDATE -->
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java 
b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
index d79ccca6..b01ca0ba 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
@@ -932,6 +932,29 @@ public abstract class JexlParser extends StringParser 
implements JexlScriptParse
         return !getFeatures().supportsAmbiguousStatement();
     }
 
+
+    /**
+     * Checks whether a token image is composed only of decimal digits.
+     * <p>Used to recognize a floating point literal with an omitted leading
+     * zero (e.g. {@code .1}) that is tokenized as {@code DOT 
DOT_IDENTIFIER}.</p>
+     *
+     * @param image the token image
+     * @return true if every character is a decimal digit
+     */
+    protected boolean isAllDigits(final String image) {
+        int len = image != null ? image.length() : 0;
+        if (len == 0) {
+            return false;
+        }
+        for (int i = 0; i < len; ++i) {
+            final char c = image.charAt(i);
+            if (c < '0' || c > '9') {
+                return false;
+            }
+        }
+        return true;
+    }
+
     /**
      * Called by parser at end of node construction.
      * <p>
diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt 
b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
index 4ec329fd..7105234e 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
+++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
@@ -107,27 +107,6 @@ public final class Parser extends JexlParser
             jjtree.reset();
         }
     }
-
-    /**
-     * Checks whether a token image is composed only of decimal digits.
-     * <p>Used to recognize a floating point literal with an omitted leading
-     * zero (e.g. {@code .1}) that is tokenized as {@code DOT 
DOT_IDENTIFIER}.</p>
-     *
-     * @param image the token image
-     * @return true if every character is a decimal digit
-     */
-    private static boolean isAllDigits(final String image) {
-        if (image.isEmpty()) {
-            return false;
-        }
-        for (int i = 0; i < image.length(); i++) {
-            final char c = image.charAt(i);
-            if (c < '0' || c > '9') {
-                return false;
-            }
-        }
-        return true;
-    }
 }
 
 PARSER_END(Parser)
diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java 
b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
index a2093e60..2893f0b3 100644
--- a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
@@ -2362,11 +2362,13 @@ class ArithmeticTest extends JexlTestCase {
         assertEquals(-1.4d, jexl.createExpression("-.5+-.9").evaluate(jc));
         // unary handling
         assertEquals(-0.1d, jexl.createExpression("-.1").evaluate(jc));
+        assertEquals(0.1d, jexl.createExpression("+.1").evaluate(jc));
         // property / index access via a dot must keep working (not parsed as 
a float)
         final List<Object> array = new java.util.ArrayList<>();
         array.add("zero");
         array.add("one");
         jc.set("array", array);
+        assertEquals("zero", jexl.createExpression("array.0").evaluate(jc));
         assertEquals("one", jexl.createExpression("array.1").evaluate(jc));
     }
 }

Reply via email to