On 12 Jun 2007, at 22:12, SirZooro wrote:
I am trying to create grammar which has if/elseif/else instruction.
However I
am unable to get rid of shift/reduce conflicts.
Just write it as:
%token if then else
%%
statement:
if conditional then statement
| if conditional then statement else statement
;
If you do it, I think you get a simple shift/reduce conflict. Look at
the conflicting state and the two tokens before and after the "." in
the conflicting rules of that state. In this case, it should be
"then" and "else". Then apply token precedences to these two tokens, %
left, etc. though I think it does not matter which in this case.
(Since the parser generated prefers shifts over reduces, one can also
just ignore it, and set %expect.)
Hans Aberg
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison