Tm version 2.0.9 released

Kees van Reeuwijk <>
8 Nov 2001 01:15:02 -0500

          From comp.compilers

Related articles
Tm version 2.0.9 released (Kees van Reeuwijk) (2001-11-08)
| List of all articles for this month |

From: Kees van Reeuwijk <>
Newsgroups: comp.compilers
Date: 8 Nov 2001 01:15:02 -0500
Organization: Delft University of Technology
Keywords: tools, available
Posted-Date: 08 Nov 2001 01:15:02 EST

Hello everyone,

I hereby announce the availability of version 2.0.9 of my template
preprocessor 'Tm' (for _T_emplate _m_anager).

Tm is a preprocessor that takes a code template and some datastructure
definitions, and generates source code for an arbitrary programming
language. Thus, by using Tm you can have templates in any programming

                      +---------------+ +----------------+
                      | datastructure | | code |
                      | definition | | template |
                      +---------------+ +----------------+
                                    | |
                                    ----------- ----------
                                                        | |
                                                        V V
                                                  | Tm |
                                                  | |
                                                | source |
                                                | code |

Although it has been used a general-purpose preprocessor and template
language, it has special support for the generation of data-structure
manipulation code. We use it extensively to generate C code to
manipulate the abstract syntax trees of our compiler. The generated
code comprise tree manipulation code, but also `tree walkers' to apply
user-provided functions on all instances of specific node types, and
analyzers that apply a reduction over a whole tree of different node

The core package of Tm contains extensive C templates (including the
tree walker and analyzer templates described above) and a support
library. They have been tested and used extensively in the past ten
years. These templates have been used in more than ten medium and large
programming project. There are separate packages on the web site with a
Pascal and a Miranda template, but these have been used less

Tm is flexible enough that useful templates can be written for any
sufficiently powerful programming language. For example, I have written
templates for Lisp and for the functional programming language Clean,
although these are not good enough for public release. Templates for
languages such as Java and Fortran 90, and for other functional
languages, are also eminently possible.

By using templates, especially the standard templates, you can reap the
benefits of any template: the code is re-used more intensively, is
therefore tested more intensively, is more likely to be documented, and
is standardized.

The Tm web site provides the Tm kernel distribution, consisting of:

- All the sources for Tm itself (Tm is written in C)
- A set of C templates that can generate code for general-purpose
    datastructure manipulation.
- C templates for tree walking and analysis.
- The sources for a C support library for the templates above.

Available separately are:
- A PDF manual describing the kernel distribution.
- The LaTeX sources for this manual.
- An example project.
- A small Pascal template (not tested for a long time).
- A small Miranda template (not tested for a long time).

The kernel distribution has been compiled successfully on many UNIX
variants, including Linux. We believe it is highly portable. It has been
compiled with gcc, Borland C++ for Windows, MetroWerks CodeWarrior
compiler for Windows, and Pure C for Atari ST (not all of them recently,

All Tm-related software is licensed under the Gnu Public License (GPL),
or the Library Gnu Public License (LGPL).

For further information, see my Tm web site:

Tm is used extensively in our Timber compiler, a static compiler for a
superset of Java. The Timber compiler has its own website at


To give an indication of how intensive Tm is used in the Timber
compiler: the Spar/Java frontend of the compiler has 47433 lines of code
in Tm input files, Yacc input files, and non-generated C source and
header files. The final C source and header files (from Yacc, Tm, or not
generated) have a total of 136681 lines of code.

Kees van Reeuwijk, Delft University of Technology

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.