Puma [Grosch91] is the program transformation generator of the Coctail compiler toolkit. A Puma specification specifies a transformation of an abstract syntax tree that has been produced and attributed by some other tool. The generator translates such a specification to a C or Modula-2 program that implements the transformation tool.
A specification defines a series of procedures (or functions or predicates) that operate on one or more tree arguments. A procedure is defined by one or more rules. A rule matches the arguments against patterns, tests further properties of the arguments, computes some side effects and computes the values of output arguments and the result. Each of these computations can cause the failure of the rule upon which the next rule is tried or the procedure fails if no more rules are available.
Tree traversal is achieved by means of procedural recursion. All traversals have to be defined explicitly. This means that there is no higher-level support for finding application instances of transformation rules nor are procedures higher-order, hence no generic traversals can be described.
Puma is a typical example of a domain-specific language that provides domain abstractions on top of an existing paradigm. The language provides syntactic support for talking about trees, e.g., pattern matching and attribute reference, and for dealing with computations that can fail. These are features not usually provided in imperative languages and that can be quite awkard to program. The result is a kind of functional language for abstract syntax trees with some imperative features.
References
See Also
Other TransformationSystems