>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' ;

The short answer is that you don't have to do anything, since Bison
takes the shift to resolve a S/R conflict.  Normally I would advise
rewriting the grammar to get rid of the ambiguity, but in this case,
all of the alternatives I can think of are ugly and complex.

You can put this in the header part to shut it up:

%expect 2

You could also use this to tell it that you expect conflicts on '0'
and '1' and to resolve it by the shift:

%right '0' '1'

but it would mask any other conflicts involving 0 and 1, so I'd use the
expect so you'll see any other unintended conflicts.

R's,
John


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to