Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 221055

Summary: EL Parser doesn't parse choice expressions correctly
Product: [WebTools] WTP Source Editing Reporter: Matthias Fuessel <mat.fuessel>
Component: jst.jspAssignee: Nick Sandonato <nsand.dev>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: nsand.dev
Version: 3.0Keywords: helpwanted
Target Milestone: 3.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
proposed fix none

Description Matthias Fuessel CLA 2008-03-02 07:08:20 EST
Build ID: I20080207-1530

When given a choice expression ("condition? alt1 : alt2"), JSPELParser just parses the part before the "?"

Steps To Reproduce:
1. JSPELParser elParser = JSPELParser.createParser("xx? yy : zz");
2. ASTExpression expr =  elParser.Expression();
3. expr will contain only an ASTUnaryExpression consisting of the single token "xx"

This ultimately leads to the jsf(!) validator tagging all choice expressions as syntax errors (since not parseable to the end), which is rather annoying.
Comment 1 Matthias Fuessel CLA 2008-03-09 18:16:06 EDT
Created attachment 91999 [details]
proposed fix

The important part is in JSPEL.jjt - the other files are (more or less...) generated by jtree/javacc.

This fixes the lookahead condition for choice expressions which previously never was true.

Unfortunately this revealed a problem with function invocations: These have the form "prefix:name(params)", where according to jsp-2.1 el spec "prefix:" is optional and the prefix-":" takes precedence over the choice-":".
The parser however treated "prefix:" as mandatory and "name" and "(params)" as optional.

I had to make "(params)" mandatory in order to distinguish between choice-":" and prefix-":". I also made "prefix:" optional and (consequently) "name" mandatory which is (I belief) the correct behaviour but not necessary for the "choice" fix. I don't know however if there has been any particular reason for the "old" behaviour, it seemed to have been made rather intentionally...

I also changed "choice expression" in order to allow for choice expressions within choice expression.

The patched parser has been tested to parse simple choice expressions and simple function invocations with and without prefix correctly. Other behaviour "should" be unchanged. The patched parser will probably be a slightly slower than the "old" one.

Please review the changes carefully as I'm not much of a parser expert ;-)
Comment 2 Nick Sandonato CLA 2009-09-29 17:21:20 EDT
Hi Matthias,

Thanks for your patch, it looked great overall. At this time, though, I'm going to mark this bug as a duplicate of bug 280621.

If you would like, could you please open a new bugzilla specifically addressing the "problem with function invocations". If you'd like, and it will help me out a bit, you could attach only the changes to the .jjt file. I can generate the .jj and java files myself.

*** This bug has been marked as a duplicate of bug 280621 ***