FermaT Transformation System

The FermaT Transformation System is an industrial strength program transformation system targeted at reverse engineering, program comprehension and migration between programming languages. The system is currently being used to translate IBM 370 Assembler modules into equivalent readable and maintainable C and COBOL programs.

FermaT is available as free software under the GNU General Public License (GPL).

A program transformation is any operation which changes the text of a program without changing its external behaviour. A simple example is reversing the arms of an IF statement:

IF x = 0 THEN y := 1 ELSE y := 2 FI

is semantically equivalent to:

IF x <> 0 THEN y := 2 ELSE y := 1 FI

A more complex example of a program transformation is Semantic Slicing. Consider the following WSL program:

total:= 0;
i := 0;
evens := 0;
noevens := 0;
odds := 0;
noodds := 0;
n := n0;
WHILE i <= n DO
  evenflag := A[i] MOD 2;
  evenflag := 0;
  IF FALSE
    THEN evens := evens + A[i];
         noevens := noevens + 1
    ELSE odds := odds + A[i];
         noodds := noodds + 1 FI;
  total := total + A[i];
  i := i + 1 OD;
IF noevens <> 0
  THEN meaneven := evens/noevens
  ELSE meaneven := 0 FI;
IF noodds <> 0
  THEN meanodd := odds/noodds
  ELSE meanodd := 0 FI;
mean := total/(n+1);
evendifference := ABS(meaneven - mean);
odddifference := ABS(meanodd-mean)

Suppose we are interested in the final value of the variable evendifference. Save the program as a text file test-1.wsl and run the transformation:

dotrans test-1.wsl test-2.wsl Semantic_Slice data=evendifference

This generates the output file test-2.wsl:

evendifference
  := ABS(REDUCE("+", A[0..n0]) / (n0 + 1))


This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.