项目作者: Enter-tainer

项目描述 :
将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
高级语言: Rust
项目地址: git://github.com/Enter-tainer/cxx2flow.git
创建时间: 2021-08-17T13:02:50Z
项目社区:https://github.com/Enter-tainer/cxx2flow

开源协议:MIT License

下载


cxx2flow

简体中文 | English

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

效果

更多效果图请参考 GALLERY

两种样式:
| | |
|:-:|:-:|
| 折线 | 平滑 |
|ployline|curve|

  1. inline int read() { //快读
  2. char c = getchar();
  3. int x = 0, f = 1;
  4. while (c < '0' || c > '9') {
  5. if (c == '-') f = -1;
  6. c = getchar();
  7. }
  8. while (c >= '0' && c <= '9') {
  9. x = x * 10 + c - '0';
  10. c = getchar();
  11. }
  12. return x * f;
  13. }

错误报告

error reporting

安装

自行编译

  1. cargo install cxx2flow

下载预构建二进制

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

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

使用 GUI 版本

对于没有命令行使用经验的用户,推荐下载使用基于 tauri 编写的 GUI 版本。 https://github.com/Enter-tainer/cxx2flow-gui/releases

gui

使用

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

  1. Convert your C/C++ code to control flow chart
  2. Usage: cxx2flow [OPTIONS] [INPUT] [FUNCTION]
  3. Arguments:
  4. [INPUT] Sets the path of the input file. e.g. test.cpp
  5. If not specified, cxx2flow will read from stdin.
  6. [FUNCTION] The function you want to convert. e.g. main [default: main]
  7. Options:
  8. -o, --output <OUTPUT> Sets the output file.
  9. If not specified, result will be directed to stdout.
  10. e.g. graph.dot
  11. -c, --curly Sets the style of the flow chart.
  12. If specified, output flow chart will have curly connection line.
  13. --cpp Use C preprocessor.
  14. -t, --tikz Use tikz backend.
  15. -d, --dump-ast Dump AST(For debug purpose only).
  16. -h, --help Print help information
  17. -V, --version Print version information
  18. Note that you need to manually compile the dot file using graphviz to get SVG or PNG files.
  19. EXAMPLES:
  20. cat main.cpp | cxx2flow | dot -Tsvg -o test.svg
  21. cxx2flow test.cpp | dot -Tpng -o test.png
  22. cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svg
  23. Please give me star if this application helps you!
  24. 如果这个应用有帮助到你,请给我点一个 star
  25. https://github.com/Enter-tainer/cxx2flow

限制

  • 对于预处理器的支持基于 cpp ,默认关闭,需要使用 --cpp 参数手动启用。如果 PATH 中不存在 cpp 则会失败。
  • 支持的控制流语句有:while,for,if,break,continue,break,return,switch, goto, do-while。
  • 对 range for 有基本支持。部分情况下,受到 tree-sitter-cpp 能力限制,会出现一些问题