commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JEXL-296) Real literal in scientific format is not parsed as a statement
Date Mon, 01 Apr 2019 08:33:00 GMT
Dmitri Blinov created JEXL-296:
----------------------------------

             Summary: Real literal in scientific format is not parsed as a statement
                 Key: JEXL-296
                 URL: https://issues.apache.org/jira/browse/JEXL-296
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 3.1
            Reporter: Dmitri Blinov


I have found that in current implementation the {{testRealLiteralScript()}} fails with ambigous
expression error whereas {{testRealLiteralExpr()}} passes as expected.

{code}
    @Test
    public void testRealLiteralScript() throws Exception {
        JexlContext jc = new MapContext();
        Object o;
        o = JEXL.createScript("1e10d").execute(jc);
        Assert.assertEquals(1e10d, o);
    }

    @Test
    public void testRealLiteralExpr() throws Exception {
        JexlContext jc = new MapContext();
        Object o;
        o = JEXL.createExpression("1e10d").evaluate(jc);
        Assert.assertEquals(1e10d, o);
    }
{code}

Changing the grammar from 
{code}
void Literal() #void :
{
   Token t;
}
{
  IntegerLiteral()
|
  FloatLiteral()
...
{code}
to 
{code}
void Literal() #void :
{
   Token t;
}
{
  FloatLiteral()
|
  IntegerLiteral()
...
{code}
fixes the problem but I'm not sure if there is more robust solution to this



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message