Subtopic 3 of 5
6.3Dependency graphs and evaluation order
Edges go from an attribute to those that depend on it. Evaluate in a topological order. A cycle means the definition cannot be evaluated.
C.s?
B.s = C.s × 2?
A.s = B.s + 1?
- Dependency graph: C.s → B.s → A.s. C.s depends on nothing: evaluate it first (from the lexer).
- B.s needs C.s: now ready
- A.s needs B.s: ready last (topological order C, B, A)
Previous year questions: Syntax-Directed Translation (9)
PYQs are grouped by topic, so this is the full set for Syntax-Directed Translation; try the ones that match this subtopic. Open all 9 on the topic page.