Describe why shift/reduce and reduce/reduce conflicts occur

This commit is contained in:
Charles Baker 2021-05-09 15:10:14 +12:00
parent 7b51a6a040
commit 49a092e70d

View file

@ -324,6 +324,8 @@ The precedence of a production defaults to that of its right-most terminal but c
### Shift/Reduce Conflicts
Shift/reduce conflicts arise when the parser is unable to decide between shifting another token onto the stack or reducing the top of the stack that matches the right hand side of a production.
Shift/reduce conflicts are resolved by examining the associativity and precedence of the symbol that is to be shifted and reduced on and the production that is to be reduced. Shift/reduce conflicts are resolved in the following way:
- If either the symbol or the production lack precedence information then the conflict is not resolved, an error is reported, and the grammar fails to generate a parser.
@ -336,6 +338,8 @@ Shift/reduce conflicts are resolved by examining the associativity and precedenc
### Reduce/Reduce Conflicts
Reduce/reduce conflicts arise when the parser is unable to decide which production to reduce on when the top of the stack matches the right hand side of a more than one production.
Reduce/reduce conflicts are resolved by examining the precedence of the two conflicting productions. Reduce/reduce conflicts are resolved in the following way:
- If either of the productions lack precedence information or both productions have the same precedence then the conflict is not resolved, an error is reported, and the grammar fails to generate a parser.