Early parser fails to detect ambiguity in terminals
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Lecture 8: Parser Conflicts, Using Ambiguity, Error Recovery
When parser gets to the y, will detect error. • Then pops items off parsing stack until it finds a state that allows...
Read more >Resolving Grammar Errors - Common Prefix Ambiguities
In some rare cases the Parser may detect ambiguities that are not actually possible or are perhaps implicitly resolved, e.g: by the order...
Read more >Ambiguity Detection: Scaling towards Scannerless
Abstract. Static ambiguity detection would be an important aspect of language workbenches for textual software languages. The challenge is that automatic.
Read more >Detecting Ambiguity in Programming Language Grammars
Ambiguous Context Free Grammars (CFGs) are problematic for programming languages, as they allow inputs to be parsed in more than one way.
Read more >compiler construction - Ambiguous non-terminal in GLR
How does knowing which non-terminals can produce an ambiguity simplify parse tree construction in a practical way?
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
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?
Updated. See here: https://lark-parser.readthedocs.io/en/latest/grammar/#terms