Ambiguous BNF Detection

I have a task to fix the ambiguous BNF, but I'm completely lost. I know that this is not a real programming issue, and I will be happy to remove it if this is not suitable for these tips. Are there any good sites where I could learn more about BNF? The one I'm dealing with seems pretty simple, but I can't find any examples or good explanations regarding BNF. I had some experience discovering ambiguous parsing trees and other kinds of grammars, but I completely lost it.

Since this is a school assignment, I'm not sure I should post the BNF, but if anyone knows of a good site I could take a look at to better understand how to attack my question. I really just don't know where to start.

+4
source share
2 answers

Some BNFs that describe context-free grammar also describe a state machine (in this case, Pushdown automata ). The best way to do this is probably to check the condition of the machine.

As a starting point, you can see that the conflict is in the parsers that use such machines .

+1
source

If there are two or more identical non-terminals on the right side of a sentence, this is ambiguous. For example: <expr> β†’ <expr> + <expr> | <facto>. Rectangular expr can be exported differently in a tree, so you can draw different trees and do it ambiguously.

0
source

All Articles