English


My implementation of the flowchart generator for a given valid Python code is a multistage process. On some stages I used C/C++ to squeeze the best performance while on the others I used Python to make it easier to try various ideas without irritating necessity to re-build an application after each minor change.

The pipeline starts with parsing the source code into a syntax tree. Then the syntax tree is analyzed and all the code blocks, functions, classes etc are created as a hierarchical data structure. Then there is another pass over the source code to collect comments. Then the comments and the recognized language elements are merged into a single data structure. These stages are written in C/C++ and provided as a Python module. The further stages are written in Python. First of all the graphics items are laid out on a virtual canvas, then there is a rendering stage which is followed by drawing and painting stages. At the end we have a graphics flowchart-like diagram.

Now, let's discuss all these stages in more details.