Hi all,

I am new to bison and would need your kind help to understand why the
following (stupid) simple grammar is ambiguous:

%left '!'
%left '='

%%

start : bool_expr ;

bool_expr : '!' bool_expr
          | num_expr '=' num_expr
          | 'b'
          ;

num_expr : bool_expr
         | 'n'
         ;

%%

There is a cycle in the rules (bool_expr depends on num_expr, which in
turn depends on bool_expr), but I can't imagine an input that would be
ambiguous. However, bison reports the following reduce/reduce
conflict:

State 7

    2 bool_expr: '!' bool_expr .
    5 num_expr: bool_expr .

    '='       reduce using rule 2 (bool_expr)
    '='       [reduce using rule 5 (num_expr)]
    $défaut  reduce using rule 2 (bool_expr)

I don't understand what are the 2 conflicting semantic actions that
can be performed here. Could someone explain me please (perhaps with a
counter-example?)

Thanks,
Florent Teichteil.

_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to