Data Flow Graph Construction

前端 未结 1 1862
执念已碎
执念已碎 2021-02-10 16:26

I have been asked to write a program to construct a data flow graph of a input program code, given the abstract syntax tree. I search for the definition of data flow graph onlin

相关标签:
1条回答
  • 2021-02-10 16:49

    Given an AST, to produce a data flow graph, you must:

    • build up symbol tables, so that every identifier used is mapped to its explicitly or implicitly defined type, also allowing you distinguish an identifier in one scope from the same identifier in another scope

    • construct a control flow graph, showing the order in which the program code is executed, and the conditional branches. (Bonus points for constructing a call graph between functions!)

    • determine how data flows along the control flow graph, usually using some kind of data flow analysis framework, building up references to variable lifetimes, and capturing all this as a graph.

    You can draw the final graph using some kind of external graph drawing package.

    All of these steps are pretty complicated, and are likely to be a lot more work than you might think. I get the impression you don't have much background here. You can get that background by studying a standard compiler text (Aho/Sethi/Ullman "Compilers") is pretty classic and very good. But you need to do that before you start, or you won't really understand the steps and they link together.

    0 讨论(0)
提交回复
热议问题