aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp
diff options
context:
space:
mode:
authorantonovvk <antonovvk@yandex-team.ru>2022-02-10 16:47:51 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:51 +0300
commit37a63debdc21e372d99e1808cdd31aecf75018c3 (patch)
treefd84293fb9a1b16381dd6c1a5e14c78afacb8710 /contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp
parent1fe621e70df847cc201ac942fe6d7804ea10508d (diff)
downloadydb-37a63debdc21e372d99e1808cdd31aecf75018c3.tar.gz
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp')
-rw-r--r--contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp
index c32968ac92..523abee82d 100644
--- a/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp
+++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.hpp
@@ -1,42 +1,42 @@
-/** \file
- * Definition of the ANTLR3 common tree adaptor.
- */
-
+/** \file
+ * Definition of the ANTLR3 common tree adaptor.
+ */
+
#ifndef _ANTLR3_COMMON_TREE_ADAPTOR_HPP
#define _ANTLR3_COMMON_TREE_ADAPTOR_HPP
-
-// [The "BSD licence"]
-// Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
-
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// 3. The name of the author may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
+// [The "BSD licence"]
+// Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
+
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. The name of the author may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
namespace antlr3 {
-
+
template <typename ImplTraits> class CommonTreeStore;
-
+
/** Helper class for unique_ptr. Implements deleter for instances of unique_ptr
While building AST tree dangling pointers are automatically put back into pool
*/
@@ -101,48 +101,48 @@ protected:
ResourcePoolManagerType m_manager;
};
-template<class ImplTraits>
+template<class ImplTraits>
class CommonTreeAdaptor
: public ImplTraits::AllocPolicyType
, public CommonTreeStore<ImplTraits>
-{
-public:
+{
+public:
typedef typename ImplTraits::StringType StringType;
typedef typename ImplTraits::TreeType TreeType;
typedef typename ImplTraits::TreeTypePtr TreeTypePtr;
typedef typename TreeType::ChildrenType ChildrenType;
-
+
typedef TreeType TokenType;
typedef typename ImplTraits::CommonTokenType CommonTokenType;
typedef typename ImplTraits::DebugEventListenerType DebuggerType;
typedef typename ImplTraits::TokenStreamType TokenStreamType;
typedef CommonTreeStore<ImplTraits> TreeStoreType;
-public:
+public:
//The parameter is there only to provide uniform constructor interface
CommonTreeAdaptor(DebuggerType* dbg = nullptr);
-
+
TreeTypePtr nilNode();
TreeTypePtr dupTree( const TreeTypePtr& tree);
TreeTypePtr dupTree( const TreeType* tree);
-
+
TreeTypePtr dupNode(const TreeTypePtr& treeNode);
TreeTypePtr dupNode(const TreeType* treeNode);
-
+
void addChild( TreeTypePtr& t, TreeTypePtr& child);
void addChild( TreeTypePtr& t, TreeTypePtr&& child);
void addChildToken( TreeTypePtr& t, CommonTokenType* child);
void setParent( TreeTypePtr& child, TreeType* parent);
TreeType* getParent( TreeTypePtr& child);
-
+
TreeTypePtr errorNode( CommonTokenType* tnstream, const CommonTokenType* startToken, const CommonTokenType* stopToken);
bool isNilNode( TreeTypePtr& t);
-
+
TreeTypePtr becomeRoot( TreeTypePtr& newRoot, TreeTypePtr& oldRoot);
TreeTypePtr becomeRoot( TreeTypePtr&& newRoot, TreeTypePtr& oldRoot);
TreeTypePtr becomeRootToken(CommonTokenType* newRoot, TreeTypePtr& oldRoot);
TreeTypePtr rulePostProcessing( TreeTypePtr& root);
-
+
TreeTypePtr create( CommonTokenType const* payload);
TreeTypePtr create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken);
TreeTypePtr create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken, const char* text);
@@ -153,7 +153,7 @@ public:
CommonTokenType* createToken( ANTLR_UINT32 tokenType, const char* text);
CommonTokenType* createToken( ANTLR_UINT32 tokenType, StringType const& text);
CommonTokenType* createToken( const CommonTokenType* fromToken);
-
+
ANTLR_UINT32 getType( TreeTypePtr& t);
StringType getText( TreeTypePtr& t);
@@ -165,17 +165,17 @@ public:
ANTLR_UINT32 getChildCount( TreeTypePtr&);
ANTLR_UINT64 getUniqueID( TreeTypePtr&);
-
+
CommonTokenType* getToken( TreeTypePtr& t);
-
+
void setTokenBoundaries( TreeTypePtr& t, const CommonTokenType* startToken, const CommonTokenType* stopToken);
ANTLR_MARKER getTokenStartIndex( TreeTypePtr& t);
ANTLR_MARKER getTokenStopIndex( TreeTypePtr& t);
-
+
/// Produce a DOT (see graphviz freeware suite) from a base tree
///
StringType makeDot( TreeTypePtr& theTree);
-
+
/// Replace from start to stop child index of parent with t, which might
/// be a list. Number of children may be different
/// after this call.
@@ -185,23 +185,23 @@ public:
///
void replaceChildren( TreeTypePtr parent, ANTLR_INT32 startChildIndex,
ANTLR_INT32 stopChildIndex, TreeTypePtr t);
-
+
~CommonTreeAdaptor();
-
+
protected:
TreeTypePtr dupTreeImpl( const TreeType* root, TreeType* parent);
-
+
void defineDotNodes(TreeTypePtr t, const StringType& dotSpec);
void defineDotEdges(TreeTypePtr t, const StringType& dotSpec);
-};
-
+};
+
//If someone can override the CommonTreeAdaptor at the compile time, that will be
-//inherited here. Still you can choose to override the DebugTreeAdaptor, if you wish to
-//change the DebugTreeAdaptor
-template<class ImplTraits>
-class DebugTreeAdaptor : public ImplTraits::CommonTreeAdaptorType
-{
-public:
+//inherited here. Still you can choose to override the DebugTreeAdaptor, if you wish to
+//change the DebugTreeAdaptor
+template<class ImplTraits>
+class DebugTreeAdaptor : public ImplTraits::CommonTreeAdaptorType
+{
+public:
//DebugEventListener implements functionality through virtual functions
//the template parameter is required for pointing back at the adaptor
typedef typename ImplTraits::DebugEventListener DebuggerType;
@@ -209,8 +209,8 @@ public:
typedef typename ImplTraits::TreeTypePtr TreeTypePtr;
typedef typename ImplTraits::CommonTokenType CommonTokenType;
typedef typename ImplTraits::CommonTreeAdaptorType super;
-
-private:
+
+private:
/// If set to something other than NULL, then this structure is
/// points to an instance of the debugger interface. In general, the
/// debugger is only referenced internally in recovery/error operations
@@ -218,8 +218,8 @@ private:
/// in every function/method
///
DebuggerType* m_debugger;
-
-public:
+
+public:
DebugTreeAdaptor( DebuggerType* debugger );
void setDebugEventListener( DebuggerType* debugger);
TreeTypePtr nilNode();
@@ -227,7 +227,7 @@ public:
void addChildToken(TreeTypePtr& t, CommonTokenType* child);
TreeTypePtr becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr& oldRootTree );
TreeTypePtr becomeRootToken( CommonTokenType* newRoot, TreeTypePtr& oldRoot);
-
+
TreeTypePtr createTypeToken(ANTLR_UINT32 tokenType, CommonTokenType* fromToken);
TreeTypePtr createTypeTokenText(ANTLR_UINT32 tokenType, CommonTokenType* fromToken, ANTLR_UINT8* text);
TreeTypePtr createTypeText( ANTLR_UINT32 tokenType, ANTLR_UINT8* text);
@@ -239,10 +239,10 @@ public:
/// to the debugger.
///
void simulateTreeConstruction(TreeTypePtr& tree);
-};
-
+};
+
}
-
-#include "antlr3commontreeadaptor.inl"
-
-#endif
+
+#include "antlr3commontreeadaptor.inl"
+
+#endif