Re: ambiguity in XQuery grammar

----- Original Message -----
From: "Michael Dyck" <michaeldyck@shaw.ca>
To: "Kay, Michael" <Michael.Kay@softwareag.com>
Cc: "Damien Fisher" <damien@sodatech.com>; <www-ql@w3.org>
Sent: Thursday, June 06, 2002 2:11 PM
Subject: Re: ambiguity in XQuery grammar


> Damien Fisher wrote:
> >
> > There appears to be an ambiguity in the current draft specification's
> > grammar, which I was hoping someone could resolve for me.
> >
> > Consider:
> >     1 instance of xs:integer+ +1
> > Is this equivalent to:
> >     (1 instance of xs:integer+) +1
> > or:
> >     (1 instance of xs:integer) + (+1)
> > ?
>
> Michael Kay replied:
> >
> > It is indeed an ambiguity, and I've been concerned about it too, ...
>
> I don't think it is an ambiguity.
>
> According to A.3 Precedence Order, InstanceofExpr is at precedence level 6
> and AdditiveExpr is at level 8. Now, while the exact grammatical meaning
of
> the precedence table has never been given, my interpretation is that an
> AdditiveExpr cannot have an InstanceofExpr as either of its operands. So
> both of the suggested parsings are illegal, and in fact, the example query
> has no legal parse.

I'm afraid I don't understand your interpretation of the precedence order.

Unless I am totally mistaken, precedences do not state what are legal or
illegal operands for an AdditiveExpr -- that is the job of the AdditiveExpr
rule.  Precedences are used to disambiguate sentences of a language which
have multiple possible interpretations under a given set of rules.  For
example, 1+2*3 could be (in the   absence of precedence information)
interpretation as (1+2)*3 or 1+(2*3).  However, * binds more tightly than +,
and so we are restricted to a unique interpretation.

AFAICT, the precedence order given in the standard does not disambiguate the
above expression, which is legal according to the grammar.  The grammar
explicitly says AdditiveExpr takes operands of type Expr, which includes
InstanceofExpr -- if the standard did not want to include InstanceofExpr as
a legal operand, then this would have been replaced by something like
ExprExceptInstanceofExpr.

Received on Thursday, 6 June 2002 00:42:43 UTC