Search code examples
parsingcompiler-constructiongrammarlr-grammarambiguous-grammar

If the grammar is ambiguous then there exists exactly one handle for each sentential form.?


there can be two productions from which we can do the reduction. After giving precedence and associations as required there will be one handle only.so is this statement true??


Solution

  • This is partially true, a reduce/reduce conflict is usually resolved by specifying precedence or by letting the parser builder choose which rule to apply before the other.

    This means that the conflict is solved but not that the parser is going to behave exactly as intended. It is convenient to study what is causing the conflict and think if a refactoring of the grammar is needed to express what you are trying to parse or if the automatic choice/precedence is enough.