Community
Participate
Working Groups
The CUP based parser has problems with parsing XPath if then else statements. In particular the parser throws an error when it reaches the "then" statement. http://www.w3.org/TR/xpath20/ XPath ::= Expr:exps {: RESULT = new XPath(exps); :} ; Expr ::= ExprSingle:ex {: Collection exps = new ArrayList(); exps.add(ex); RESULT = exps; :} | Expr:exprs COMMA ExprSingle:ex {: exprs.add(ex); RESULT = exprs; :} ; ExprSingle ::= ForExpr:n {: RESULT = n; :} | QuantifiedExpr:n {: RESULT = n; :} | IfExpr:n {: RESULT = n; :} | OrExpr:n {: RESULT = n; :} ; IfExpr ::= IF LPAR Expr:exps RPAR THEN ExprSingle:t ELSE ExprSingle:e {: RESULT = new IfExpr(exps, t, e); :} ; Are the current definitions.
The simple xpath expression throws a parsing exception at the "then" statement: if (1 != 0) then 2 else 3
This is fixed by differentiating reserved and non-reserved words in the QName production, so that if ( ex ) doesn't look like a function call of an unqualified function. Patch underway.
Created attachment 141460 [details] Code changes in grammar file for this change
Created attachment 141461 [details] Updated test cases with more success than failure I still get three failures in this test.
Created attachment 141462 [details] Generated lexer and grammar If you don't have CUP and JFlex set up in your lib folder yet. (big patch, breaks 250 code line, but it's all just generated code.
Okay, I'll take a look at these, and will just regenerate based on the grammar changes and the updated test cases. I'll see about getting this in later tonight. Thanks for the patches Jesper.
I've applied the Grammar patches and unit test patches. The last three conditional tests will need to be tweaked so that we can compare the correct results as they are XQuery tests and not strictly XPath 2.0 tests (i.e. the results file is XQuery). We need to compare the two attributes values and not the entire XML String for Test 12.
Code checked into HEAD, build started. Thanks for the patch. I'll keep this bug opened until we resolve the last three remaining unit tests.
Created attachment 141583 [details] Fix the remaining three tests One was just about expecting XML nodes instead of text (using buildXMLResultString) The next required extending the buildXMLResultString to also be able to format atomic results (in effect making buildResultString obsolete) The last one was tricky, since there was a real bug in comparing result sequences containing untyped atomic values (copy-and-paste error). Also, the extected result had to be massaged. So now it's all green!
I mean, the if-then-else tests are all green now, not the entire suite... The comparison bugfix actually fixes some 11 other test failures :-)
latest patch applied to head, and build passes. Thans for the patches Jesper.