Preservation of code quality in source-to-source translation : Bliss -> C

Roy Styan · Summit (Simon Fraser University) · 1985

A major problem created by diversity in computing tools is the portability of software.Programs written on one machine cannot be used on others unless a compiler for the original source is present.Many solutions to the problem have been proposed, but none have been universally accepted.One solution, which allows programs to be maintained in their new environment, is source-to-source translation.In this thesis the concept of quality translation, in the first phase of a Bliss-to-C translator, is explored.A quality translation is one which produces comprehensible, as well as semantically correct code.For a Bliss-to-C system, preservation of quality must first come through the translation of data structures.Bliss is an untyped language with access algorithms for defining structures, while C is a typed language using data aggregates.Heuristics have been developed for both deriving type form context, and building data aggregates from the definition and usage of access algorithms.A scheme is presented for transforming the original source to a more abstract form, resulting in aefew abstract functions which can be translated by hand, and an improved source which is easier to translate by machine.* correctness, * reliability, * robustness, * readability and documentation for users and maintenance, * small, easily understood modules, * the ability to communicate with man,the operating system and other software, * efficiency with respect to time and storage, and * portability.In terms of translation some of the points are irrelevant, as either the original code fits the criteria or it doesn't.On the other hand, the translation will affect the program's readability, efficiency, portability, and its communication ability.These factors should also be considered goals when designing a source-to-source translator.Freak Freak 811 has done just this in his Fortran --> Pascal translator.As well as preserving semantic content he forces structure onto a Fortran program.His idea of a structured program is simply a "one entry, one exit" philosophy.Each block of code must have a single entry point and a single exit point.Although this philosophy can be followed in Fortran programming, the dependence on goto's to alter sequence of control flow makes it hard.Using a "Boolean flag technique", Freak eliminates goto's from the Fortran program, replacing them with Pascal while loops.Translation has now gone beyond simple semantic analysis.His programs must deal with the problem of code rearrangement, perhaps introducing auxiliary variables or even auxiliary statements to achieve correct translation.However, his goal is not only correctness, but provability.The end result is a program of higher quality than the original source.* the variable has a single, correct type, * the variable has multiple types, but proper merging would yield a single, ' correct type, * the variable has multiple types, some are correct while others are not, * the translator was unable to find the variable type, and * the variable is incorrectly typed.

Read the paper · More papers on PaperTik