Chapter 5:Semantic Analysis

Algorithm to construct dependency graph

for each node n in the parse tree do

for each attribute a of the grammar symbol do

construct a node in the dependency graph

for a

for each node n in the parse tree do

for each semantic rule b = f (c1 , c2 , ..., ck ) do

{ associated with production at n }

for i = 1 to k do

construct an edge from ci to b

An algorithm to construct the dependency graph. After making one node for every attribute of all the nodes of the parse tree, make one edge from each of the other attributes on which it depends.