Visitor<TContext, TNode, TResult> Class ​
Definition ​
A visitor for a syntax tree. A visitor is called for a node and returns a value for it. Unlike a Listener<TContext, TNode>, which walks the whole tree itself, a visitor controls the walk: it visits whichever children it needs, in whatever order it needs, and combines their results into its own. That makes visitors the natural fit for evaluating or transforming a tree into a value, especially when not every child should be visited, for example, short-circuit evaluation.
c#
public abstract class Visitor<TContext, TNode, TResult>
where TNode : Node<TNode>Type Parameters ​
| Name | Description |
|---|---|
TContext | The type of the context object. |
TNode | The type of the nodes to visit. |
TResult | The type of the result of visiting a node. |
Constructors ​
| Name | Description |
|---|---|
Visitor() |
Methods ​
| Name | Description |
|---|---|
Visit(TContext, TNode) | Visits the specified node and returns the result. |
VisitChildren(TContext, TNode) | Visits all the children of the specified node in order and returns their results. |
VisitNode(TContext, TNode) | Called to visit a node. |