Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Enter-tainer/cxx2flow
将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
https://github.com/Enter-tainer/cxx2flow
cpp diagrams flowchart rust tree-sitter
Last synced: 3 months ago
JSON representation
将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
- Host: GitHub
- URL: https://github.com/Enter-tainer/cxx2flow
- Owner: Enter-tainer
- License: mit
- Created: 2021-08-17T13:02:50.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T15:26:04.000Z (4 months ago)
- Last Synced: 2024-07-07T04:48:31.817Z (4 months ago)
- Topics: cpp, diagrams, flowchart, rust, tree-sitter
- Language: Rust
- Homepage:
- Size: 498 KB
- Stars: 695
- Watchers: 9
- Forks: 58
- Open Issues: 8
-
Metadata Files:
- Readme: README-en.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hust - cxx2flow
README
# cxx2flow
[简体中文](README.md) | [English](README-en.md)
Turn your C/C++ code into flowchart
## Demo
For more demo please refer to [GALLERY](gallery.md)
Two different styles:
| | |
|:-:|:-:|
| polyline | smooth |
|![ployline](assets/polyline.svg)|![curve](assets/curve.svg)|```cpp
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
![error reporting](assets/error_reporting.png)
## Installation
### Compile from source
```bash
cargo install cxx2flow
```### Prebuilt binary
It is recommended to download prebuilt binary from [Github Release](https://github.com/Enter-tainer/cxx2flow/releases).
### GUI version
For those who are not familiar with command line, I recommend the GUI version of cxx2flow. https://github.com/Enter-tainer/cxx2flow-gui/releases
![gui](https://github.com/Enter-tainer/cxx2flow-gui/raw/master/assets/2022-05-01-16-37-32.png)
## Usage
To compile the generated dot file, you need graphviz. You can also copy the output to online graphviz services such as http://magjac.com/graphviz-visual-editor/ .
```
Convert your C/C++ code to control flow chartUsage: cxx2flow [OPTIONS] [INPUT] [FUNCTION]
Arguments:
[INPUT] Sets the path of the input file. e.g. test.cpp
If not specified, cxx2flow will read from stdin.
[FUNCTION] The function you want to convert. e.g. main [default: main]Options:
-o, --output Sets the output file.
If not specified, result will be directed to stdout.
e.g. graph.dot
-c, --curly Sets the style of the flow chart.
If specified, output flow chart will have curly connection line.
--cpp Use C preprocessor.
-t, --tikz Use tikz backend.
-d, --dump-ast Dump AST(For debug purpose only).
-h, --help Print help information
-V, --version Print version informationNote that you need to manually compile the dot file using graphviz to get SVG or PNG files.
EXAMPLES:
cat main.cpp | cxx2flow | dot -Tsvg -o test.svg
cxx2flow test.cpp | dot -Tpng -o test.png
cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svgPlease give me star if this application helps you!
如果这个应用有帮助到你,请给我点一个 star!
https://github.com/Enter-tainer/cxx2flow
```## Limitations
- The support of preprocessor is based on `cpp`, and is disabled by default. `--cpp` flag is needed to enable it. It will fail if `cpp` does not exist in `PATH`.
- Supported control flow keyword: while,for,if,break,continue,break,return,switch, goto, do-while。
- Very basic support for range based loop in C++ 11.