W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2003

XQuery: Ambiguous expression using "context"

From: Twan van Laarhoven <twanvl@hotmail.com>
Date: Thu, 23 Jan 2003 17:19:48 +0100
To: public-qt-comments@w3.org
Message-ID: <F60aVUPC5GXNEL7sEwF0000d7cd@hotmail.com>


The expression:
     if (A) then B instance of element C context type else/D
According to precedence rules, should be interpreted the same as:
     if (A) then (B instance of element C context type else/D)
However, this is not a valid expression, since there is no 'else' in if 
expression. The first expression should therefor be interpreted as:
     if (A) then (B instance of element C context type) else (/D)
Where "type" is treated as a QName. This interpretation is a valid 
expression. To Determine which of the two choices must be made information 
is needed about whether an additional "else" statement follows the 
expression. Determining this requires an indeterminate large lookahead, 
since "/D" could be any number of tokens ("/D/E/F/G" etc.)

This problem can also occur with for (and possibly every, some and let)
    for $A as element B context type in /C return D

Solutions to this problem could be:
1. Require parenthesis around type expressions
2. Require parenthesis around in, then, as, where, and maybe more 
3. Clearly state that the simpler-to-parse rules must be followed, even if 
that leads to syntax errors

Of these solutions I prefer the third, since it does not significantly 
change the language, when this problem would arise (which is quite unlikely) 
parenthesis could always be added.

Twan van Laarhoven

ps. Sorry for the Hotmail spam:

Protect your PC - get McAfee.com VirusScan Online 
Received on Thursday, 23 January 2003 11:20:20 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:11 UTC