W3C home > Mailing lists > Public > public-ixml@w3.org > April 2021

resolving ambiguity

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Tue, 13 Apr 2021 18:42:00 -0600
Message-Id: <4C762324-2C76-4552-B8CA-592720869F28@blackmesatech.com>
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>
To: public-ixml@w3.org
On today’s call, Tom suggested that the spec might usefully say which tree should be returned, in case of ambiguity. 

I am nervous about this suggestion; I think that the choice of tree is better left open.  

"First rule wins" seems plausible enough when it applies, but I have not thought enough about it to know whether it always applies, whether it always provides a unique solution, or how to extend the Earley algorithm (or any of the other general algorithms) to keep track of such things in a way that would guarantee the selection of the correct tree.  Consider this grammar:

    S: Left, Right.
    Left:  "a", "b"; "a".
    Right: "b", "c"; "c".

If I'm not mistaken, this has two parse trees:


The first tree uses the first RHS for Left and the second RHS for Right.  The second tree is the other way round.  Does the "first rule wins" principle give an answer here?  I suppose we can say that it's the choice of rules for 'Left' that matters, because 'Left' precedes 'Right'.  And I guess that's what you meant.

But consider:

    S: '(', a, s?, ')'.
    a: s?, 'a', s?.
    s: #20+.

and the input string "(a )".  Which of the parses is preferred by the first-rule-wins rule?

    <S>(<a>a </a>)</S>
    <S>(<a>a</a> )</S>


C. M. Sperberg-McQueen
Black Mesa Technologies LLC
Received on Wednesday, 14 April 2021 00:42:19 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 13 September 2022 10:02:05 UTC