GATE Computer ScienceModerateGATE CS (PYQ pattern)
Consider an SDD where for A → B C the rules are: B.i = A.i + 1, C.i = B.s, A.s = C.s. Which statement is correct?
- A. It is not L-attributed, because C.i uses B.s, a synthesised attribute of a sibling symbol
- B. It is S-attributed, because the only synthesised attribute of A is computed from C.s
- C. It is L-attributed: each inherited attribute uses only the parent's inherited attributes and left siblings
- D. It is neither L-attributed nor S-attributed, because B.i uses the inherited value of the parent
Correct answer: C. It is L-attributed: each inherited attribute uses only the parent's inherited attributes and left siblings
S-attributed would forbid the inherited attributes B.i and C.i. L-attributed allows an inherited attribute to use the parent's inherited attributes and the attributes of siblings to its left: B.i uses A.i, and C.i uses B.s (B is to the left of C).
More Compiler Design questions
- Consider these claims about LR parsers. I. Merging LR(1) states with the same core can create a shift-reduce conflict that the canonical…
- Code: k = 3; m = k k; k = k + 1; p = k m; q = p - 36; s = q + z; r = s 1. Only r is live at the end and z is an input. After constant…
- A predictive translator uses E → T R; R → + { print('+') } T R | − { print('−') } T R | ε; T → num { print(num.val) }. (The print action…
- The grammar S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε is not LL(1). How many distinct parse trees does the string "a a a c" have?
- Construct the SLR(1) parsing table of S → a S b S | b S a S | ε (augmented). In how many states of the SLR(1) automaton does the ACTION…
- G1: S → A B; A → a A | c; B → a B | c. G2: S → A B A; A → a A | c; B → b B | c. For each, how many more states does the canonical LR(1)…