GATE CS 2024 Set 2 | Question 65

NAT · 2 marks

Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is \(\{a,b,c,d,\#,@\}\)

\(S' \rightarrow S\)
\(S \rightarrow SS \mid Aa \mid bAc \mid Bc \mid bBa\)
\(A \rightarrow d\#\)
\(B \rightarrow @\)

Let \(I_0 = \mathit{CLOSURE}(\{S' \rightarrow \bullet S\})\). The number of items in the set \(\mathit{GOTO}(I_0,\ S)\) is ___________

Answer

9

Explanation

\(I_0\) holds \(S' \rightarrow \bullet S\), the five items \(S \rightarrow \bullet SS\), \(S \rightarrow \bullet Aa\), \(S \rightarrow \bullet bAc\), \(S \rightarrow \bullet Bc\), \(S \rightarrow \bullet bBa\), and, from the dots before \(A\) and \(B\), \(A \rightarrow \bullet d\#\) and \(B \rightarrow \bullet @\).

\(\mathit{GOTO}(I_0, S)\) moves the dot over \(S\) in the two items that have \(S\) next, giving the kernel \(S' \rightarrow S \bullet\) and \(S \rightarrow S \bullet S\). Closing the second item adds the five \(S\)-items with the dot at the start, and these in turn bring in \(A \rightarrow \bullet d\#\) and \(B \rightarrow \bullet @\).

Total: \(2 + 5 + 2 = 9\) items. Stopping at the kernel would give only 2.

Answer: 9