commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dion Gillard" <dion.gill...@gmail.com>
Subject Re: [JEXL] Blocks and an Expression
Date Tue, 28 Feb 2006 02:25:28 GMT
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?

On 2/28/06, Rahul Akolkar <rahul.akolkar@gmail.com> wrote:
>
> On 2/27/06, Dion Gillard <dion.gillard@gmail.com> wrote:
> > On 2/28/06, Rahul Akolkar <rahul.akolkar@gmail.com> wrote:
> > >
> > > Thanks for the recent changes Dion. The bit that is hazy (for me) is
> > > the relationship between an Expression and a "block" in the current
> > > impl. As demonstrated by the two failing test cases at the end of
> > > BlockTest.java (and therefore, commented out) I think we may need to
> > > flesh out the semantics of "value on Expression evaluation becomes
> > > block value", especially when the Expression can contain multiple
> > > blocks or a mix of blocks and statements.
> > >
> > > I hope to look at the code soon as well ;-) but didn't want to lose
> > > track of this initial thought while looking at the svn commits fly by.
> > >
> >
> > Hmm.. This seems to be the same as multiple expression evaluations, e.g.
> if
> > you evaluate:
> >
> > " x = 1; y = 2;"
> >
> > what do you expect? (me, I expect 2!).
> <snip/>
>
> Me too. But "if (true) { x = 1; } if (true) { y = 2; }" evaluates to ?
>
> A JEXL Expression (upper case 'E') may be more than, less than or
> equal to a block. For instance, a Perl code block can serve as an
> rvalue in an assignment expression, which is the kind of scenario
> where the value of the block mostly comes into play. In which case,
> there is exactly one block.
>
>
> > Blocks shouldn't change the
> > semantics.
> >
> > is that your understanding too?
> >
> > I can look at the failing/commented tests and check out what's happening
> if
> > you like.
> >
> <snap/>
>
> Please.
>
> -Rahul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>


--
http://www.multitask.com.au/people/dion/
Chuck Norris sleeps with a night light. Not because Chuck Norris is afraid
of the dark, but because the dark is afraid of Chuck Norris

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