W3C home > Mailing lists > Public > www-ql@w3.org > October to December 2003

Re: Precedence rules for QuantifiedExpr - OrExpr - AndExpr

From: Michael Brundage <xquery@comcast.net>
Date: Sat, 20 Dec 2003 10:34:58 -0800
To: <pgp.coppens@pandora.be>, "www-ql@w3.org 2" <www-ql@w3.org>
Message-ID: <BC09D652.AEC%xquery@comcast.net>

Hi Peter,

I think you're misreading the spec.  Both expressions parse as

for $x in (1,2,3)
where some $y in (1,2) satisfies ((1 = $y) OP ($y =1))
return $x

where OP is "or" or "and".

The "and" operator has a precedence level immediately greater than "or" --
there is no intervening expression.   Quoting from section A.1 of the
current (Nov 12, 2003) draft:

[55]   OrExpr  ::=   AndExpr ( "or" AndExpr )
[56]   AndExpr ::=   InstanceofExpr ( "and" InstanceofExpr)*

So for example,

A or B and C
parses as
A or (B and C)


Hope this helps,

Michael Brundage
xquery@comcast.net

Writing as
Author, XQuery: The XML Query Language (Addison-Wesley, 2004)
Co-author, Professional XML Databases (Wrox Press, 2000)

not as
Technical Lead
Common Query Runtime/XML Query Processing
WebData XML Team
Microsoft



On 12/19/03 7:36 AM, "Peter Coppens" <pgp.coppens@pandora.be> wrote:
> All,
> 
> Looking at the XQuery spec, I am somewhat surprised by the consequences of
> the precedence rules for QuantifiedExpr - OrExpr and AndExpr
> 
> What I mean is:
> 
> Take the query
> 
> for $x in (1,2,3)
> where 
> some $y in (1,2) satisfies 1 = $y and $y = 1
> return $x
> 
> Which, I think, is equivalent to
> 
> for $x in (1,2,3)
> where 
> some $y in (1,2) satisfies (1 = $y and $y = 1)
> return $x
> 
> But now take the query
> 
> for $x in (1,2,3)
> where 
> some $y in (1,2) satisfies 1 = $y or $y = 1
> return $x
> 
> 
> Which, I think, is equivalent to
> 
> for $x in (1,2,3)
> where 
> (some $y in (1,2) satisfies 1 = $y) or $y = 1
> return $x
> 
> I find that rather confusing.
> 
> So I guess I have the following questions
> 
> (1) is the above interpretation correct?
> (2) is this a deliberate choice and if yes, are there any motivations for
> that decision that can be shared?
> (3) would it not be possible to add an extra level of precendence where the
> OrExpr comes to sit between QuantifiedExpr and AndExpr, or would that
> propagate to have other side effects?
> 
> Thanks,
> 
> Peter
> 
Received on Saturday, 20 December 2003 13:36:45 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:16 UTC