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.

Limiting Parsings for Ambiguous Grammars (Bocages)

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
kachcommented, Mar 24, 2015

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).

0reactions
kachcommented, Aug 24, 2017

Closing because #163 can continue this discussion.

Read more comments on GitHub >

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

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