About Tom technology

What is Tom ?

Tom is a pattern matching compiler developed at INRIA. It is particularly well-suited for programming various transformations on trees/terms and XML based documents. Its design follows our research on rule based languages, and our experiences on the efficient compilation of ELAN developed by the Protheo group.

Is there any implementation?

Tom is a tool implemented in Tom itself. When observing its illuminated face, Tom can be seen as a Yacc-like compiler translating patterns into executable pattern matching automata. Similarly to Yacc, when a match is found, the corresponding semantic action (a sequence of instructions written in Java, C or Caml) is triggered and executed.

When observing its dark side, Tom is a complex compiler which adds non-trivial constructs to Java, C and Caml(ML family), and offers the possibility to analyse any kind of data-structure. Tom is a real programming language, with many programming and debugging facilities.

What is it good for ?

Tom is good for:

  • programming by pattern matching
  • transforming XML documents
  • implementing rule based systems
  • describing algebraic transformations
  • improving the quality of your software

Tom is language extension which adds a new matching primitives to C and Java: %match. This construct is similar to the match primitive found in functional languages: given a term (called subject) and a list of pairs: pattern-action, the match primitive selects a pattern that matches the subject and performs the associated action. This construct may thus 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.

In its first version, the syntax for describing patterns was restricted to prefix term notation. Recently, this syntax has been extended to XML syntax. By combining this natural syntax with powerful associative-matching capabilities, Tom appears to be a serious alternative to manipulate XML documents in Java. The interest of this approach is to combine a well established programming environment (Java) with an expressive, and theoretically based pattern matching language.

In addition to %match, Tom provides a %rule construct which allows to describe rewrite rule systems. This construct supports conditional rewrite rules as well as rules with matching conditions (as in ELAN or ASF+SDF). By default, Tom provides a left-most innermost normalization strategy which allows to compute normal forms in an efficient way. It is of course possible to combine these features with more complex strategies, like generic traversal strategies, to describe more complex or generic transformations. When understanding all the possibilities offered by Tom, this general purpose system becomes as powerful and expressive as many specific rewrite rule based programming languages.

Licensing conditions for Tom

Tom has received the Inter Deposit Digital Number IDDN.FR.001.130053.000.S.P.2005.000.10400

Tom is released under the GPL General Public License, and the BSD license.

The core of the Tom compiler is released under the GPL v.2.

In order to allow any user of Tom to distribute the files generated by Tom under the license he prefers, the Tom runtime library and the predefined mappings are released under a BSD License. This means that you can use the predefined mappings provided by Tom and still set the generated code (containing parts of the mapping) under the license you want.

What does Tom stand for ?

In its first version, Tom was just supposed to add pattern matching facilities to a programming language. The considered pattern matching feature was supposed to discriminate over a single subject. This is why Tom is called Tom: ToOne Matching.

In the current version, Tom is still sticked to this paradigm: the number of patterns is not restricted, but only one subject is considered when solving a matching problem.