RE: ambiguity in XQuery grammar

> > > 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 Dyck said...
> >
> > 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.

Yes, I think that's correct: the precedence can be used to disambiguate this
case. However, that's still a little unsatisfactory. Firstly because, as was
pointed out, the meaning of the precedence table is rather fuzzily defined,
and secondly, because even if it's unambiguous, you still need to apply some
special reasoning to decide that the "+" is part of the "instance of"
expression. In my parser, this consists simply of saying that if you find
"+", "*", or "?" at this point, then it's part of the SequenceType.

We're working on a revised way of presenting the grammar, this has been
somewhat delayed but hopefully will bring improvements in the next draft.

Michael Kay

Received on Thursday, 6 June 2002 08:04:00 UTC