Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source-code Visualizer #827

Open
emil14 opened this issue Jan 10, 2025 · 0 comments
Open

Source-code Visualizer #827

emil14 opened this issue Jan 10, 2025 · 0 comments
Assignees
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Jan 10, 2025

Example DOT for 99_bottles

digraph G {
    // Graph styling
    rankdir = LR;
    node [shape = box; style = "rounded,filled"; fillcolor = lightblue;];
    edge [color = "#666666";];
    
    // Components as subgraphs
    subgraph cluster_main {
        label = "Main";
        style = filled;
        color = lightgrey;
        node [style = "rounded,filled"; fillcolor = white;];
        
        main_start [label = "start";];
        main_print [label = "print\nFor<int>";];
        main_wait [label = "Wait";];
        main_stop [label = "stop";];
        
        main_start -> "99..-1" -> main_print -> main_wait -> main_stop;
    }
    
    subgraph cluster_next2lines {
        label = "Next2Lines";
        style = filled;
        color = lightgrey;
        node [style = "rounded,filled"; fillcolor = white;];
        
        n2l_data [label = "data";];
        n2l_first [label = "first\nTap<int>";];
        n2l_dec [label = "dec\nDec<int>";];
        n2l_second [label = "second";];
        n2l_sig [label = "sig";];
        
        n2l_data -> n2l_first -> n2l_dec -> n2l_second -> n2l_sig;
    }
    
    subgraph cluster_firstline {
        label = "FirstLine";
        style = filled;
        color = lightgrey;
        node [style = "rounded,filled"; fillcolor = white;];
        
        fl_data [label = "data";];
        fl_switch [label = "switch";shape = diamond;];
        fl_p1 [label = "p1\nfmt.Println";];
        fl_p2 [label = "p2\nfmt.Println";];
        fl_p3 [label = "p3\nfmt.Printf";];
        fl_panic [label = "panic\nPanic";fillcolor = "#ffcccc";];
        fl_sig [label = "sig";];
        
        // String literals
        fl_str0 [label = "'No more bottles of beer on the wall,\nno more bottles of beer.'";shape = note;fillcolor = "#e6ffe6";];
        fl_str1 [label = "'1 bottle of beer on the wall,\n1 bottle of beer.'";shape = note;fillcolor = "#e6ffe6";];
        fl_strn [label = "'$0 bottles of beer on the wall,\n$0 bottles of beer.\n'";shape = note;fillcolor = "#e6ffe6";];
        
        fl_data -> fl_switch;
        fl_switch -> fl_str0 [label = "0";];
        fl_switch -> fl_str1 [label = "1";];
        fl_switch -> fl_strn [label = "default";];
        fl_str0 -> fl_p1;
        fl_str1 -> fl_p2;
        fl_strn -> fl_p3;
        fl_p3:e -> fl_panic [label = "err";];
        {fl_p1 fl_p2 fl_p3} -> fl_sig;
    }
    
    subgraph cluster_secondline {
        label = "SecondLine";
        style = filled;
        color = lightgrey;
        node [style = "rounded,filled"; fillcolor = white;];
        
        sl_data [label = "data";];
        sl_switch [label = "switch";shape = diamond;];
        sl_p1 [label = "p1\nfmt.Println";];
        sl_p2 [label = "p2\nfmt.Println";];
        sl_p3 [label = "p3\nfmt.Println";];
        sl_p4 [label = "p4\nfmt.Printf";];
        sl_panic [label = "panic\nPanic";fillcolor = "#ffcccc";];
        sl_sig [label = "sig";];
        
        // String literals
        sl_strm1 [label = "'Go to the store and buy some more,\n99 bottles of beer on the wall.'";shape = note;fillcolor = "#e6ffe6";];
        sl_str0 [label = "'Take one down and pass it around,\nno more bottles of beer on the wall.\n'";shape = note;fillcolor = "#e6ffe6";];
        sl_str1 [label = "'Take one down and pass it around,\n1 bottle of beer on the wall.\n'";shape = note;fillcolor = "#e6ffe6";];
        sl_strn [label = "'Take one down and pass it around,\n$0 bottles of beer on the wall.\n\n'";shape = note;fillcolor = "#e6ffe6";];
        
        sl_data -> sl_switch;
        sl_switch -> sl_strm1 [label = "-1";];
        sl_switch -> sl_str0 [label = "0";];
        sl_switch -> sl_str1 [label = "1";];
        sl_switch -> sl_strn [label = "default";];
        sl_strm1 -> sl_p1;
        sl_str0 -> sl_p2;
        sl_str1 -> sl_p3;
        sl_strn -> sl_p4;
        sl_p4:e -> sl_panic [label = "err";];
        {sl_p1 sl_p2 sl_p3 sl_p4} -> sl_sig;
    }
    
    // Inter-component connections
    edge [color = "#0066cc"; style = dashed;];
    main_print -> n2l_data;
    n2l_first -> fl_data;
    n2l_second -> sl_data;
}
@emil14 emil14 self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant