[Bug 5727] [XQuery] Syntax ambiguities with leading "/"

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5727





--- Comment #11 from Michael Dyck <jmdyck@ibiblio.org>  2008-08-04 21:38:46 ---
(In reply to comment #8)
> 
> <new>
> A single slash may appear either as a complete path expression or as the
> first part of a path expression in which it is followed by a
> RelativePathExpr.  After a single slash, there are several tokens which
> have an ambiguous interpretation according to the grammar:

This uses "ambiguous" with not quite its technical meaning, which I don't
think we should do when we're talking about grammars and parsers.
I suggest changing "After ... grammar:" to:
    In some cases, the next token after the slash is insufficient to
    allow a parser to distinguish these two possibilities:

> the "*" token and keywords like "union" could indicate either an operator
> or a NameTest, and the "<" token could indicate a ComparisonExpr or the
> start of a DirectConstructor.

I think it would be clearer to change "indicate" to "be" and
"ComparisonExpr" to "operator". (Why say "ComparisonExpr" for "<" and not
"MultiplicativeExpr" for "*"?) And maybe toss in another "either":
    the "*" token and keywords like "union" could be either an operator or
    a NameTest, and the "<" token could be either an operator or the start
    of a DirectConstructor.

(Actually, a keyword token in this context could be something other than an
operator, e.g. the example from comment #7:
    if ($doclevel) then / else /*
But since (a) we don't formally define "operator", and (b) we're about to
disallow that parse anyway, the fix is probably not worth it.)

---

So, just checking: Under this rule, these queries are all syntax errors:
    /*5
    /<a
    /<5
    /</b
    /<a div 3
    if ($doclevel) then / else /*
    / is $a
    / instance of document-node(schema-element(x))
    let $doc := / return $doc/*

these are PathExprs:
    /*
    /<a/>
    /<a div="3"/>
    /unordered{x}
    /f(x)

and these are other kinds of Exprs:
    /-5
    /=$a
    5*/

Right?

(It might be worth putting such examples in the doc.)


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Monday, 4 August 2008 21:39:19 UTC