Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
LR parser
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Conflicts in the constructed tables === The automaton is constructed in such a way that it is guaranteed to be deterministic. However, when reduce actions are added to the action table it can happen that the same cell is filled with a reduce action and a shift action (a ''shift-reduce conflict'') or with two different reduce actions (a ''reduce-reduce conflict''). However, it can be shown that when this happens the grammar is not an LR(0) grammar. A classic real-world example of a shift-reduce conflict is the [[dangling else]] problem. A small example of a non-LR(0) grammar with a shift-reduce conflict is: : (1) E β 1 E : (2) E β 1 One of the item sets found is: : '''Item set 1''' : E β 1 <big>{{color|#f7f|β’}}</big> E : E β 1 <big>{{color|#f7f|β’}}</big> : '''+''' E β <big>{{color|#f7f|β’}}</big> 1 E : '''+''' E β <big>{{color|#f7f|β’}}</big> 1 There is a shift-reduce conflict in this item set: when constructing the action table according to the rules above, the cell for [item set 1, terminal '1'] contains '''s1''' (shift to state 1) '''and r2''' (reduce with grammar rule 2). A small example of a non-LR(0) grammar with a reduce-reduce conflict is: : (1) E β A 1 : (2) E β B 2 : (3) A β 1 : (4) B β 1 In this case the following item set is obtained: : '''Item set 1''' : A β 1 <big>{{color|#f7f|β’}}</big> : B β 1 <big>{{color|#f7f|β’}}</big> There is a reduce-reduce conflict in this item set because in the cells in the action table for this item set there will be both a reduce action for rule 3 and one for rule 4. Both examples above can be solved by letting the parser use the follow set (see [[LL parser]]) of a nonterminal ''A'' to decide if it is going to use one of ''A''s rules for a reduction; it will only use the rule ''A'' β ''w'' for a reduction if the next symbol on the input stream is in the follow set of ''A''. This solution results in so-called [[Simple LR parser]]s.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
LR parser
(section)
Add topic