Bug 221055 - EL Parser doesn't parse choice expressions correctly
Summary: EL Parser doesn't parse choice expressions correctly
Status: CLOSED DUPLICATE of bug 280621
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2008-03-02 07:08 EST by Matthias Fuessel CLA
Modified: 2009-09-29 17:21 EDT (History)
1 user (show)

See Also:


Attachments
proposed fix (71.69 KB, patch)
2008-03-09 18:16 EDT, Matthias Fuessel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 ***