GATE CS 2024 Set 2 — Question 40
MCQ+2 / -0.67MediumLL(1) ParsingSyntax AnalysisCompiler Design
Compiler Design → Syntax Analysis → LL(1) Parsing
Last updated
Question
Consider the following context-free grammar where the start symbol is and the set of terminals is .The following is a partially-filled LL(1) parsing table.
Which one of the following options represents the CORRECT combination for the numbered cells in the parsing table?Note: In the options, "blank" denotes that the corresponding cell is empty.
| (1) | (2) | ||||
| (3) | |||||
| (4) |
A.
(1) (2) (3) (4)
B.
(1) (2) (3) (4)
C.
(1) (2) (3) blank (4) blank
D.
(1) (2) (3) blank (4) blank
Correct answer
(A) (1) S arrow AaAb (2) S arrow BbBa (3) A arrow ε (4) B arrow ε
Solution
To determine the entries in the LL(1) parsing table, we first compute the First and Follow sets for the non-terminals.1. Compute First Sets:
(1)
(2)
(3)
(4) This corresponds to Option (A).
- (from )
- (from )
- :
- For : .
- For : .
- Thus, .
- includes (start symbol).
- From :
- The first is followed by , so .
- The second is followed by , so .
- Therefore, .
- From :
- The first is followed by , so .
- The second is followed by , so .
- Therefore, .
- Cell (1) for : Since , the entry is .
- Cell (2) for : Since , the entry is .
- Cell (3) for : Since and is a production, the entry is .
- Cell (4) for : Since and is a production, the entry is .
(1)
(2)
(3)
(4) This corresponds to Option (A).
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