Previous Up Next

Chapter 8  Runtime Library

8.1  Predefined mappings

8.1.1  Builtin sorts

The system comes with several predefined signature-mappings for C, Java and Caml. Among them, let us mention: These mappings define, for each builtin sort of the host language, an algebraic sort that can be used in a %match or a signature definition construct. Thus, builtin values, such as f(5), g('a') or h("foo"), can be used in patterns.

The string.tom mapping is interesting because it provides an associative operator (concString) which allows the programmer to consider a string as a list of characters. Thus, the string "foo" can be seen as the algebraic object concString('f','o','o'). By using this mapping, it becomes possible to perform pattern matching against the content of a string. The pattern concString('f',X*) will match any string which begins with the character 'f'. By using the unnamed-symbol capability, this pattern can be written: ('f',X*) instead of concString('f',X*).

To match any string which begins with the substring "fo", the corresponding pattern should be ('f','o',X*). To simplify the definitions of such patterns, Tom supports an exception which allows the programmer to write ('fo',X*) instead. Internally, the ill-formed character 'fo' is expanded into the list ('f','o'). Thus, the annotated notation y@'fo' is expanded into (y@'f',y@'o'), and thus may be dangerous to use in this case.

In addition to these mappings, several other predefined mappings come with the system:

8.1.2  Java

To help manipulating Java data-structures, Tom provides several mappings for the Java Runtime Library. The naming convention follows Java's one:
  java
  o--- Character.tom
  +--- util
       o--- ArrayList.tom
       o--- HashMap.tom
       o--- HashSet.tom
       o--- LinkedList.tom
       o--- MapEntry.tom
       o--- TreeMap.tom
       o--- TreeSet.tom
       +--- types
            o--- AbsractCollection.tom
            o--- AbsractList.tom
            o--- AbsractSequentialList.tom
            o--- AbsractSet.tom
            o--- ArrayList.tom
            o--- Collection.tom
            o--- HashMap.tom
            o--- HashSet.tom
            o--- LinkedHashSet.tom
            o--- Map.tom
            o--- Object.tom
            o--- Stack.tom
            o--- TreeMap.tom
            o--- TreeSet.tom
            o--- Vector.tom
            o--- WeakHashMap.tom
The directory types contains only %typeterm declarations.

8.1.3  Strategies

To support strategies, Tom provides a predefined mapping to allow the description of strategies.

8.1.4  Bytecode

To support the analysis and transformation of Java bytecode programs, Tom provides several mappings and libraries:

8.2  XML

To support the transformation of Xml documents, Tom provides a specific syntax for defining patterns, as well as several predefined mappings: See Section 5.4 for a detailed description of the Xml facilities offered by Tom.
Previous Up Next