Re: How is ambiguity defined?

> In your case, the serializations being the same is thanks to the "-"
> before the rules. Take them away, and you see that the parses are
> truly ambiguous, and it is that that is reported as an error.

Yes, the “-”s were there specifically to make that point. What I believe
you are saying is that the parses are ambiguious (because they are!)
even though if you asked the implementation to return all of them, they
would all look “the same”.

I think that makes sense, though it may be a little confusing for users
at first.

> But is "matching nothing" any different from "matching a character"?
> If I replace the nothings with "0" in your grammar:
>
>  lnnl: "a", number, number, "a" .
>  -number: oddnumber ; evennumber .
>  -oddnumber: "1" ; "0".
>  -evennumber: "2" ; "0".
>
> is "a00a" ambiguous? Sure it is.

Right. I happened to have an example with matching nothing because of a
test case I was working on, not because I thought it was special.

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh
Saxonica

Received on Wednesday, 5 January 2022 16:20:52 UTC