X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/9f94b672a5dc32da5ad01742bd4e976315a30d9c..c6ad2948bb98d42f8e0883ef82cd14cd2d5eda60:/antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/ParseTreeVisitor.h?ds=sidebyside diff --git a/antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/ParseTreeVisitor.h b/antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/ParseTreeVisitor.h new file mode 100644 index 0000000..5a08599 --- /dev/null +++ b/antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/ParseTreeVisitor.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ + +#pragma once + +#include "support/Any.h" + +namespace antlr4 { +namespace tree { + + /// + /// This interface defines the basic notion of a parse tree visitor. Generated + /// visitors implement this interface and the {@code XVisitor} interface for + /// grammar {@code X}. + /// + /// @param The return type of the visit operation. Use for + /// operations with no return type. + // ml: no template parameter here, to avoid the need for virtual template functions. Instead we have our Any class. + class ANTLR4CPP_PUBLIC ParseTreeVisitor { + public: + virtual ~ParseTreeVisitor(); + + /// + /// Visit a parse tree, and return a user-defined result of the operation. + /// + /// The to visit. + /// The result of visiting the parse tree. + virtual antlrcpp::Any visit(ParseTree *tree) = 0; + + /// + /// Visit the children of a node, and return a user-defined result of the + /// operation. + /// + /// The whose children should be visited. + /// The result of visiting the children of the node. + virtual antlrcpp::Any visitChildren(ParseTree *node) = 0; + + /// + /// Visit a terminal node, and return a user-defined result of the operation. + /// + /// The to visit. + /// The result of visiting the node. + virtual antlrcpp::Any visitTerminal(TerminalNode *node) = 0; + + /// + /// Visit an error node, and return a user-defined result of the operation. + /// + /// The to visit. + /// The result of visiting the node. + virtual antlrcpp::Any visitErrorNode(ErrorNode *node) = 0; + + }; + +} // namespace tree +} // namespace antlr4