- From: Tom Hillman <tom@expertml.com>
- Date: Wed, 5 Jan 2022 16:20:51 +0000
- To: Norm Tovey-Walsh <norm@saxonica.com>, ixml <public-ixml@w3.org>, Steven Pemberton <steven.pemberton@cwi.nl>
- Message-ID: <2d430fb0-82e8-43ad-9831-afc1e208803d@Spark>
Ambiguous in JayParser, since there would be multiple parse trees in the parse forest. Thanks, Tom On 5 Jan 2022, 3:21 PM +0000, Steven Pemberton <steven.pemberton@cwi.nl>, wrote: > > > On Wednesday 05 January 2022 13:35:30 (+01:00), Norm Tovey-Walsh wrote: > > > Apologies for what may be a naive question. > > > > Consider this grammar: > > > > lnnl: "a", number, number, "a" . > > -number: oddnumber ; evennumber . > > -oddnumber: "1" ; . > > -evennumber: "2" ; . > > > > The grammar is ambiguous in that there are multiple nonterminals that > > can match nothing. > > > > But there is only one possible parse for “a12a”. I assume that we don’t > > report any ambiguity in this case. > Correct. > > > There are several possible parses for “aa”, but they’ll all produce > > exactly the same XML serialization. Does that count as ambiguous? > > As Michael recently remarked, this is angels dancing on a pin territory, and I believe my implementation says it's ambiguous, and his says not (but I may be wrong in this particular case). > > 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. > > 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. > > Steven > >
Received on Wednesday, 5 January 2022 16:21:39 UTC