lark: Early parser fails to detect ambiguity in terminals

I am working on Python 3.7.3, Lark 0.7.1

Consider the following very simple example:

grammar = r"""
    start           : item_list
    item_list       : item_list? item
    item            : A | B 
    A               : "a" | "ab"
    B               : "b"
"""
parser = Lark(grammar, parser="earley", ambiguity="explicit", debug=True)

result = parser.parse("ab")
print(result.pretty())

With the explicit option, I expected something like:

start
  __ambig
    item_list
      item_list
        item	a
      item	b
    item_list
      item ab

However, the output is:

start
  item_list
    item_list
      item	a
    item	b

Is this a bug? Or am I misunderstanding something?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

That does look like a bug, from a cursory glance. I’ll add the “bug” tag until proven otherwise.

@night199uk Do you have any insight to add?