Non-deterministic parser state for ambiguous example with priorities
See original GitHub issueI have a very small example of an ambiguity in a parser:
from lark import Lark
l = Lark(
'''start: GENERIC | SPECIFIC
GENERIC.2: /\w+/
SPECIFIC.1: "HelloWorld"
''', parser="earley", lexer="dynamic", ambiguity="resolve"
)
for i in range(1, 101):
print(l.parse("HelloWorld"))
Both GENERIC and SPECIFIC matches, but I have set a priority forcing GENERIC to match. This is not always the result though. If running this program multiple times it will match either GENERIC or SPECIFIC seemingly random. All matches for one run will be the same, but not between runs. This signals that a state in the parser is different between the runs.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Deterministic Parsing of Ambiguous Grammars
We shall give some examples of how ambiguities in grammars can be naturally resolved using operator precedence and recursive descent techniques. 2. We...
Read more >How is non-ambuiguity different from determinism?
First off, a string is not a language; strings are not ambiguous, unambiguous, deterministic or nondeterministic; they're just strings. The ...
Read more >Ambiguous Grammar - an overview | ScienceDirect Topics
First, make sure the grammar is not ambiguous; second, keep the grammar in Greibach Normal Form. If the same sentence can emerge from...
Read more >LR parsing and conflicts - parglare - Igor Dejanović
LR parsing, ambiguities and conflicts resolving¶. LR parser operates as a deterministic PDA (Push-down automata). It is a state machine which is always...
Read more >Analyzing Ambiguity of Context-Free Grammars
Ambiguity in context-free grammars is a recurring problem ... An increasing number of parser generators, for example, Bison [33], SDF [35],.
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
@dirk-thomas
0.7b
is the latest candidate. I hope to merge it to master in the next couple of weeks.An official release might take a little longer, because I’ll want to make sure the documentation reflects all the changes.
0.7 published