I'm trying to build a complexity analysis tool and I need an algorithm for constructing the control flow graph (to get cyclomatic and eventually essential complexity). I couldn't find any pseudocode online so I just got down to writing it. Using recursion seems to have been a bad way to go; my code handles most simple cases but with deeper nesting of control structures errors arise.

Is there somewhere I can find pseudocode for constructing the CFG?

(For the curious I'm doing this for VHDL.)

  • $\begingroup$ Standard compiler textbooks should describe how to build a CFG. Which ones have you looked at so far? $\endgroup$
    – D.W.
    Jun 5 '17 at 22:40
  • $\begingroup$ Compilers, dragon book is my favorite. I have never heard about tools generating CFGs. As for parsers from CFGs, then GNU Bison and friends. $\endgroup$
    – fade2black
    Jun 5 '17 at 22:52
  • $\begingroup$ @fade2black This question is about control flow graphs, not context-free grammars. $\endgroup$ Jun 6 '17 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.