A start on the actual LR algorithm (it's going to be SLR(1), I think...).