Tom Manual

Emilie Balland,
Paul Brauner,
Radu Kopetz,
Pierre-Etienne Moreau,
and Antoine Reilles

July, 2007


This manual contains information for Tom version 2.5.
This manual also exists in pdf.

Tom is a software environment for defining transformations. It is built as a language extension which adds new matching primitives to C, Java, and Caml.

In Java for example, the integration is smooth, allowing the use of the Java Runtime Library without any restriction.

The main construct of Tom is %match, which is similar to the match primitive found in functional languages: given an object (called subject) and a list of patterns-actions, the match primitive selects the first pattern that matches the subject and performs the associated action. The subject against which we match can be any object, but in practice, this object is usually a tree-based data-structure.

The %match construct can be seen as an extension of the classical switch/case construct. The main difference is that the discrimination occurs on a term and not on atomic values like characters or integers: the patterns are used to discriminate and retrieve information from an algebraic data structure. Therefore, Tom is a good language for programming by pattern matching, and it is particularly well-suited for programming various transformations on trees/terms or Xml data-structures.

Information on Tom is available at tom.loria.fr.



Writing a good documentation is a difficult task. To help new users, as well as confirmed Tom developers, we have split the documentation into four complementary documents:

Here you can find the detailed table of contents:

Part I
A guided tour of Tom: code examples

We provide here cut and paste examples, each of them illustrates one particular aspect of the Tom language. Every code snippet comes with the command line to compile and execute it along with the associated program output.

Part II
Tutorial

In the following we consider that the reader is familiar with the Java programming language. Since a potential Tom user may have a background very different from another one, we sometimes address a particular topic which may appear too technical or too theoretical. We use (*) and (**) to indicate such sections that may be omitted in the first reading.

Tom is an extension of Java that can be considered as a preprocessor. Therefore, any Java construct can be used in a Tom program. The tom command line compiler takes a Tom file, whose extension should be .t, and generates a Java file with the extension .java. The Java compiler (javac) has to be used to produce the class file.

Part III
Language

Part IV
Tools


This document was translated from LATEX by HEVEA.