Limiting Parsings for Ambiguous Grammars (Bocages)
See original GitHub issueI know its a long shot and not really something earley was meant for, but are there any methods or optimizations we can implement to deal with ambiguous grammars with exponential parsings? For instance:
num -> num "+" num | [0-9]:+
This seems simple, but nearley can’t deal well with large statements of this type because the amount of possible parsings is exponential with the number of plus signs. Could we implement the option of limiting the number of parsings?
Issue Analytics
- State:
- Created 8 years ago
- Comments:23 (14 by maintainers)
Top Results From Across the Web
Removal of ambiguity (Converting an Ambiguous grammar ...
In this article we are going to see the removal of ambiguity from grammar using suitable examples. Ambiguous vs Unambiguous Grammar : The ......
Read more >Grammar equivalence, eliminating ambiguities, adapting to LL ...
Works for some ambiguities and some parser algorithms. Alternatively, use general parser: Constructs all parse trees. Disambiguate after parsing ...
Read more >compilers - Why are ambiguous grammars bad?
Parsing natural languages with their ambiguous grammars is so hard that traditional parsers can't do it! – Davislor. Jun 10, 2019 at 16:46....
Read more >parsing - Ambiguous Grammar Parser - Stack Overflow
Only parser combinators that can return more than one value can handle ambiguous grammars. Such combinators use a list as their reply type."...
Read more >Ambiguous grammars and lazy parsing (and an experiment)
I have a highly-ambiguous Marpa grammar, which I've translated to a highly-ambiguous nearley grammar. I'd like to quickly check whether a ...
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 Free
Top 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
That’s not a well-written grammar, though. You should write
num -> num "+" [0-9]:+ | [0-9]:+
. If there’s an ambiguous grammar, the assumption is that you want all possible parsings (I can think of use-cases where this is a legitimate assumption).Closing because #163 can continue this discussion.