GATE CS 2024 Set 2 — Question 65
NAT+2 / -0HardLR(0) & SLR(1)Syntax AnalysisCompiler Design
Compiler Design → Syntax Analysis → LR(0) & SLR(1)
Last updated
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 ___________
Correct answer
9 to 9
Solution
To find the number of items in , we first determine the set and then compute the transition for the symbol .
The complete set of items is:
1.
2.
3.
4.
5.
6.
7.
8.
9. There are 9 items in total.
1.Compute :
- Start with the initial item: .
- Since the dot is before , add all productions of with the dot at the beginning:
- Now, check for non-terminals after the dot in the newly added items:
- In , the dot is before . Add productions: .
- In , the dot is before . Add productions: .
- Thus, .
- .
- The items in with immediately after the dot are and .
- Moving the dot over gives the kernel of the new state: .
- Now, compute the closure of this kernel:
- is already complete.
- For , the dot is before , so we add all productions with the dot at the beginning:
- In , the dot is before , so add .
- In , the dot is before , so add .
The complete set of items is:
1.
2.
3.
4.
5.
6.
7.
8.
9. There are 9 items in total.
More questions on Syntax Analysis
2024 Set 2 Q21Consider the following two sets: | Set X | Set Y | | :--- | :--- | | P. Lexical Analyzer | 1.…2024 Set 1 Q26Which of the following is/are Bottom-Up Parser(s)?2024 Set 2 Q29Which of the following statements is/are FALSE?2024 Set 1 Q37Consider the following syntax-directed definition (SDD). | Production | Semantic Rules | | ------ |…2024 Set 1 Q38Consider the following grammar , with as the start symbol. The grammar has three…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free