mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
Describe why shift/reduce and reduce/reduce conflicts occur
This commit is contained in:
parent
7b51a6a040
commit
49a092e70d
1 changed files with 4 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue