commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <>
Subject Re: [JEXL] Blocks and an Expression
Date Tue, 28 Feb 2006 23:25:44 GMT
On 2/27/06, Dion Gillard <> wrote:
> Ok, I've found the cause of the problem.
> ExpressionFactory.createNewExpression on line 125 does this:
>        SimpleNode node = (SimpleNode) tree.jjtGetChild(0);
> So only the first statement of the parsed expression is actually evaluated.
> In the cases of the commented out tests, there are multiple statements which
> are children of the parse tree.
> The use of a block here really isn't significant, using a parse string like
> "x =1; y=2;" causes the same issue.


> So, the question becomes, should we support multiple statements for an
> expression (outside a block), or do we implement ASTJexlScript so that it
> evaluates each of it's children in turn and returns the last value?

Neither? ;-) Took a peek, the behavior is as advertised since a JEXL
Expression is indeed a reference to a single expression, and those
semantics need to persist. However, since we use the "script grammar"
for the ExpressionFactory (whereas the grammar for scripts is really a
superset of the expression grammar), we parse the (potential) script
and pluck out the just first expression even if there are more. The
fact that expressions beyond the first are silently ignored probably
needs to be addressed. Short of teasing apart two grammars (and/or
having a ScriptFactory), perhaps it will be sufficient to trivially
log a warning when that happens.


As an independent question, why doesn't JEXL have Script as a first
class entity like Expression (with a ScriptFactory to match)?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message