LALR(1) parsers resolve their conflicts using a single-character lookahead. When the lookahead can't disambiguate between the different actions, the conflict is then shown to the user.
In the following state, a "?" lookahead means the parser can shift.
A : B . '?'
A : B .
But what if it reduces A? It could possible reduce into the following state:
B: "c" A "t" A .
Which, by reducing B, could lead right back into:
A : B . '?'
A : B .
Therefore, "?" is also a valid lookahead to reduce.
So how can you solve this?
You have two options:
1) Try to rewrite the grammar with left-recursion instead of right-recursion. It might help, but that's not guaranteed.
2) Tell YACC which one to choose whenever it has this conflict (For example, using %left or %right).
Or, perhaps, use a smarter parser. For example elkhound or antlr.
cata?
? Which A gets the trailing?
? – Scott Hunter