question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing ambiguities when using inline rules

See original GitHub issue

Describe 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:closed
  • Created 10 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chanicpaniccommented, Nov 18, 2022

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.

0reactions
erezshcommented, Dec 6, 2022

@yurymann Released 1.1.5 today.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found