### University of Leicester –
Department of Computer Science

### CO7206 - Fall 2003 - Lab 7:
Source Code Transformation Using TXL

### 20 / Nov. / 2003

### Objective: (1)
Learning TXL Basics

### TXL is a
structure transformation language that can be applied in a variety of contexts.
In this lab, students will try out TXL tool suite and will try and extend some
TXL programs. This will get them acquainted with TXL and ready to write further
source code transformations.

### Task:

### 2-
Download and
compile sort.txl and run it on different inputs. A sample
input file is here.

### 3-
Download and
compile factorial.txl and run it on different inputs, e.g.,
this one. Extend it to accommodate for factorial 0
(0!) by writing a function that takes care of this case.

### 5-
Extend the
non-ambiguous expression grammar to express exp(x,y), where exp(2,5) = 32. Then
try it on this input. Also try it on this second input. If it worked on the first input but not on
the second, you may need to change your grammar a bit to accommodate for
expressions like exp(x,exp(y, z)).

### 6-
Check your
answers against the sample programs below or have a look at these programs if
you are stuck.

### * *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..*

### 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
**An Factorial Program
with fact0 function*** *

q
**A non-ambiguous
expression grammar (+, *, -, /, exp(.,
.)). **Here are the rules that implement the **TXL
calculator with exp.
**Here is an **alternative
solution **with recursive functions.

q
**A non-ambiguous expression
grammar (+, *, -, /, exp(., .)) t**hat
allows exp(**x**,exp(**y**, **z**))**.**

q
**More examples**