GATE Computer ScienceVery hardGATE CS · ISRO
In S → A B C | C a; A → a A | ε; B → b B | A c | ε; C → d | B e, how many symbols (including $) does FOLLOW(B) contain?
- A. 4
- B. 6
- C. 7
- D. 5
Correct answer: D. 5
In S → A B C, B is followed by C, so FOLLOW(B) ⊇ FIRST(C) = {d} ∪ (FIRST(B) = {a, b, c}) ∪ {e}, where e comes from C → B e. Hence FOLLOW(B) = {a, b, c, d, e}, 5 symbols; $ is not included because C is not nullable.
More Compiler Design questions
- How many of these four grammars are LL(1)? (1) S → a S b | ε; (2) S → A B; A → a | ε; B → a | b; (3) S → a A | b; A → S c | ε; (4) S → S a…
- Statements: 1: a = 1; 2: b = 2; 3: c = a + b; 4: d = c 2; 5: if d > 10 goto 8; 6: e = a + d; 7: goto 9; 8: e = b + 1; 9: print e. Which…
- A C lexer applies the maximal-munch rule (always take the longest possible token). How many tokens does it produce for the input…
- How many basic blocks does this three-address code contain? 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s…
- Using Sethi–Ullman numbering (a leaf that is a left operand needs 1 register, a leaf that is a right operand can be used from memory and…
- Grammar: S → A B D; A → a A | ε; B → b B | A c | ε; D → d D | ε. What is |FOLLOW(A)| + |FOLLOW(B)| + |FOLLOW(D)|? (FOLLOW sets may contain…