• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2015, Vol. 37 ›› Issue (05): 937-945.

• 论文 • 上一篇    下一篇

基于图文法的程序流程图与源代码自动转换

朱云,曾晓勤,朱宁,刘禹锋   

  1. (河海大学计算机与信息学院,江苏 南京 211100)
  • 收稿日期:2014-01-13 修回日期:2014-05-26 出版日期:2015-05-25 发布日期:2015-05-25
  • 基金资助:

    国家自然科学基金资助项目(61170089)

Automatic transformation between programs’
flowcharts and codes based on graph grammar 

ZHU Yun,ZENG Xiaoqin,ZHU Ning,LIU Yufeng   

  1. (College of Computer and Information Engineering,Hohai University,Nanjing 211100,China)
  • Received:2014-01-13 Revised:2014-05-26 Online:2015-05-25 Published:2015-05-25

摘要:

程序流程图在整个软件工程的生命周期中发挥着非常重要的作用。在软件设计中,设计人员通常需要先根据算法从结构上画出程序执行流程图,然后再依据流程图写出相应的源程序代码;在分析和维护软件时,如果能先将源程序代码逆向转换成流程图,则可以有效地帮助分析程序结构。显然,若能让计算机自动地实现流程图与源程序代码之间的相互转换,将大量节省软件开发的人力资源和时间耗费。讨论了如何利用基于边的图文法EGG来自动地实现这种转换,并用具体例子展示了应用EGG图文法的归约和推导操作分别实现流程图的语法分析和流程图的逆向生成,前者可以完成从流程图自动生成源程序代码,而后者则可以从源程序代码自动生成流程图。

关键词: 图文法;流程图;源程序;归约;推导

Abstract:

Flowchart is very important in the lifecycle of software engineering. During the design of a program,programmers usually need to draw a structural flowchart before coding.While in the course of the analysis and maintenance of a program,it can be helpful for programmers to analyze the program’s structure by firstly reversing the source codes to a corresponding flowchart.Obviously,automatical transformation between flowcharts and source codes can save plenty of human resources and lots of development time. We discuss how to make use of the Edge-based Graph Grammar (EGG) to automatically perform the transformation,and demonstrate the realization of grammatical analysis and reverse generation of flowcharts by applying the reduction and derivation operations of the EGG through an example.

Key words: graph grammar;flowchart;source code;reduction;derivation