GATE CSE 2019 Q29: FOLLOW set of B in S → Aa, A → BD, B → b | ε, D → d | ε
- Compiler Design
- 1 mark
- NAT
- No negative marking
Syllabus topic: Lexical analysis, parsing and syntax-directed translation
Question
Consider the grammar given below:
Let a, b, d, and be indexed as follows:
| a | b | d | $ |
|---|---|---|---|
| 3 | 2 | 1 | 0 |
Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is , then the answer should be 3210)
Answer: ________.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 31 (official GATE 2019 final answer key)
Concept used: FOLLOW(B) contains FIRST of what follows B; if that can derive , it also includes FOLLOW of the left-hand side.
First step: From , add FIRST(D) minus to FOLLOW(B); since D is nullable, also add FOLLOW(A), which comes from .
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Lexical analysis, parsing and syntax-directed translation
Every PYQ on this topic →Share this question
Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 1 · Q53Compare two SDDs for type declarations
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar