Visitor Combination and Traversal Control

by JoostVisser

This paper describes VisitorCombinators. These are implementations of the Visitor interface that can be used to compose new visitors from given ones. The paper also describes the generic visitor combinator framework Tools.JJTraveler, and the visitor generator Tools.JJForester, which supports instantation of this framework for a given grammar.



The Visitor design pattern allows the encapsulation of poly- morphic behavior outside the class hierarchy on which it operates. A common application of Visitor is the encapsu- lation of tree traversals. Unfortunately, visitors resist com- position and allow little traversal control.

To remove these limitations, we introduce visitor combina- tors. These are implementations of the visitor interface that can be used to compose new visitors from given ones. The set of combinators we propose includes traversal combina- tors that can be used to obtain full traversal control.

A clean separation can be made between the generic parts of the combinator set and the parts that are speci c to a particular class hierarchy. The generic parts form a reusable framework. The specific parts can be generated from a (tree) grammar. Due to this separation, programming with visitor combinators becomes a form of generic programming with signi cant reuse of (visitor) code.

Revision: r1.2 - 26 Apr 2001 - 11:27 - ArieVanDeursen
Transform > VisitorCombinationAndTraversalControl
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback