Sets of items
C : Collection of sets of LR(0) items for grammar G'
C = { closure ( { S'
.S } ) }
repeat
for each set of items I in C
and each grammar symbol X
such that goto (I,X) is not empty and not in C
ADD goto(I,X) to C
until no more additions
We are now ready to give an algorithm to construct C, the canonical collection of sets of LR(0) items for an augmented grammar G'; the algorithm is as shown below:
C = { closure ( { S'
.S } ) }
repeat
for each set of items I in C and each grammar symbol X
such that goto (I,X) is not empty and not in C do
ADD goto(I,X) to C
until no more sets of items can be added to C