help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rule cycle and reduce/reduce conflict


From: Florent Teichteil
Subject: rule cycle and reduce/reduce conflict
Date: Mon, 18 Nov 2013 22:17:06 +0100

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]