Given AST, to create a data flow graph, you should:
create symbol tables so that each identifier used is mapped to its explicitly or implicitly defined type, also allowing you to distinguish an identifier in one scope from the same identifier in another area
plot the flow of control by showing the execution order of program code and conditional branches. (Bonus points for plotting calls between functions!)
determine how the data flows along the schedule of the control flow, usually using some kind of mechanism for analyzing the data flow , creating links to the lifetime variable and capturing all of this in the form of a graph.
You can draw the final plot using some kind of external drawing package.
All of these steps are quite complex and are likely to work a lot more than you might think. I get the impression that you don't have much experience here. You can get this background by looking at the standard compiler text (Aho / Sethi / Ullman compilers), quite classic and very good. But you need to do this before you start, or you wonβt understand the steps and they will come together.
source share