A flowchart generator using GraphViz

agent on 2005-11-01T10:46:29

I'm now hacking on a GraphViz application that generates flowcharts. I've designed a tiny scripting language to describe the detailed structure of a program's control flow. This language is very similar to MASM, since flowcharts look pretty close to assembly languages from the point view of branching. Here's a tiny example to illustrate the basic idea:

_______ ( start ) ------- || \/ /----------------/ / input a string <--------+ /----------------/ | || | \/ | +--------------------+ | | convert to a number| | +--------------------+ | || | \/ | /---------------------/ | / output the hex form / | /---------------------/ | || | || | \/ | || | / \ | / \ | / \ | - quit? +------------+ \ / \ / \ / || || \/ ______ ( end ) ------

The corresponding script is as following:

start start L1: io input a string do convert to number io output the hex form test quit? jno L1 end end

Note that the opcode of each Asm-like instruction is a keyword, such as "start", "io", "do", "test", "jno" and "end". The label "L1" is also critical to the flowchart's structure. Other stuff, such as the long string "convert to a number", is all arbitrarily determined by the user. The compiler just displays these chars in the flowchart verbatim.

Well, it's time for me to name this scripting language formally. Eh, FlowAsm is a good choice. So all FlowAsm source files should be ended with the .fa extension.

FolwAsm is already simple, but it's some kind of immediate languages which are not supposed to be used directly by the user. Hence, the end-user will probably use a more advanced pseudo-language which has saner control flow structures like "if", "while", and "for" statements. Moreover, we may be able to translate real-world C/C++/Perl code to FlowAsm code in the foreseeable future. Converting assembly programs to FolwAsm scripts can be easier.

I started this project because I found no parallel efforts on CPAN except an ASCII version named Text::Flowchart.