GATE Computer ScienceModerateGATE CS (PYQ pattern)
For the grammar S → A B; A → a | ε; B → A b | c, what is FOLLOW(A)?
- A. {b, c}
- B. {a, b, c}
- C. {$, a, b, c}
- D. {a, b}
Correct answer: B. {a, b, c}
A occurs in S → A B, where FIRST(B) = {a, b, c} (B → A b can start with a, or with b when A is empty, or with c), and B is not nullable; in B → A b it adds b. So FOLLOW(A) = {a, b, c}.
More Compiler Design questions
- Expressions are compared textually and an assignment to an operand kills the expressions that use it. Which expressions are available on…
- A scanner (longest match, ties to the earlier rule) has rules: COMMENT = //[^newline]; STR = "[^"]"; DIV = /; EQ = ==; ASSIGN = =; ID =…
- SDD for S → ( S1 S2 ) | a: the inherited attribute S.n is 1 at the root, and for S → ( S1 S2 ) the rules are S1.n = 2 × S.n and S2.n = 2 ×…
- Minimal SSA form (φ-functions placed at the iterated dominance frontier of each variable's definition blocks, without liveness pruning…
- Which of the following about run-time environments is/are true? I. An access (static) link points to the frame of the lexically enclosing…
- For S′ → S; S → S ( S ) | ε, LALR(1) merges canonical LR(1) states with equal cores. The LALR state whose only item is S → S ( S ) · is…