Coder Social home page Coder Social logo

gusabary / flowchar Goto Github PK

View Code? Open in Web Editor NEW
561.0 19.0 66.0 71 KB

A tiny tool for conversion from pseudo-code to flowchart in character format.

License: MIT License

CMake 0.36% C++ 99.24% Shell 0.12% Dockerfile 0.17% Batchfile 0.11%
linux cpp flowchart windows

flowchar's Introduction

简体中文 | English

FlowChar

一个用来从伪代码生成纯字符格式流程图的小工具。

背景

前几天学习红黑树,插入和删除的操作过于复杂,心想画个小流程图好让笔记看上去更直观些,又懒得用画图工具,于是就一个字符一个字符地敲,敲完发现其实也没比用画图工具轻松多少。后来我就想搞一个小工具,只要输入一些很简单的伪代码就能生成一张纯字符格式的流程图,于是就有了这个仓库。

示例

伪代码:

be born;
while (alive) {
    if (happy) {
        smile;
    }
    else {
        try to be happy;
    }
}
die;

流程图:

              +-------------+                   
              |   be born   |                   
              +-------------+                   
                     |                          
                     V                          
             N /-----------\                    
+--------------|   alive   |<------------------+
|              \-----------/                   |
|                    | Y                       |
|                    V                         |
|            Y /-----------\ N                 |
|         +----|   happy   |----+              |
|         |    \-----------/    |              |
|         |                     |              |
|         V                     V              |
|   +-----------+    +---------------------+   |
|   |   smile   |    |   try to be happy   |   |
|   +-----------+    +---------------------+   |
|         |                     |              |
|         +--------->O<---------+              |
|                    |                         |
|                    V                         |
|                    O-------------------------+
|                                               
|                                               
|               +---------+                     
+-------------->|   die   |                     
                +---------+                     

更多示例

如何使用

首先克隆仓库并进行构建:

git clone https://github.com/Gusabary/FlowChar.git
cd FlowChar

# for linux
chmod +x ./build.sh
./build.sh

# for windows
.\build.bat

然后指定伪代码文件,可选地,可以指定流程图输出文件,缺省的话会打印到标准输出:

cd build
./flowchar -c ../examples/simple -o ../examples/simple-chart

使用 -h 选项以打印帮助信息:

./flowchar -h

Docker

或者直接拉取 Docker 镜像,挂载并运行:

# 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

需要将伪代码文件所在目录挂载为容器的 /app/files 目录。

从 github docker registry 拉取镜像的话可能会需要 token,可以参考这里

伪代码语法

目前仅支持顺序结构,if-else 控制的选择结构以及 while 控制的循环结构。

  • 一串以分号结尾的字符串是一个语句,会出现在流程图的一个方框中:

    a;
    do this;
    
  • if 关键字后要求跟一对圆括号,其中为 if 的判断条件,然后是由一对花括号包裹着的语句块:

    if (condition) {
        statementA;
        statementB;
    }
    

    可选地,使用 else 关键字,并跟上一对花括号包裹着的语句块:

    if (condition) {
        ok;
    }
    else {
        no;
    }
    
  • while 关键字后要求跟一对圆括号,其中为 while 的判断条件,然后是由一对花括号包裹着的语句块:

    while (condition) {
        loop;
    }
    
  • 语句块可以是简单语句、if 语句和 while 语句的组合。

使用许可

MIT

Last-modified date: 2020.5.17, 4 p.m.

flowchar's People

Contributors

gusabary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flowchar's Issues

I can't use,help

萌新真不会搞了,上网也解决不了,求救一下大佬。
image
已经配置了cmake了,但是这个问题完全解决不了,VS是最新版的。

Can not deal with Chinese character correctly

When FlowChar deal with wide character like Chinese, the lacking of blanks is occured in the tail of the flowgraph

+---------+
|   一   |
+---------+
     |
     V
+---------+
|   二   |
+---------+
     |
     V
+---------+
|   三   |
+---------+

Execute my modification

我用这条命令构建、指定了伪代码文件和流程图输出文件。
image
然后尝试修改simple文件
image
做了修改之后我不知道怎么执行修改,让流程图输出到simple-chart文件。
我并没有在build目录下看到可执行文件

多语言?

什么时候支持多语言比如:python?

Support for node?

Have you ever thought about providing a node module?
There are a lot of javascript developers.

i can't use,help

我是萌新,电脑已经配置cmake
但我不知道怎么设置flowchar -c [-o ]
如图
无标题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.