[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to resolve a shift/reduce conflict in simple grammar
From: |
sandori |
Subject: |
Re: How to resolve a shift/reduce conflict in simple grammar |
Date: |
Fri, 27 Nov 2009 09:51:08 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hi!
What about using left recursive rules?
seq0: seq0 '0'
| '0'
;
regards
Istvan
On Thu, Nov 26, 2009 at 10:49:47PM +0100, Daniel Rentz wrote:
> 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
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison