Simplified Chinese | English
A widget used to generate pure character format flowcharts from pseudo-code.
A few days ago, I learned about the red and black tree. The operations of insertion and deletion were too complicated. I thought to draw a small flow chart so that the notes would look more intuitive, but I was too lazy to use the drawing tool, so I typed one character at a time. After typing, I found that it was actually not much easier than using the drawing tool. Later I wanted to build a small tool that could generate a flowchart in pure character format by just entering some simple pseudo-code, so I had this repository.
pseudocode:
be born;
while (alive) {
if (happy) {
smile;
}
else {
try to be happy;
}
}
die;
flow chart:
+-------------+
| be born |
+-------------+
|
V
N /-----------
+--------------| alive |<------------------+
| -----------/ |
| | Y |
| V |
| Y /----------- N |
| +----| happy |----+ |
| | -----------/ | |
| | | |
| V V |
| +-----------+ +---------------------+ |
| | smile | | try to be happy | |
| +-----------+ +---------------------+ |
| | | |
| +--------->O<---------+ |
| | |
| V |
| O-------------------------+
|
|
| +---------+
+-------------->| die |
+---------+
More examples
First clone the repository and build it:
git clone https://github.com/Gusabary/FlowChar.git
cd FlowChar
# for linux
chmod +x ./build.sh
./build.sh
# for windows
. b uild.batThen specify a pseudo-code file. Alternatively, the flowchart output file can be specified, and by default it will be printed to standard output:
cd build
./flowchar -c ../examples/simple -o ../examples/simple-chart Use the -h option to print help information:
./flowchar -hOr directly pull the Docker image, mount and run:
# from dockerhub
docker pull gusabary/flowchar:v1.0
# or from github
docker pull docker.pkg.github.com/gusabary/flowchar/flowchar:v1.0
# run
docker run -v /path/to/dir:/app/files gusabary/flowchar:v1.0 -c files/code -o files/chart You need to mount the directory where the pseudocode file is located as the /app/files directory of the container.
Tokens may be required to pull the image from github docker registry, please refer to this.
Currently, only sequential structures, selection structures controlled by if-else , and loop structures controlled by while are supported.
A string ending with a semicolon is a statement that appears in a box in the flowchart:
a;
do this;
The if keyword is followed by a pair of parentheses, which are the judgment conditions of if , and then a statement block wrapped by a pair of curly braces:
if (condition) {
statementA;
statementB;
}
Optionally, use the else keyword and follow a pair of statement blocks wrapped in curly braces:
if (condition) {
ok;
}
else {
no;
}
The while keyword is followed by a pair of parentheses, which are the judgment conditions of while , and then a statement block wrapped by a pair of curly braces:
while (condition) {
loop;
}
A statement block can be a combination of simple statements, if statements, and while statements.
MIT