Visitors

Edit pageLast modified: 02 February 2025

To completely traverse a graph of all types, you can use the TypeLang\Parser\Traverser class. The traverser instance can accept several the TypeLang\Parser\Traverser\VisitorInterface implementation as a constructor argument.

Let's try to write a simple visitor that will display the names of all classes when entering each AST node.

You can see the following text as the output result: