_toFlowchart: A Prototype Compiler to Convert Source-Code to Flowchart

Nasik Shafeek, Damith Karunarathne · 2018

In the modern distributed software development environment inter-developer communication is mainly through the source-code they write themselves. Source-code that one developer writes may not definitely make sense to another, the understandability depends on the proficiency in the language and the logical thinking pattern of the developer. Main goal of source-code is to instruct a computer to follow a series of instructions/computations in-order to achieve a goal. Instructions to a computer follows a logical flow. There is also another dimension, when distributed software development is concerned, where people need to read and understand the source-code, similar to any kind of literature. Over the years, flowcharts are proven to be standard in depicting the logical flow of processes and effective in representing the flow control of software programs. It would be worthwhile to establish a software program that would convert source-code to flowcharts, in-order to bridge the aforementioned gap in understanding software programs by directly reading the code. The existing techniques, which are publicly made available, does not use abstract representation (AST - Abstract Syntax Tree) in the process of translation, they translate from one programming language to flowchart diagrams directly, hence this proves hard in expanding it to support other programming languages. This research studies the feasibility of constructing a prototype compiler, which translates source-code to flowcharts without changing the semantics of the program; employing abstractions over the process of translation, thereby making it easier to expand the support for other programming languages other than the one experimented on. As the compiler constructed is a prototype, a scope was defined for it to support only a subset of language constructs. The studied compiler is so modelled that it can translate source-code (source-language) to flowcharts (target-language) when the source-code written in a programming language and the corresponding language's parser are provided. This is a novel approach. The compiler is divided into 3 sub-compilers, one responsible for converting source-code to AST, the next one converting AST to Dot language representations, the final one converting Dot language representations to flowcharts, which incurs a library named GraphViz. The AST is abstracted to an abstract grammar, which acts as the contract for supporting source-code written in other programming languages; by constructing the corresponding parser which generated AST complying to the grammar provided. The results produced by the prototype compiler (flowcharts), when implemented, with the source-code written by hand were evaluated. The generated flowcharts were proven to be correct representations of the source-code (the semantics of the generated flowcharts were found to be equal to the semantics of the source-code written) and found to be valid according to flowchart specifications.

Read the paper · More papers on PaperTik