On Sat, Nov 15, 2008 at 6:36 AM, Carlos Durán <[EMAIL PROTECTED]> wrote:
> 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.
>
<snip/>
'foreach' is a keyword in JEXL, best to avoid using it as a method or
variable name.
-Rahul
> 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.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]