Re: Is this ambiguous?

The text in the spec is


"If more than one parse tree describes the input, the processor must serialize one of them. It is not defined how this choice is made, but the resulting parse should be marked as ambiguous"


Steven

On Monday 14 February 2022 16:11:29 (+01:00), Steven Pemberton wrote:

> Sure it is. Ambiguity is in the input, not in the output. It's why we go to such lengths about spaces in the ixml grammar.
>
> I call it "harmless" ambiguity, but spotting if a parse is ambiguous is easy (it's just a tree walk); spotting whether it is harmless is not easy: you have to compare the generated output from all the possible ambiguous parse trees, and there may be a lot of them.
>
> Ambiguous grammars also slow parse time down, sometimes by a lot.
>
> Steven
>
> On Sunday 13 February 2022 11:33:56 (+01:00), Norm Tovey-Walsh wrote:
>
> > Hello world,
> >
> > Consider this grammar:
> >
> > list: word + -',' .
> > word: c, v, c ; c, v, v .
> > -c: ["bcdfghjklmnpqrstvwxyz"] .
> > -v: ["aeiouy" ].
> >
> > and this input: “hey,bee”.
> >
> > By one reckoning, that’s ambiguous: “hey” can be either cvc or cvv
> > because I’ve identified “y” as both a consonant and a vowel.
> >
> > But “c” and “v” are both elided from the output, so the generated XML is
> > identical for both parses. By that reckoning, it isn’t ambiguous.
> >
> > I expect our intent is that it *isn’t* ambiguous…but I thought I’d check.
> >
> > Be seeing you,
> > norm
> >
> > --
> > Norm Tovey-Walsh
> > Saxonica
> >

Received on Monday, 14 February 2022 15:27:36 UTC