Missing ambiguities when using inline rules
See original GitHub issueDescribe the bug
With some grammars, Earley parser does not return all ambiguities with ambiguity='explicit'
.
However, when removing the inlining underscore, all ambiguities are returned.
Potentially related to #536.
To Reproduce
start: _field+
_field: f1 | f2 | f3
f1: INT
f2: INT "M"?
f3: INT "M"
%ignore WS
%import common.WS
%import common.INT
When parsing string 1M 2
with ambiguity='explicit'
, the result misses ambiguities f2 f2
and f3 f1
.
>> t = parser.parse('1M 2')
>> print(t.pretty())
_ambig
start
f2 1
f1 2
start
f3 1
f2 2
However, removing _
from field
fixes it, at the expense of the additional tree level which I wanted to avoid.
start: field+
field: f1 | f2 | f3
f1: INT
f2: INT "M"?
f3: INT "M"
%ignore WS
%import common.WS
%import common.INT
>> t = parser.parse('1M 2')
>> print(t.pretty())
start
_ambig
field
f2 1
field
f3 1
_ambig
field
f1 2
field
f2 2
It’s great that the workaround works, at least in this case. But with a complex grammar including inlined rules at several levels, it’s difficult to spot the issue before realising that some results are missing in production.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Ambiguous Case of the Law of Sines - Study.com
The law of sines is used in finding missing parts in the following situations. Two Angles, One Side. The third angle can be...
Read more >How to find the missing parts of two triangles using ... - YouTube
Using the law of sines, we can obtain the value of the angle opposite the ... About Me: I make short, to-the-point online...
Read more >Ambiguous Case Law of Sines - YouTube
Learn how to solve a triangle using the law of sines when it is the ambiguous SSA case in this free math video...
Read more >Ambiguous PEMDAS - Harvard Mathematics Department
There is a rule called PEMDAS which is wide spread (kids learn "Please Excuse My Dear Aunt Sally") which when followed asks to...
Read more >Error Messages: Examples, Best Practices & Common Mistakes
4 common mistakes with error messages · 1. Ambiguity · 2. Condescending language/blaming the user · 3. Poor placement of error messages ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Both grammars produce the same SPPF, so the issue is probably in the forest to tree transformation. I will look into it more when I have a chance.
@yurymann Released 1.1.5 today.