V -> 'x' *
Currently the stack has states [0,1,2], and we pop 2 and reduce with V -> 'x', reaching state 3*:
C -> ( V * e. C |-> C )
C -> V *
Here we have a shift-reduce conflict, as you said, since we want to shift 'e.' and also reduce C -> V. To see if we can discover the necessary repair to the table (to shift here and add the special derived rule W -> V e. C), we backtrack to look at the stack more carefully. We arrived at C -> * V by closure from W -> C e. C, so we composite these two rules to get W -> V e. C and pretend that state 1 was actually:
W -> ( * W /\ W )
C -> ( * V e. C |-> C )
W -> * ( W /\ W )
W -> * V e. C
W -> * 'ph'
(which was created by suppressing W -> C e. C and adding W -> V e. C when taking the closure of {W -> ( * W /\ W ), C -> ( * V e. C |-> C )} ) so that the reduction actually leads to state 3, which looks like:
C -> ( V * e. C |-> C )
W -> V * e. C
Shifting the 'e.', we reach state 4:
C -> ( V e. * C |-> C )
W -> V e. * C
C -> * ( V e. C |-> C )
C -> * V
C -> * 'A'
V -> * 'x'
and shift 'A' to get to state 5:
C -> 'A' *
and pop 5 and reduce with C -> 'A'. At this point the stack has states [0,1,3,4,5], and the reduce takes us to state 6:
C -> ( V e. C * |-> C )
W -> V e. C *
This is a shift-reduce conflict for LR(0), but the lookahead tells us that since |-> is not in the follow set of W we should only reduce W -> V e. C if the next token is not |->. Since the stack is now [0,1,3,4,6], the reduce would pop 3,4,6 and take us to state 7:
W -> ( W * /\ W )
The rest continues as you would expect. The reduction by W -> V e. C entails unfolding its composite definition - to keep it linear time you could output a special theorem to the RPN here and then expand it in a second pass.
One problem with this approach is that in the final step we rely on |-> not being in the follow set of W. Although there are currently no rules of the form C -> & W where & is some terminal, this is by no means a prohibited syntax extension (it is a prefix axiom in the language of grammar-ambiguity.txt), and it would add |-> to the follow set of W by the derivation ( V e. & W |-> C ). Nevertheless it is still impossible for state 6 to allow reducing W -> V e. C because the other derivation C -> ( V e. C * |-> C ) implies that the token before W is '(', not '&'.
For another example, let's try to derive the aforementioned theorems "class <. x , A >." and "class <. x , y >.". A minimal example grammar:
C -> { <. V , V >. | W }
C -> <. C , C >.
C -> { C }
C -> V
C -> 'A'
W -> 'ph'
V -> 'x'
We will parse { <. x , x >. | ph } against { <. x , x >. }. State 0:
C -> * { <. V , V >. | W }
C -> * <. C , C >.
C -> * { C }
C -> * V
C -> * 'A'
V -> * 'x'
shift '{', state 1:
C -> { * <. V , V >. | W }
C -> { * C }
C -> * { <. V , V >. | W }
C -> * <. C , C >.
C -> * { C }
C -> * V
C -> * 'A'
V -> * 'x'
shift '<.', state 2:
C -> { <. * V , V >. | W }
C -> <. * C , C >.
C -> * { <. V , V >. | W }
C -> * <. C , C >.
C -> * { C }
C -> * V
C -> * 'A'
V -> * 'x'
shift 'x', state 3:
V -> 'x' *
pop 3 and reduce V -> 'x', state 4*:
C -> { <. V * , V >. | W }
C -> V *
A shift-reduce conflict is obtained. We reached state 4* from state 2, so we composite C -> V with C -> <. C , C >. so that the correct state 4 is:
C -> { <. V * , V >. | W }
C -> <. V * , C >.
shift ',', state 5:
C -> { <. V , * V >. | W }
C -> <. V , * C >.
C -> * { <. V , V >. | W }
C -> * <. C , C >.
C -> * { C }
C -> * V
C -> * 'A'
V -> * 'x'
shift 'x', taking us back to state 3, then reduce V -> 'x' to get to state 6*:
C -> { <. V , V * >. | W }
C -> V *
Again, a shift-reduce conflict, so we backtrack from state 6* to state 5; the offending reduction is C -> V through C -> <. V , C >. so we composite again to get state 6:
C -> { <. V , V * >. | W }
C -> <. V , V * >.
shift '.>', state 7:
C -> { <. V , V >. * | W }
C -> <. V , V >. *
And now the lookahead tells the difference between shift and reduce. Note that the two constructed rules C -> <. V , C >. and C -> <. V , V >. match the previously given rules
class <. x , A >.