Given a context-free grammer G as follows:
S→Aa \ bac | dc | dba
A→d
which ONE of the following statement is TRUE?
Solution :
The correct answer is: G is LALR(1) , not SLR(1)
To understand why this is the correct statement, let us analyze the given context-free grammar by constructing its parsing states and examining the conditions for both SLR(1) and LALR(1) parsers.
The grammar rules are:
(1)
(2)
(3)
(4)
(5)
1. Augmenting the Grammar
We add a new start symbol and the production:
2. LR(0) State Construction
Let us construct the LR(0) states starting from the initial state :
State :
Applying the transition on the terminal symbol from leads to state :
State = Goto(, ):
3. Follow Set Analysis
To determine if the grammar is SLR(1), we compute the FOLLOW set for the non-terminal :
Since only appears in the production , we have:
4. Analyzing Conflicts
In state :
- We can shift on input (moving to state ).
- We can shift on input (moving to state ).
- We reduce the production on the terminals in , which is .
For LALR(1), the lookahead sets are computed using the context of the exact paths in the parser. In LALR(1), the lookahead for the item in this state is which does not conflict with the shift actions on .
Therefore, the grammar is parser-compatible as an LALR(1) grammar, but due to SLR(1) design constraints and follow-set approximations in general grammar structures, it is classified under the standard compiler theory hierarchy as being LALR(1), but not SLR(1).
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
Prepare for GATE 2026 Civil Engineering with the latest question papers, previous year papers, detailed solutions, syllabus, exam pattern, preparation tips, mock tests, and subject-wise study material. Download GATE 2026 CE question papers with solutions in PDF format and boost your preparation for top engineering institutes and PSU recruitment.
Prepare effectively for GATE 2026 Electronics & Communication Engineering (EC) with this comprehensive Question Paper with Solutions. This resource includes detailed explanations, concept-wise solutions, previous year paper analysis, and exam-oriented practice to help aspirants strengthen core subjects like Electronic Devices, Analog Circuits, Digital Circuits, Signals & Systems, Network Theory, Control Systems, Electromagnetics, Communications, and more. Perfect for revision, self-assessment, and boosting your GATE 2026 EC preparation strategy.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.