Le 18 nov. 2013 à 22:17, Florent Teichteil <florent.teicht...@gmail.com> a écrit :
> Hi all, > > I am new to bison and would need your kind help to understand why the > following (stupid) simple grammar is ambiguous: Actually your question is why the conflict remains.</pedantic> > %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?) Precedence is never involved in resolving RR conflicts. It could arguably be a feature-request, but often RR conflicts are signs that you should rework your grammar (or that you should go for GLR and use %dprec). More concretely, you "fall into the classical temptation" to treat type issues at the syntactic level. Don't do that. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison