#cpp #flowchart #tree-sitter #chart #diagrams

bin+lib cxx2flow

Convert your C/C++ code to control flow chart

17 releases (4 breaking)

0.5.4 Jan 11, 2022
0.5.3 Jan 2, 2022
0.4.2 Jan 1, 2022
0.3.0 Sep 8, 2021
0.1.6 Aug 19, 2021

#3 in #cpp

Download history 9/week @ 2021-10-02 11/week @ 2021-10-09 10/week @ 2021-10-16 12/week @ 2021-11-06 10/week @ 2021-11-13 12/week @ 2021-11-20 11/week @ 2021-11-27 14/week @ 2021-12-04 3/week @ 2021-12-11 6/week @ 2021-12-18 11/week @ 2021-12-25 130/week @ 2022-01-01 41/week @ 2022-01-08 7/week @ 2022-01-15

189 downloads per month

MIT license

51KB
1K SLoC

cxx2flow

将 C/C++ 代码转换为流程图

效果

更多效果图请参考 GALLERY

两种样式:

折线 平滑
ployline curve
inline int read() {  //快读
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}

错误报告

error reporting

安装

自行编译

cargo install cxx2flow

下载预构建二进制

推荐从右侧的 Github Release 下载对应平台的二进制文件。

也可以到 GitHub ActionsNightly.link 下载最新构建的二进制,包含 Linux, Windows 和 MacOS 版本。

使用

为了编译生成的 dot 文件,你需要安装 graphviz,并将其添加到 PATH 中。也可以将生成的结果复制进在线的 graphviz 服务中,如 http://magjac.com/graphviz-visual-editor/

cxx2flow 0.5.4
mgt <mgt@oi-wiki.org>
Convert your C/C++ code to control flow chart

USAGE:
    cxx2flow [OPTIONS] <INPUT> [FUNCTION]

ARGS:
    <INPUT>       Sets the input file. e.g. test.cpp
    <FUNCTION>    The function you want to convert. e.g. main [default: main]

OPTIONS:
    -c, --curly              Sets the style of the flow chart.
                             If specified, output flow chart will have curly connection line.
    -h, --help               Print help information
    -o, --output <OUTPUT>    Sets the output file.
                             If not specified, result will be directed to stdout.
                             e.g. graph.dot
    -t, --tikz               Use tikz backend.
    -V, --version            Print version information

Note that you need to manually compile the dot file using graphviz to get SVG or PNG files.

EXAMPLES:
    cxx2flow test.cpp | dot -Tpng -o test.png
    cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svg

Please give me star if this application helps you!
如果这个应用有帮助到你,请给我点一个 star!
https://github.com/Enter-tainer/cxx2flow

限制

  • 不支持预处理器,如 include, ifdef, ifndef...
  • 支持的控制流语句有:while,for,if,break,continue,break,return,switch, goto, do-while。

Dependencies

~18MB
~476K SLoC

a