Community
Participate
Working Groups
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.
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 ;-)
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 ***