diff options
author | antonovvk <antonovvk@yandex-team.ru> | 2022-02-10 16:47:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:51 +0300 |
commit | 37a63debdc21e372d99e1808cdd31aecf75018c3 (patch) | |
tree | fd84293fb9a1b16381dd6c1a5e14c78afacb8710 /contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp | |
parent | 1fe621e70df847cc201ac942fe6d7804ea10508d (diff) | |
download | ydb-37a63debdc21e372d99e1808cdd31aecf75018c3.tar.gz |
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp')
-rw-r--r-- | contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp index 68eab69568..4c33e377ff 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3bitset.hpp @@ -1,96 +1,96 @@ -/** - * \file +/** + * \file * Defines the basic structures of an ANTLR3 bitset. this is a C version of the - * cut down Bitset class provided with the java version of antlr 3. + * cut down Bitset class provided with the java version of antlr 3. * * - */ + */ #ifndef _ANTLR3_BITSET_HPP #define _ANTLR3_BITSET_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 { - -/** How many bits in the elements - */ + +/** How many bits in the elements + */ static const ANTLR_UINT32 ANTLR_BITSET_BITS = 64; - -/** How many bits in a nible of bits - */ + +/** How many bits in a nible of bits + */ static const ANTLR_UINT32 ANTLR_BITSET_NIBBLE = 4; - -/** log2 of ANTLR3_BITSET_BITS 2^ANTLR3_BITSET_LOG_BITS = ANTLR3_BITSET_BITS - */ + +/** log2 of ANTLR3_BITSET_BITS 2^ANTLR3_BITSET_LOG_BITS = ANTLR3_BITSET_BITS + */ static const ANTLR_UINT32 ANTLR_BITSET_LOG_BITS = 6; - -/** We will often need to do a mod operator (i mod nbits). - * For powers of two, this mod operation is the - * same as: + +/** We will often need to do a mod operator (i mod nbits). + * For powers of two, this mod operation is the + * same as: * - (i & (nbits-1)). - * - * Since mod is relatively slow, we use an easily - * precomputed mod mask to do the mod instead. - */ + * + * Since mod is relatively slow, we use an easily + * precomputed mod mask to do the mod instead. + */ static const ANTLR_UINT32 ANTLR_BITSET_MOD_MASK = ANTLR_BITSET_BITS - 1; - -template <class ImplTraits> -class BitsetList : public ImplTraits::AllocPolicyType -{ -public: + +template <class ImplTraits> +class BitsetList : public ImplTraits::AllocPolicyType +{ +public: typedef typename ImplTraits::AllocPolicyType AllocPolicyType; typedef typename ImplTraits::BitsetType BitsetType; - -private: + +private: /// Pointer to the allocated array of bits for this bit set, which /// is an array of 64 bit elements (of the architecture). If we find a - /// machine/C compiler that does not know anything about 64 bit values + /// machine/C compiler that does not know anything about 64 bit values /// then it should be easy enough to produce a 32 bit (or less) version - /// of the bitset code. Note that the pointer here may be static if laid down + /// of the bitset code. Note that the pointer here may be static if laid down /// by the code generation, and it must be copied if it is to be manipulated /// to perform followset calculations. - /// - ANTLR_BITWORD* m_bits; - - /// Length of the current bit set in ANTLR3_UINT64 units. - /// - ANTLR_UINT32 m_length; - -public: + /// + ANTLR_BITWORD* m_bits; + + /// Length of the current bit set in ANTLR3_UINT64 units. + /// + ANTLR_UINT32 m_length; + +public: BitsetList(); BitsetList( ANTLR_BITWORD* bits, ANTLR_UINT32 length ); - + ANTLR_BITWORD* get_bits() const; ANTLR_UINT32 get_length() const; void set_bits( ANTLR_BITWORD* bits ); void set_length( ANTLR_UINT32 length ); - + /// /// \brief /// Creates a new bitset with at least one 64 bit bset of bits, but as @@ -113,30 +113,30 @@ public: /// /// BitsetType* bitsetLoad(); - + BitsetType* bitsetCopy(); - -}; - -template <class ImplTraits> -class Bitset : public ImplTraits::AllocPolicyType -{ -public: + +}; + +template <class ImplTraits> +class Bitset : public ImplTraits::AllocPolicyType +{ +public: typedef typename ImplTraits::AllocPolicyType AllocPolicyType; typedef typename AllocPolicyType::template ListType<ANTLR_UINT32> IntListType; typedef typename ImplTraits::BitsetListType BitsetListType; - -private: + +private: /// The actual bits themselves /// BitsetListType m_blist; - -public: + +public: Bitset( ANTLR_UINT32 nbits=0 ); Bitset( const Bitset& bitset ); - Bitset* clone() const; + Bitset* clone() const; Bitset* bor(Bitset* bitset2); - + BitsetListType& get_blist(); void borInPlace(Bitset* bitset2); ANTLR_UINT32 size() const; @@ -147,7 +147,7 @@ public: ANTLR_UINT32 numBits() const; void remove(ANTLR_UINT32 bit); bool isNilNode() const; - + /** Produce an integer list of all the bits that are turned on * in this bitset. Used for error processing in the main as the bitset * reresents a number of integer tokens which we use for follow sets @@ -156,7 +156,7 @@ public: * The first entry is the number of elements following in the list. */ ANTLR_INT32* toIntList() const; - + /// /// \brief /// Creates a new bitset with at least one element, but as @@ -204,19 +204,19 @@ public: ///antlr3BitsetList static Bitset* BitsetFromList(const IntListType& list); ~Bitset(); - -private: + +private: void growToInclude(ANTLR_INT32 bit); static ANTLR_UINT64 BitMask(ANTLR_UINT32 bitNumber); static ANTLR_UINT32 NumWordsToHold(ANTLR_UINT32 bit); static ANTLR_UINT32 WordNumber(ANTLR_UINT32 bit); void bitsetORInPlace(Bitset* bitset2); -}; - +}; + } - -#include "antlr3bitset.inl" - -#endif - + +#include "antlr3bitset.inl" + +#endif + |