aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp
diff options
context:
space:
mode:
authorantonovvk <antonovvk@yandex-team.ru>2022-02-10 16:47:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:52 +0300
commit37de222addabbef336dcaaea5f7c7645a629fc6d (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp
parent37a63debdc21e372d99e1808cdd31aecf75018c3 (diff)
downloadydb-37de222addabbef336dcaaea5f7c7645a629fc6d.tar.gz
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp')
-rw-r--r--contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp192
1 files changed, 96 insertions, 96 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp
index 420139c2db..c5741ce985 100644
--- a/contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp
+++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3traits.hpp
@@ -1,48 +1,48 @@
-#ifndef _ANTLR3_TRAITS_HPP
-#define _ANTLR3_TRAITS_HPP
-
+#ifndef _ANTLR3_TRAITS_HPP
+#define _ANTLR3_TRAITS_HPP
+
namespace antlr3 {
-
+
/**
* Users implementing overrides should inherit from this
*
* All classes typenames reffer to Empty class
*/
-template<class ImplTraits>
-class CustomTraitsBase
-{
-public:
+template<class ImplTraits>
+class CustomTraitsBase
+{
+public:
typedef Empty AllocPolicyType;
typedef Empty StringType;
typedef Empty StringStreamType;
typedef Empty StreamDataType;
typedef Empty Endianness;
-
+
//collections
typedef Empty BitsetType;
typedef Empty BitsetListType;
-
+
typedef Empty InputStreamType;
-
+
template<class StreamType>
class IntStreamType : public Empty
{
public:
typedef Empty BaseType;
};
-
+
typedef Empty LexStateType;
-
+
typedef Empty CommonTokenType;
typedef Empty TokenUserDataType;
-
+
typedef Empty TokenIntStreamType;
typedef Empty TokenStreamType;
-
+
typedef Empty TreeNodeIntStreamType;
typedef Empty TreeNodeStreamType;
-
-
+
+
typedef Empty DebugEventListenerType;
template<class StreamType>
class RecognizerSharedStateType : public Empty
@@ -50,7 +50,7 @@ public:
public:
typedef Empty BaseType;
};
-
+
template<class StreamType>
class RecognizerType : public Empty
{
@@ -69,7 +69,7 @@ public:
public:
typedef Empty BaseType;
};
-
+
//this should be overridden with generated lexer
typedef Empty BaseLexerType;
@@ -83,76 +83,76 @@ public:
public:
typedef Empty BaseType;
};
-
+
typedef Empty RuleReturnValueType;
-
+
//If we want to change the way tokens are stored
static const bool TOKENS_ACCESSED_FROM_OWNING_RULE = false;
static const unsigned TOKEN_FILL_BUFFER_INCREMENT = 100; //used only if the above val is true
-
+
static void displayRecognitionError( const std::string& str ) { printf("%s", str.c_str() ); }
-};
-
+};
+
/**
* Traits manipulation classes
*/
-template<class A, class B>
-class TraitsSelector
-{
-public:
+template<class A, class B>
+class TraitsSelector
+{
+public:
typedef A selected;
-};
-
-template<class B>
-class TraitsSelector<Empty, B>
-{
-public:
+};
+
+template<class B>
+class TraitsSelector<Empty, B>
+{
+public:
typedef B selected;
-};
-
-template<class A, class B, class C>
-class TraitsOneArgSelector
-{
-public:
+};
+
+template<class A, class B, class C>
+class TraitsOneArgSelector
+{
+public:
typedef A selected;
-};
-
-template<class A, class B>
-class TraitsOneArgSelector<A,B,Empty>
-{
-public:
+};
+
+template<class A, class B>
+class TraitsOneArgSelector<A,B,Empty>
+{
+public:
typedef B selected;
-};
-
-template<bool v, class A, class B>
-class BoolSelector
-{
-public:
+};
+
+template<bool v, class A, class B>
+class BoolSelector
+{
+public:
typedef A selected;
-};
-
-template<class A, class B>
-class BoolSelector<false, A, B>
-{
-public:
+};
+
+template<class A, class B>
+class BoolSelector<false, A, B>
+{
+public:
typedef B selected;
-};
-
+};
+
/**
* Base traits template
*
* This class contains default typenames for every trait
*/
-template< template<class ImplTraits> class UserTraits >
-class TraitsBase
-{
-public:
+template< template<class ImplTraits> class UserTraits >
+class TraitsBase
+{
+public:
typedef TraitsBase TraitsType;
typedef typename TraitsSelector< typename UserTraits<TraitsType>::AllocPolicyType,
DefaultAllocPolicy
>::selected AllocPolicyType;
-
+
typedef typename TraitsSelector< typename UserTraits<TraitsType>::StringType,
std::string
>::selected StringType;
@@ -160,7 +160,7 @@ public:
typedef typename TraitsSelector< typename UserTraits<TraitsType>::StringStreamType,
std::stringstream
>::selected StringStreamType;
-
+
typedef typename TraitsSelector< typename UserTraits<TraitsType>::StreamDataType,
ANTLR_UINT8
>::selected StreamDataType;
@@ -168,18 +168,18 @@ public:
typedef typename TraitsSelector< typename UserTraits<TraitsType>::Endianness,
RESOLVE_ENDIAN_AT_RUNTIME
>::selected Endianness;
-
+
typedef typename TraitsSelector< typename UserTraits<TraitsType>::BitsetType,
Bitset<TraitsType>
>::selected BitsetType;
typedef typename TraitsSelector< typename UserTraits<TraitsType>::BitsetListType,
BitsetList<TraitsType>
>::selected BitsetListType;
-
+
typedef typename TraitsSelector< typename UserTraits<TraitsType>::InputStreamType,
InputStream<TraitsType>
>::selected InputStreamType;
-
+
template<class SuperType>
class IntStreamType : public TraitsOneArgSelector< typename UserTraits<TraitsType>::template IntStreamType<SuperType>,
IntStream<TraitsType, SuperType>,
@@ -190,13 +190,13 @@ public:
typedef typename TraitsSelector< typename UserTraits<TraitsType>::LexStateType,
LexState<TraitsType>
>::selected LexStateType;
-
+
static const bool TOKENS_ACCESSED_FROM_OWNING_RULE = UserTraits<TraitsType>::TOKENS_ACCESSED_FROM_OWNING_RULE;
static const unsigned TOKEN_FILL_BUFFER_INCREMENT = UserTraits<TraitsType>::TOKEN_FILL_BUFFER_INCREMENT; //used only if the above val is true
-
+
static void displayRecognitionError( const StringType& str ) { UserTraits<TraitsType>::displayRecognitionError(str); }
};
-
+
/**
* Final traits
*
@@ -214,37 +214,37 @@ class Traits : public TraitsBase<UserTraits>
public:
typedef Traits TraitsType;
typedef TraitsBase<UserTraits> BaseTraitsType;
-
+
// CommonTokenType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::CommonTokenType,
CommonToken<TraitsType> >::selected CommonTokenType;
-
+
// TokenUserDataType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TokenUserDataType,
Empty >::selected TokenUserDataType;
-
+
// TokenListType
typedef typename BaseTraitsType::AllocPolicyType::template ListType<const CommonTokenType*> TokenListType;
-
+
// TokenIntStreamType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TokenIntStreamType,
TokenIntStream<TraitsType> >::selected TokenIntStreamType;
// TokenStreamType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TokenStreamType,
CommonTokenStream<TraitsType> >::selected TokenStreamType;
-
+
// TreeNodeIntStreamType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TreeNodeIntStreamType,
TreeNodeIntStream<TraitsType> >::selected TreeNodeIntStreamType;
-
+
// TreeNodeStreamType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TreeNodeStreamType,
CommonTreeNodeStream<TraitsType> >::selected TreeNodeStreamType;
-
+
// DebugEventListenerType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::DebugEventListenerType,
DebugEventListener<TraitsType> >::selected DebugEventListenerType;
-
+
// RecognizerSharedStateType
template<class StreamType>
class RecognizerSharedStateType : public TraitsOneArgSelector< typename UserTraits<TraitsType>::template RecognizerSharedStateType<StreamType>,
@@ -252,7 +252,7 @@ public:
typename UserTraits<TraitsType>::template RecognizerSharedStateType<StreamType>::BaseType
>::selected
{};
-
+
// RecognizerType
template<class StreamType>
class RecognizerType : public TraitsOneArgSelector< typename UserTraits<TraitsType>::template RecognizerType<StreamType>,
@@ -266,14 +266,14 @@ public:
typename UserTraits<TraitsType>::template RecognizerType<StreamType>::BaseType
>::selected BaseType;
typedef typename BaseType::RecognizerSharedStateType RecognizerSharedStateType;
-
+
public:
RecognizerType(ANTLR_UINT32 sizeHint, RecognizerSharedStateType* state)
: BaseType( sizeHint, state )
{
}
};
-
+
// TreeType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TreeType,
CommonTree<TraitsType> >::selected TreeType;
@@ -286,7 +286,7 @@ public:
CommonTreeStore<TraitsType> >::selected TreeStoreType;
typedef typename TreeStoreType::TreeTypePtr TreeTypePtr;
//typedef std::unique_ptr<TreeType, ResourcePoolManager<ImplTraits>> TreeTypePtr;
-
+
// ExceptionBaseType
template<class StreamType>
class ExceptionBaseType : public TraitsOneArgSelector< typename UserTraits<TraitsType>::template ExceptionBaseType<StreamType>,
@@ -306,30 +306,30 @@ public:
{
}
};
-
+
// this should be overridden with generated lexer
// BaseLexerType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::BaseLexerType,
Lexer<TraitsType> >::selected BaseLexerType;
typedef LxrType LexerType;
-
+
// TokenSourceType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::TokenSourceType,
TokenSource<TraitsType> >::selected TokenSourceType;
-
+
// this should be overridden with generated parser
// BaseParserType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::BaseParserType,
Parser<TraitsType> >::selected BaseParserType;
typedef PsrType ParserType;
-
+
// this should be overridden with generated treeparser (not implemented yet)
// BaseTreeParserType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::BaseTreeParserType,
TreeParser<TraitsType> >::selected BaseTreeParserType;
//typedef TreePsrType<Traits> TreeParserType;
typedef BaseTreeParserType TreeParserType;
-
+
// RewriteStreamType
template<class ElementType>
class RewriteStreamType : public TraitsOneArgSelector< typename UserTraits<TraitsType>::template RewriteStreamType<ElementType>,
@@ -342,12 +342,12 @@ public:
RewriteRuleElementStream<TraitsType, ElementType>,
typename UserTraits<TraitsType>::template RewriteStreamType<ElementType>::BaseType
>::selected BaseType;
-
+
//typedef typename SuperType::StreamType StreamType;
//typedef typename BaseType::RecognizerType Recognizer_Type;
//typedef typename BaseType::ElementType ElementType;
typedef typename BaseType::ElementsType ElementsType;
-
+
public:
RewriteStreamType(TreeAdaptorType* adaptor = NULL, const char* description = NULL)
:BaseType(adaptor, description)
@@ -362,7 +362,7 @@ public:
{
}
};
-
+
// RuleReturnValueType
typedef typename TraitsSelector< typename UserTraits<TraitsType>::RuleReturnValueType,
typename BoolSelector< TraitsType::TOKENS_ACCESSED_FROM_OWNING_RULE,
@@ -370,8 +370,8 @@ public:
RuleReturnValue<TraitsType>
>::selected
>::selected RuleReturnValueType;
-};
-
+};
+
}
-
-#endif //_ANTLR3_TRAITS_HPP
+
+#endif //_ANTLR3_TRAITS_HPP