Re: Precedence rules for QuantifiedExpr - OrExpr - AndExpr

Michael Brundage <[email protected]>
Newsgroups gmane.comp.web.query-languages
Message-ID <BC09D652.AEC%[email protected]>
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
[email protected]

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" <[email protected]> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.