1 /*
2  * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3  * Use of this file is governed by the BSD 3-clause license that
4  * can be found in the LICENSE.txt file in the project root.
5  */
6 
7 module antlr.v4.runtime.tree.ParseTreeVisitor;
8 
9 import antlr.v4.runtime.tree.ParseTree;
10 import antlr.v4.runtime.tree.RuleNode;
11 import antlr.v4.runtime.tree.TerminalNode;
12 import antlr.v4.runtime.tree.ErrorNode;
13 import std.variant : Variant;
14 
15 /**
16  * This interface defines the basic notion of a parse tree visitor. Generated
17  * visitors implement this interface and the {@code XVisitor} interface for
18  * grammar {@code X}.
19  *
20  *  @param <T> The return type of the visit operation. Use {@link Void} for
21  *  operations with no return type.
22  */
23 interface ParseTreeVisitor
24 {
25 
26     /**
27      * Visit a parse tree, and return a user-defined result of the operation.
28      *
29      *  @param tree The {@link ParseTree} to visit.
30      *  @return The result of visiting the parse tree.
31      */
32     public Variant visit(ParseTree tree);
33 
34     /**
35      * Visit the children of a node, and return a user-defined result of the
36      * operation.
37      *
38      *  @param node The {@link RuleNode} whose children should be visited.
39      *  @return The result of visiting the children of the node.
40      */
41     public Variant visitChildren(RuleNode node);
42 
43     /**
44      * Visit a terminal node, and return a user-defined result of the operation.
45      *
46      *  @param node The {@link TerminalNode} to visit.
47      *  @return The result of visiting the node.
48      */
49     public Variant visitTerminal(TerminalNode node);
50 
51     /**
52      * Visit an error node, and return a user-defined result of the operation.
53      *
54      *  @param node The {@link ErrorNode} to visit.
55      *  @return The result of visiting the node.
56      */
57     public Variant visitErrorNode(ErrorNode node);
58 
59 }