[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to resolve a shift/reduce conflict in simple grammar
From: |
Daniel Rentz |
Subject: |
How to resolve a shift/reduce conflict in simple grammar |
Date: |
Thu, 26 Nov 2009 22:49:47 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Hello everybody,
This is my first posting on this list, I have looked through the archive
for similar topics, but didn't find anything helpful.
The following grammar gives 2 shift/reduce conflicts. I have simplified
it as good as possible. The intention of the grammar is to "collect"
blocks of consecutive '0' and '1' characters from input until a
semicolon occurs.
start : sequences ';' ;
sequences : sequences sequence | ;
sequence : seq0 | seq1 ;
seq0 : '0' seq0 | '0' ;
seq1 : '1' seq1 | '1' ;
I can understand that Bison finds the conflicts, e.g.
state 5
6 seq0: '0' . seq0
7 | '0' .
'0' shift, and go to state 5
'0' [reduce using rule 7 (seq0)]
$default reduce using rule 7 (seq0)
seq0 go to state 10
My question: How can I tell Bison that shifting is really intended?
Best regards
Daniel
- How to resolve a shift/reduce conflict in simple grammar,
Daniel Rentz <=