Discussion
Arrange these grammar transformations in the order they are normally applied when preparing a grammar for predictive parsing.
1. perform left factoring
2. remove ambiguity from the grammar
3. compute the FIRST and FOLLOW sets
4. eliminate left recursion
Answer: A
Correct answer: 2 - 4 - 1 - 3
Remove ambiguity first, since neither of the other transformations helps with it and the grammar must be unambiguous before either is worth doing. Then eliminate left recursion, which a top-down parser cannot tolerate at all. Then left factor, which removes the remaining need for lookahead beyond one token. Only then compute FIRST and FOLLOW, on the grammar that will actually be used.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development