Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

agent (5836)

agent
  agentzh@yahoo.cn
http://agentzh.spaces.live.com/

Agent Zhang (章亦春) is a happy Yahoo! China guy who loves Perl more than anything else.

Journal of agent (5836)

Tuesday November 01, 2005
05:46 AM

A flowchart generator using GraphViz

[ #27403 ]
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.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.