Search code examples
parsinggrammarbnfambiguous-grammar

What is the easiest way of telling whether a BNF grammar is ambiguous or not?


Namely, is there a tool out there that will automatically show the full language for a given grammar, including highlighting ambiguities (if any)?


Solution

  • There might be some peculiarity about BNF-style grammars, but in general, deciding whether a given context-free grammar (such as BNF) is ambiguous is not possible.

    In short, there does not exist a tool because in general, that tool is mathematically impossible. There might be some special cases that could work for you, though.