Pattern Matching in Trees

Christoph Martin Hoffmann, Michael James O'Donnell. Pattern Matching in Trees. Journal of the ACM, 29(1):68-95, jan 1982. [doi]

Abstract

Tree pattern matching is an interesting special problem which occurs as a crucial step in a number of programming tasks, for instance, design of interpreters for nonprocedural programming languages, automatic implementations of abstract data types, code optimization m compilers, symbolic computation, context searching in structure editors, and automatic theorem proving. As with the sorting problem, the variations in requirements and resources for each application seem to preclude a uniform, universal solution to the tree-pattern-matching problem. Instead, a collection of well-analyzed techniques, from which specific applications may be selected and adapted, should be sought. Five new techniques for tree pattern matching are presented, analyzed for time and space complexity, and compared with previously known methods. Particularly important are applications where the same patterns are matched against many subjects and where a subject may be modified incrementally. Therefore, methods which spend some tune preprocessing patterns in order to improve the actual matching time are included.