University of Leicester Department of Computer Science

CO7206 - Fall 2003 - Lab 8: Program Restructuring Using TXL

27 / Nov. / 2003

Objective: Using the Structure Transformation Language TXL for a Code Restructuring Task

In lab 7 we had our first hands on experience using TXL. In lab 8 we will use it for a real restructuring task.

Task:

1-     Download (press right mouse button and choose save target as) and compile (using command txlc) the Commands language grammar (assignments, declarations, 'if', 'case', 'while', 'goto' statements and labels).

2-     Download and compile the goto elimination TXL program.

3-     Download exmaple1 and example2 and run the program on them.

4-     Write your own input files and run the program on them. Try an input that has nested loops (e.g, example3) inside another and see if goto elimination TXL program will be able to handle it or no.

5-     Extend the goto elimination TXL program to transform structures like the following to while loops (besides the structure that it already handles). You may need to add extra rules to do so. Here is the second goto structure that you will eliminate:

 x:=10;
 y:=0;
b: x:=x-1;
 y:=y+1;
if x>0 then goto b;
endif
x:=99;

* Note: It is required to learn as much TXL as you can to the point that you are able to solve TXL lab. problems, assignment, etc. comfortably. You will need to spend enough time beyond the lab session, studying TXL on your own.

Resources:

q       Amble Resources are found on the TXL page

q       TXL Documentation

q       A brief guide on how to write a TXL program

q       More examples