Abstract
This paper describes an algorithm which transforms a flowgraph into a program containing control constructs such as if then else statements, repeat (do forever) statements, multilevel break statements (causing jumps out of enclosing repeats), and multilevel next statements (causing jumps to iterations of enclosing repeats). The algorithm can be extended to create other types of control constructs, such as while or until. The program appears natural because the constructs are used according to common programming practices. The algorithm does not copy code, create subroutines, or add new variables. Instead, goto statements are generated when no other available control construct describes the flow of control. The algorithm has been implemented in a program called STRUCT which rewrites Fortran programs using constructs such as while, repeat, and if then else statements. The resulting programs are substantially more readable than their Fortran counterparts.
- 1 AHO, A V, AND ULLMAN, J D The Theory of Parsing, Translation, and Compdmg, VoL IL Complhng Prentice-Hall, Englewood Chffs, N J, 1973 Google Scholar
- 2 ASMCROFT, E, AND MANNA, Z Translating program schemas to while-schemas SlAM J. Comptg 4, 2 (1975), 125-146Google Scholar
- 3 BAKER, B.S Struct, a program which structures Fortran Internal memo, Bell Labs, Murray Hdl, N J., 1975.Google Scholar
- 4 BAKER, B S. Automatic structurmg of programs In preparationGoogle Scholar
- 5 DE BALBINE, G Better Man Power UUhzation Using Automatic Restructuring Came, Farber & Gordon, Inc., 1974Google Scholar
- 6 DE BALBINE, G Using the Fortran structuring engme In Proc of Comp Sci and Stat 8th Ann Syrup on the Interface, Los Angeles, 1975, pp 297-305Google Scholar
- 7 BOHM, C, AND JACOPINI, G Flow dmgrams, Turmg machines and languages with only two formation rules Comm ACM 9, 5 (May 1966), 366-371 Google Scholar
- 8 BRONO, J, AND STEIGLITZ, K The expression of algorithms by charts d ACM 19, 3 (July 1972), 366-371 Google Scholar
- 9 COOPER, D C Bohm and Jacopml's reduction of flow charts Carom ,4CM 10, Aug 1967), 463 (Letter) Google Scholar
- 10 DAHL, O-J, DUKSTRA, E W, AND HOARE, C A R Structured Programmmg Academic Press, New York, 1972. Google Scholar
- 11 DIJKSTRA, E W Go to statement considered harmful Comm ACM 11, 3 (March 1968), 147-148 Google Scholar
- 12 HECHT, M S, AND ULLMAN, J.D Characterlzauons of reducible flowgraphs J ACM 21, 3 (july 1974), 367-375 Google Scholar
- 13 KERNIGHAN, B W Ratfor -- a preprocessor for a rational Fortran Software Pracnce and Experience 5, 4 (1975), 395-406Google Scholar
- 14 KEgNIGHAN, BW, AND CHERRY, L L A system for typesetting mathematics Comm ACM 18, 3 (March 1975), 151-156 Google Scholar
- 15 KNUTH, D E, AND FLOYD, R W Notes on avoiding "go to" statements Infor Proc Letters 1 (1971), 23-31Google Scholar
- 16 KNUTH, D E Structured programming with go to statements ACM Comptg Surveys 6, 4 (1974), 261-302 Google Scholar
- 17 KOSARAJU, S.R. Analysis of structured programs. J. Comptr. Sys. Scl. 9, 3 (1974), 232-254Google Scholar
- 18 LESK, M E, KERNIGHAN, B W, AND RITCmE, D M The C programming manual Comptg Sct Tech. Rep #31, Bell Labs, Murray Hill, N JGoogle Scholar
- 19 PETERSON, W W, KASAMI, T, AND TOKURA, N. On the capabilities of whde, repeat and exit statements Comra ACM 16, 8 (Aug 1973), 503-512 Google Scholar
- 20 Ra'rcmE, D M, AND THOMPSON, K The UNIX time-sharing system Comrn ACM 17, 7 (July 1974), 365-375 Google Scholar
Index Terms
- An Algorithm for Structuring Flowgraphs
Recommendations
An algorithm for structuring programs (Extended Abstract)
POPL '76: Proceedings of the 3rd ACM SIGACT-SIGPLAN symposium on Principles on programming languagesStructured programming emphasizes programming language constructs such as while loops, until loops, and if then else statements. Properly used, these constructs make occurrences of loops and branching of control obvious. They are preferable to goto ...
Inner loops in flowgraphs and code optimization
A criterion is developed to define a hierarchy of inner loops in a program which constitute sections of the program which take up large proportions of the execution time; this hierarchy lends a dynamic loop structure to the program. It is assumed that ...
Analysis of Real-Time Systems by Data Flowgraphs
The concept of a data flowgraph is formalized as a bipartite directed graph. Each execution sequence of a computer program has a corresponding data flowgraph which describes functionally what happens to the data if that execution sequence is followed.
Comments