Unfortunately, this need can only be met at a great expense. The full process of redesigning an antiquated software system, while greatly aided by automated CASE and re-engineering tools, is nevertheless largely a human-assisted one. A large body of code may require substantial effort from a team of programmers and systems analysts before it can be brought to life in its new form. There is no magic bullet that can transmute a creaky old batch-oriented transaction processor into a flashy new interactive client-server transaction processor. Substantial human effort is required, and with this effort comes substantial costs.
There is, however, one critical domain in which fully automated, or nearly fully automated, solutions are possible. This is the domain of software translation . Many systems contain large amounts of code in languages that are no longer considered desirable. In the process of updating such systems, it is often necessary to move to a more modern language in order to realize cost savings and programmer contentment and availability. This process can be carried out in a fully automated fashion, at a substantial savings in both time and money.
Alydaar Software Corporation has developed an automated translation engine which can be used to carry out translations with little or no human supervision. The core translation engine can be rapidly customized to the needs of a particular translation. The engine is highly flexible so that unique and customer specific translation issues can be addressed by augmenting the core features of the engine with new capabilities. This is accomplished by writing new rules, known as "Teach" statements, which, in effect, teach the engine how to deal with the new issues.
As an example, a large body of Pascal code was fully ported to Ada. The client's Pascal was an extended dialect, with many non-standard features, and the code included numerous calls to exception handlers, which the client wanted conveyed to the automatic exception handling provided by Ada. By the methods described below, the standard Pascal to Ada translator engine was customized to handle the Pascal extensions. Further customizations were able to convert nearly all of the client's exception handling code to the new Ada style. These customizations took only a few days. Once complete, the client's code (nearly 150k lines) was translated in a matter of minutes. To translate such a body of code manually would have taken incomparably more time.
Clearly, vast savings in time and money are possible by employing automatic translation techniques. The following outline illustrates the three-step automatic translation process used by Alydaar:
1. Initial Process: The source language is studied by the person performing the conversion. Systems analysis is accomplished at this stage. The analysts works directly with the client in order to fully understand all syntactic and semantic issues.
2. SmartCode One: The source code and other information accumulated in the initial process is sent to SmartCode One where it is broken down into a form that SmartCode Two can understand.
3. SmartCode Two: At this stage, a translation can be built using Teach statements and the information received from SmartCode One.
1. Initial Process:1.1 Identify the different parts of the source language and the anomalies particular to the code.
- PROGRAM BODY
- INCLUDE FILES
- MACROS
- LIBRARIES
- Many companies have extensions to the language which they are using; these deviations must be identified.
- etc.
1.2 Identify the comment types used in the source.
1.3 Identify pre-processor code use in source:
- CICS
- SQL
- etc.
1.4 Provide the result of 1.1, 1.2 and 1.3 to SmartCode One.
2. SmartCode One:
- Puts source code (SC) into an intermediate form (IC) that SmartCode Two can understand.
Example: PL1 code broken down into an intermediate form:
SC: dcl i pointer;
IC: SMT{KYWD (dol), ID(i), KYWD(pointer), OP(,)}
- Provide intermediate source to SmartCode Two.
3. SmartCode Two:
3.1 Identify different parts of the source code:
- declaration
- statements
- expression
- I/O
3.2 Use Teach statements to change the already identified source code portions into equivalent target language parts.
- The target language must convey the original intent of the source. As a case in point, in converting from Pascal to Ada, if a Pascal function returns a value and also passes out one or more pointers as VAR arguments, then the target Ada procedure should pass back the RETURN value as a new argument.
Examples:
Pascal : FUNCTION GetUser(theObject: theObjectID;
VAR theUser:aUserID): Boolean;
Ada : PROCEDURE GetUser(self: id;
theUser: OUT User.id;
success: OUT boolean);
Pascal USAGE: IF GetUser(theObject , theUser)
...
THEN
...
ELSE
Ada USAGE: GetUser(self, myUser, success)
IF success THEN
...
ELSE
...
END IF
- SmartCode Two makes it easy to convey the original intent of the source code into the new target language.
3.3 Compile new code.
3.4 Use Teach Statements to resolve compilation errors, if any.
In the Pascal to Ada example described above, much of the code performs complex calculations on a variety of data structures to carry out an elaborate simulation. This code is well suited for automatic translation because it has few operating system and machine dependencies. Such added complexities can substantially increase the difficulty of a translation and the degree of human intervention, because it is these required complexities that cause the need for\translation to approach the need to re-engineer.
It is not impossible to surmount such complexities. In fact, there is one area of translation in which machine and operating system dependencies become the crux of the matter. This is the translation of assembly language into high level languages. Here a thorough understanding of the source machine's architecture is essential. Alydaar is currently adapting its translation engine to translate IBM 370 assembly code into C. The translator is capable of extracting control and data flow information from the assembly source, and then using this information to synthesize well-structured C-code that carries out the same functions as the original assembly code.