Re: Precedence rules for QuantifiedExpr - OrExpr - AndExpr

On 12/20/03 10:34 AM, "Michael Brundage" <xquery@comcast.net> wrote:

I'm sorry Peter, my error -- I misunderstood your question.

You're asking about the relative precedence of quantification and "or", and
you're right, they're currently at the same level (expr 41 in the grammar)
with left-to-right associativity, so your examples below parse as you
stated.

This is most likely just another error in the grammar, introduced between
the November, 2002 and May, 2003 drafts.  These expressions used to be at
different levels.


Sorry for my confusion,

michael

> 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 14:34:17 UTC