]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/ParseTreeVisitor.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / tree / ParseTreeVisitor.h
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.
4  */
5
6 #pragma once
7
8 #include "support/Any.h"
9
10 namespace antlr4 {
11 namespace tree {
12
13   /// <summary>
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}.
17   /// </summary>
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 {
22   public:
23     virtual ~ParseTreeVisitor();
24
25     /// <summary>
26     /// Visit a parse tree, and return a user-defined result of the operation.
27     /// </summary>
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;
31
32     /// <summary>
33     /// Visit the children of a node, and return a user-defined result of the
34     /// operation.
35     /// </summary>
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;
39
40     /// <summary>
41     /// Visit a terminal node, and return a user-defined result of the operation.
42     /// </summary>
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;
46
47     /// <summary>
48     /// Visit an error node, and return a user-defined result of the operation.
49     /// </summary>
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;
53
54   };
55
56 } // namespace tree
57 } // namespace antlr4