University of Leicester –
Department of Computer Science
CO7206 - Fall 2003 - Lab 7:
Source Code Transformation Using TXL
20 / Nov. / 2003
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.
compile sort.txl and run it on different inputs. A sample
input file is here.
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.
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)).
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..
Amble Resources are found on the TXL page
A brief guide on how to
write a TXL program
An Factorial Program
with fact0 function
expression grammar (+, *, -, /, exp(.,
.)). Here are the rules that implement the TXL
calculator with exp.
Here is an alternative
solution with recursive functions.
A non-ambiguous expression
grammar (+, *, -, /, exp(., .)) that
allows exp(x,exp(y, z)).