commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos DurĂ¡n" <carlostenis...@gmail.com>
Subject Bug in jexl library
Date Sat, 15 Nov 2008 11:36:20 GMT
Hello,
I have checked that there is a conflict(in jexl library) when a method is
called "foreach",for example.If method's name is the same than the beginning
of a statement defined("foraech" is already defined but you can define other
like "forall","exists"..) the parser doesnt recognize that method,the
statement defined is expected.

This is the grammar.

void Statement() #void :
{}
{
  ";"
|
  Block()
|
  LOOKAHEAD( Reference() ";" ) ReferenceExpression()
|
  LOOKAHEAD( PrimaryExpression() "=" ) StatementExpression()
|
  LOOKAHEAD( Expression() ";" ) ExpressionExpression()
|
  Expression()
|
  IfStatement()
|
 * ForeachStatement()*
|
  WhileStatement()

}



void ForeachStatement() :
{}
{
  "foreach" "(" Reference() "in"  Reference() ")" Statement()
}


---------------------------------------------------------------------------------------------

If I do something like this:

String jexlExp = "foreach(x)";  //there is no problem if the name is not the
same than something defined in the grammar(for example "foreac(x)")
Script script = ScriptFactory.createScript(jexlExp);


the result is:

Exception in thread "main" org.apache.commons.jexl.parser.ParseException:
Encountered ")" at line 1, column 10.
Was expecting one of:
    "in" ...
    "(" ...
    "[" ...
    "." ...

    at
org.apache.commons.jexl.parser.Parser.generateParseException(Parser.java:3786)
    at
org.apache.commons.jexl.parser.Parser.jj_consume_token(Parser.java:3663)
    at
org.apache.commons.jexl.parser.Parser.ForeachStatement(Parser.java:1729)
    at org.apache.commons.jexl.parser.Parser.Statement(Parser.java:1546)
    at org.apache.commons.jexl.parser.Parser.JexlScript(Parser.java:60)
    at org.apache.commons.jexl.parser.Parser.parse(Parser.java:18)
    at
org.apache.commons.jexl.ScriptFactory.createNewScript(ScriptFactory.java:162)
    at
org.apache.commons.jexl.ScriptFactory.createScript(ScriptFactory.java:99)
    at parser.pruebillas.main(pruebillas.java:134)



I think this is connected to Tokenizer Lookahead, but I dont know well what
is the best way to solve the problem,I need help.

Thanks.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message