I'm trying to implement Warshall's algorithm to quickly compute LR(1) closures.
I think I understand how it works for LR(0):
- The nodes of the graph are LR items, like
A → B • C
- The edges are "transitions" starting from
A → B • C
toC → • D
The trouble is, LR(1) requires computation of lookaheads, and I can't figure out how to incorporate them into the algorithm.
It seems to me that even if I know the transitive closure of any given LR item I still need to go through all the same computation just to figure out what the lookahead set for each item is.
Is it even possible to use Warshall's algorithm to calculate canonical LR(1) closures, or is it only possible for more restricted cases (like LR(0), SLR(1), etc.)?