Closed stuartlangridge closed 4 years ago
Your assumption is correct. It should return both results but the currently implemented solution to deal with empty reductions is too restrictive and some valid solutions gets dropped. In this case the algorithm prefers non-empty solution over empty and thus returns only OtherSentence
.
This is related to #112
I'm working on a fix.
It is fixed on the master branch. It should now correctly handle all context-free grammars. You can see the regression test for your issue
Notice that there are 2 valid solution for your first sentence and 3 valid solution for the second.
Thanks for the contribution. I'm closing this issue. Feel free to open if you notice anything wrong.
Description
I'm using the following code. The key issue seems to be the optional
KindWith?
, which seems to break parsing of a simple sentence? Perhaps the code will make it clearer:I think that "a car is a kind of vehicle" ought to match a KindDefinitionSentence (the KindWith part is not present, but it is explicitly optional). When using "a car is a kind of vehicle with wheels." then it parses correctly (GLRParser returns two possible parses, one of which is the KindDefinitionSentence as expected). Perhaps I have misunderstood what an "optional" item is, but since KindWith is optional, I would have expected that a sentence without that part would still parse correctly, and it doesn't.
The code above outputs:
Am I writing the grammar wrong somehow?