GATE Computer ScienceModerateGATE CS (PYQ pattern)
Which of the following is/are true? I. Every S-attributed definition is L-attributed. II. Every L-attributed definition can be evaluated in one depth-first left-to-right traversal of the parse tree. III. An SDD whose dependency graph has a cycle for some parse tree can be L-attributed. IV. For an S-attributed definition, attributes can be evaluated on each reduce move of an LR parser using the attribute values kept on the stack.
- A. I, II and III only
- B. II, III and IV only
- C. I and IV only
- D. I, II and IV only
Correct answer: D. I, II and IV only
I: no inherited attributes, so the L-rules hold. II: that is the defining property of L-attributed. III: an L-attributed definition cannot have a cycle, since each attribute depends only on attributes already available in left-to-right order. IV: standard bottom-up evaluation with a value stack.
More Compiler Design questions
- For S → S ( S ) | ε (augmented), count the reduce entries ( column included, accept excluded) in the SLR(1) and in the LALR(1) ACTION…
- A table-driven LL(1) parser for S → ( S ) S | ε parses "( ) ( )". Each pop of a non-terminal (expanding it) and each match of a terminal…
- An array A[1..4], [0..5], [1..6] of 8-byte elements is stored in row-major order starting at address 500. What is the address of A[3][2][5]?
- For G: S → A b | a A c | B c | a B b; A → a; B → a, which statements are true? I. G is LL(2). II. G is SLR(1). III. G is LALR(1). IV. The…
- For E → id | E [ E ] | ( E ) (augmented), how many states does the LR(0) automaton have, and which is the strongest of LR(0) / SLR(1) /…
- S → A B; A → a | ε; B → A b | c generates exactly five strings, and its LL(1) table has one multiply-defined cell. If that cell is…