You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Violeta Georgieva <mi...@gmail.com> on 2013/07/18 09:00:09 UTC

Failed to parse the expression when we have repeated function invocations

Hi,

Let's have a lambda expression:

x->y->x-y

Let's now assign it and invoke it indirectly:

f = x->y->x-y; f(2)(1)

>From the spec we have:

"If the result of evaluating the function name is a LambdaExpression, the
LambdaExpression is invoked with the supplied arguments. If the result of
evaluating the LambdaExpression is another LambdaExpression, and the syntax
contains repeated function invocations, such as func()()..., then the
resultant LambdaExpression is in turn evaluated, and so on."


During evaluation I'm receiving ParseException:

javax.el.ELException: Failed to parse the expression [${(f = x->y->x-y;
f(2)(1)}]
at
org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:143)
at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:169)
at
org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:230)
at
org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
at javax.el.ELProcessor.getValue(ELProcessor.java:43)
...
Caused by: org.apache.el.parser.ParseException: Encountered " "(" "( "" at
line 1, column 23.
Was expecting one of:
    "." ...
    ")" ...
    "[" ...
    ";" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...
    "+=" ...

at org.apache.el.parser.ELParser.generateParseException(ELParser.java:3083)
at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2965)
at org.apache.el.parser.ELParser.NonLiteral(ELParser.java:1539)
at org.apache.el.parser.ELParser.ValuePrefix(ELParser.java:1369)


Regards
Violeta

Re: Failed to parse the expression when we have repeated function invocations

Posted by Mark Thomas <ma...@apache.org>.
On 18/07/2013 18:36, Mark Thomas wrote:
> On 18/07/2013 18:24, Violeta Georgieva wrote:
>> 2013/7/18 Mark Thomas wrote:

>>> I look forward to your next brain teaser :)
>>>
>>
>> ;)
>>
>> If I modify the example above like this
>>
>> f = ()->y->2-y; f()(1)
> 
> Thanks for all the testing.
> 
> I'll convert all the the lambda expression tests to their functional
> versions and make sure they all pass.

Converting those tests highlighted some related issues. After another
round of changes the tests all pass. Over to you...

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Failed to parse the expression when we have repeated function invocations

Posted by Mark Thomas <ma...@apache.org>.
On 18/07/2013 18:24, Violeta Georgieva wrote:
> 2013/7/18 Mark Thomas wrote:
>>
>> On 18/07/2013 08:00, Violeta Georgieva wrote:
>>> Hi,
>>>
>>> Let's have a lambda expression:
>>>
>>> x->y->x-y
>>>
>>> Let's now assign it and invoke it indirectly:
>>>
>>> f = x->y->x-y; f(2)(1)
>>
>> Several problems here.
>>
>> 1. The grammar didn't support functions having multiple sets of
> parameters.
>>
>> 2. The lambda expression handling in AstFunction only handled single
>> parameters sets.
>>
>> 3. The incMethodParameterIndex() can't be used in this case so an
>> alternative solution is required to the problem that addressed.
>>
>> All of these have been fixed in trunk. There is some more clean-up that
>> can now be done.
>>
>> I look forward to your next brain teaser :)
>>
> 
> ;)
> 
> If I modify the example above like this
> 
> f = ()->y->2-y; f()(1)

Thanks for all the testing.

I'll convert all the the lambda expression tests to their functional
versions and make sure they all pass.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Failed to parse the expression when we have repeated function invocations

Posted by Violeta Georgieva <mi...@gmail.com>.
2013/7/18 Mark Thomas wrote:
>
> On 18/07/2013 08:00, Violeta Georgieva wrote:
> > Hi,
> >
> > Let's have a lambda expression:
> >
> > x->y->x-y
> >
> > Let's now assign it and invoke it indirectly:
> >
> > f = x->y->x-y; f(2)(1)
>
> Several problems here.
>
> 1. The grammar didn't support functions having multiple sets of
parameters.
>
> 2. The lambda expression handling in AstFunction only handled single
> parameters sets.
>
> 3. The incMethodParameterIndex() can't be used in this case so an
> alternative solution is required to the problem that addressed.
>
> All of these have been fixed in trunk. There is some more clean-up that
> can now be done.
>
> I look forward to your next brain teaser :)
>

;)

If I modify the example above like this

f = ()->y->2-y; f()(1)

Then I'm receiving an exception:

javax.el.ELException: Only [0] arguments were provided for a lambda
expression that requires at least [1]
at javax.el.LambdaExpression.invoke(LambdaExpression.java:60)
at javax.el.LambdaExpression.invoke(LambdaExpression.java:92)
at org.apache.el.parser.AstFunction.getValue(AstFunction.java:103)
at org.apache.el.parser.AstSemicolon.getValue(AstSemicolon.java:37)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
at javax.el.ELProcessor.getValue(ELProcessor.java:45)

Re: Failed to parse the expression when we have repeated function invocations

Posted by Mark Thomas <ma...@apache.org>.
On 18/07/2013 08:00, Violeta Georgieva wrote:
> Hi,
> 
> Let's have a lambda expression:
> 
> x->y->x-y
> 
> Let's now assign it and invoke it indirectly:
> 
> f = x->y->x-y; f(2)(1)

Several problems here.

1. The grammar didn't support functions having multiple sets of parameters.

2. The lambda expression handling in AstFunction only handled single
parameters sets.

3. The incMethodParameterIndex() can't be used in this case so an
alternative solution is required to the problem that addressed.

All of these have been fixed in trunk. There is some more clean-up that
can now be done.

I look forward to your next brain teaser :)

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org