1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
8 #include "support/Any.h"
14 /// This interface defines the basic notion of a parse tree visitor. Generated
15 /// visitors implement this interface and the {@code XVisitor} interface for
16 /// grammar {@code X}.
18 /// @param <T> The return type of the visit operation. Use <seealso cref="Void"/> for
19 /// operations with no return type. </param>
20 // ml: no template parameter here, to avoid the need for virtual template functions. Instead we have our Any class.
21 class ANTLR4CPP_PUBLIC ParseTreeVisitor {
23 virtual ~ParseTreeVisitor();
26 /// Visit a parse tree, and return a user-defined result of the operation.
28 /// <param name="tree"> The <seealso cref="ParseTree"/> to visit. </param>
29 /// <returns> The result of visiting the parse tree. </returns>
30 virtual antlrcpp::Any visit(ParseTree *tree) = 0;
33 /// Visit the children of a node, and return a user-defined result of the
36 /// <param name="node"> The <seealso cref="ParseTree"/> whose children should be visited. </param>
37 /// <returns> The result of visiting the children of the node. </returns>
38 virtual antlrcpp::Any visitChildren(ParseTree *node) = 0;
41 /// Visit a terminal node, and return a user-defined result of the operation.
43 /// <param name="node"> The <seealso cref="TerminalNode"/> to visit. </param>
44 /// <returns> The result of visiting the node. </returns>
45 virtual antlrcpp::Any visitTerminal(TerminalNode *node) = 0;
48 /// Visit an error node, and return a user-defined result of the operation.
50 /// <param name="node"> The <seealso cref="ErrorNode"/> to visit. </param>
51 /// <returns> The result of visiting the node. </returns>
52 virtual antlrcpp::Any visitErrorNode(ErrorNode *node) = 0;