LR(0) items are production rules with a dot indicating the position in the right-hand side of the rule, with examples provided for clarification. An LR(0) item is complete if the dot is at the end, while kernel items have the dot not at the left end, with exceptions. The document also discusses the closure and goto functions essential for constructing the SLR parsing table.
LR(0) items are production rules with a dot indicating the position in the right-hand side of the rule, with examples provided for clarification. An LR(0) item is complete if the dot is at the end, while kernel items have the dot not at the left end, with exceptions. The document also discusses the closure and goto functions essential for constructing the SLR parsing table.
An LR(0) item is complete if the • is the last symbol in the rhs.
Example : I3 and I4 are complete items and I1 and I2 are incomplete items. An LR(0) item is called a kernel item, if the dot is not at the left end. However the item S ′ → •S is an exception and is defined to be a kernel item. Example : I1 , I2 , I3 are all kernel items and I4 is a non-kernel item.
The construction of the SLR parsing table requires two functions closure and goto.
closure: Let U be the collection of all LR(0) items of a cfg G . Then
closure : U → 2U . 1 closure(I ) = {I }, for I ∈ U 2 If A → α • Bβ ∈ closure(I ), then the item B → •η is added to closure(I ). 3 Apply step (ii) above repeatedly till no more new items can be added to closure(I ).
goto: goto : U × X → 2U , where X is a grammar symbol.
goto(A → α • X β, X ) = closure(A → αX • β).
Example: goto(A → •Aa, A) = closure(A → A • a) = {A → A • a}
closure and goto can be extended to a set S of LR(0) items by appropriate generalizations S closure(S) = {closure(I )} SI∈S goto(S, X ) = I∈S {goto(I , X )}