I have been trying to figure out what is the correct approach for retrieving a control flow graph for a Python code, I'm looking for similar output as I got with a gcc output on a c program (I have used the gcc -fdump-tree-cfg).
I'll give a short example for clarifying my intentions, for example given the following simple c source code:
I have got the control flow graph which looks like this:
The cfg output consists the original c keywords and goto instructions, instead of loops (for, while etc..), which is great for my purpose.
So for the past few days I was looking into implementing a cfg generator for a python code, delved into AST module (read: Green Tree Snakes ) but it looks the AST parses each keyword in great detail but I would like to avoid it . I'm more interested in focusing on the flow of the original keywords taken from the original python script.
Does anybody has any suggestion, how to achieve it?
Thank you all!