Question
Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is
Let . The number of items in the set is ___________
Official answer and solution
- Official answer
- 9
- From
- Official GATE 2024 answer key
Solution
Find the kernel items of by advancing the dot past in , then compute by expanding nonterminals immediately following the dot.
- In , the items having the dot () immediately before are:
- Advancing the dot past gives the kernel items of (2 items):
- Since the dot in immediately precedes nonterminal , adds all productions of with a leading dot (5 items):
3.
4.
5.
6.
7. - Because has the dot before and has the dot before , also adds the productions of and (2 items):
8.
9.
Total number of LR(0) items in is .
Final answer
9
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- Question
- 65 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.