diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /contrib/libs/pire | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/pire')
-rw-r--r-- | contrib/libs/pire/pire/extra/count.cpp | 16 | ||||
-rw-r--r-- | contrib/libs/pire/pire/extra/count.h | 14 | ||||
-rw-r--r-- | contrib/libs/pire/pire/scanners/loaded.h | 20 | ||||
-rw-r--r-- | contrib/libs/pire/pire/scanners/multi.h | 74 | ||||
-rw-r--r-- | contrib/libs/pire/pire/scanners/simple.h | 12 | ||||
-rw-r--r-- | contrib/libs/pire/pire/scanners/slow.h | 26 | ||||
-rw-r--r-- | contrib/libs/pire/pire/stub/stl.h | 12 | ||||
-rw-r--r-- | contrib/libs/pire/pire/stub/utf8.h | 6 |
8 files changed, 90 insertions, 90 deletions
diff --git a/contrib/libs/pire/pire/extra/count.cpp b/contrib/libs/pire/pire/extra/count.cpp index 468ff61d92..5a97351e41 100644 --- a/contrib/libs/pire/pire/extra/count.cpp +++ b/contrib/libs/pire/pire/extra/count.cpp @@ -11,7 +11,7 @@ * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Pire is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -33,7 +33,7 @@ #include <tuple> namespace Pire { - + namespace Impl { typedef LoadedScanner::Action Action; @@ -886,28 +886,28 @@ public: using TAction = typename Scanner::Action; using InternalState = typename Scanner::InternalState; typedef TMap<State, size_t> InvStates; - + CountingScannerGlueTask(const Scanner& lhs, const Scanner& rhs) : ScannerGlueCommon<Scanner>(lhs, rhs, LettersEquality<Scanner>(lhs.m_letters, rhs.m_letters)) { } - + void AcceptStates(const TVector<State>& states) { States = states; this->SetSc(THolder<Scanner>(new Scanner)); this->Sc().Init(states.size(), this->Letters(), 0, this->Lhs().RegexpsCount() + this->Rhs().RegexpsCount()); - + for (size_t i = 0; i < states.size(); ++i) this->Sc().SetTag(i, this->Lhs().m_tags[this->Lhs().StateIdx(states[i].first)] | (this->Rhs().m_tags[this->Rhs().StateIdx(states[i].second)] << 3)); } - + void Connect(size_t from, size_t to, Char letter) { this->Sc().SetJump(from, letter, to, Action(this->Lhs(), States[from].first, letter) | (Action(this->Rhs(), States[from].second, letter) << this->Lhs().RegexpsCount())); } - + protected: TVector<State> States; TAction Action(const Scanner& sc, InternalState state, Char letter) const @@ -981,7 +981,7 @@ private: } - + CountingScanner CountingScanner::Glue(const CountingScanner& lhs, const CountingScanner& rhs, size_t maxSize /* = 0 */) { if (lhs.RegexpsCount() + rhs.RegexpsCount() > MAX_RE_COUNT) { diff --git a/contrib/libs/pire/pire/extra/count.h b/contrib/libs/pire/pire/extra/count.h index bd1526b98d..03c2659c80 100644 --- a/contrib/libs/pire/pire/extra/count.h +++ b/contrib/libs/pire/pire/extra/count.h @@ -11,7 +11,7 @@ * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Pire is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -31,11 +31,11 @@ namespace Pire { class Fsm; - + namespace Impl { template<class T> class ScannerGlueCommon; - + template<class T> class CountingScannerGlueTask; @@ -121,7 +121,7 @@ public: enum { IncrementAction = 1, ResetAction = 2, - + FinalFlag = 0, DeadFlag = 1, }; @@ -170,7 +170,7 @@ public: bool Dead(const State&) const { return false; } using LoadedScanner::Swap; - + size_t StateIndex(const State& s) const { return StateIdx(s.m_state); } protected: @@ -192,7 +192,7 @@ protected: mask &= s.m_updatedMask; if (mask) { ResetPerformer<ActualReCount>::Do(s, mask); - s.m_updatedMask &= (Action)~mask; + s.m_updatedMask &= (Action)~mask; } } @@ -267,7 +267,7 @@ private: else return 0; } - + friend void BuildScanner<CountingScanner>(const Fsm&, CountingScanner&); friend class Impl::ScannerGlueCommon<CountingScanner>; friend class Impl::CountingScannerGlueTask<CountingScanner>; diff --git a/contrib/libs/pire/pire/scanners/loaded.h b/contrib/libs/pire/pire/scanners/loaded.h index 120dc403b7..3b77a3979e 100644 --- a/contrib/libs/pire/pire/scanners/loaded.h +++ b/contrib/libs/pire/pire/scanners/loaded.h @@ -11,7 +11,7 @@ * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Pire is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -68,16 +68,16 @@ public: }; // Override in subclass, if neccessary - enum { + enum { FinalFlag = 0, DeadFlag = 0 }; static const size_t MAX_RE_COUNT = 16; -protected: +protected: LoadedScanner() { Alias(Null()); } - + LoadedScanner(const LoadedScanner& s): m(s.m) { if (s.m_buffer) { @@ -137,7 +137,7 @@ public: Locals* locals; Impl::MapPtr(locals, 1, p, size); memcpy(&s.m, locals, sizeof(s.m)); - + Impl::MapPtr(s.m_letters, MaxChar, p, size); Impl::MapPtr(s.m_jumps, s.m.statesCount * s.m.lettersCount, p, size); if (header.Version == Header::RE_VERSION_WITH_MACTIONS) { @@ -145,7 +145,7 @@ public: Impl::MapPtr(actions, s.m.statesCount * s.m.lettersCount, p, size); } Impl::MapPtr(s.m_tags, s.m.statesCount, p, size); - + s.m.initial += reinterpret_cast<size_t>(s.m_jumps); Swap(s); @@ -260,14 +260,14 @@ private: static const LoadedScanner n = Fsm::MakeFalse().Compile<LoadedScanner>(); return n; } - + void Markup(void* buf) { m_letters = reinterpret_cast<Letter*>(buf); m_jumps = reinterpret_cast<Transition*>(m_letters + MaxChar); m_tags = reinterpret_cast<Tag*>(m_jumps + m.statesCount * m.lettersCount); } - + void Alias(const LoadedScanner& s) { memcpy(&m, &s.m, sizeof(m)); @@ -283,9 +283,9 @@ private: Init(states, letters, startState, regexpsCount); } - friend class Fsm; + friend class Fsm; }; - + inline LoadedScanner::~LoadedScanner() = default; } diff --git a/contrib/libs/pire/pire/scanners/multi.h b/contrib/libs/pire/pire/scanners/multi.h index 29679e416e..105b44ca3e 100644 --- a/contrib/libs/pire/pire/scanners/multi.h +++ b/contrib/libs/pire/pire/scanners/multi.h @@ -82,7 +82,7 @@ namespace Impl { }; -// Scanner implementation parametrized by +// Scanner implementation parametrized by // - transition table representation strategy // - strategy for fast forwarding through memory ranges template<class Relocation, class Shortcutting> @@ -120,7 +120,7 @@ public: typedef typename Shortcutting::template ExtendedRowHeader<Scanner> ScannerRowHeader; Scanner() { Alias(Null()); } - + explicit Scanner(Fsm& fsm, size_t distance = 0) { if (distance) { @@ -257,14 +257,14 @@ public: throw Error("Type mismatch while mmapping Pire::Scanner"); Impl::AdvancePtr(p, size, sizeof(s.m)); Impl::AlignPtr(p, size); - + if (Shortcutting::Signature != s.m.shortcuttingSignature) throw Error("This scanner has different shortcutting type"); - + bool empty = *((const bool*) p); Impl::AdvancePtr(p, size, sizeof(empty)); Impl::AlignPtr(p, size); - + if (empty) s.Alias(Null()); else { @@ -335,8 +335,8 @@ protected: inline static const Scanner& Null() { static const Scanner n = Fsm::MakeFalse().Compile< Scanner<Relocation, Shortcutting> >(); - - return n; + + return n; } // Returns transition row size in Transition's. Row size_in bytes should be a multiple of sizeof(MaxSizeWord) @@ -394,7 +394,7 @@ protected: m_finalIndex = s.m_finalIndex; m_transitions = s.m_transitions; } - + template<class AnotherRelocation> void DeepCopy(const Scanner<AnotherRelocation, Shortcutting>& s) { @@ -582,7 +582,7 @@ struct ScannerSaver { bool empty; LoadPodType(s, empty); Impl::AlignLoad(s, sizeof(empty)); - + if (empty) { sc.Alias(ScannerType::Null()); } else { @@ -596,13 +596,13 @@ struct ScannerSaver { // TODO: implement more effective serialization // of nonrelocatable scanner if necessary - + template<class Shortcutting> static void SaveScanner(const Scanner<Nonrelocatable, Shortcutting>& scanner, yostream* s) { Scanner<Relocatable, Shortcutting>(scanner).Save(s); } - + template<class Shortcutting> static void LoadScanner(Scanner<Nonrelocatable, Shortcutting>& scanner, yistream* s) { @@ -633,7 +633,7 @@ private: NO_SHORTCUT_MASK = 1, // the state doesn't have shortcuts NO_EXIT_MASK = 2 // the state has only transtions to itself (we can stop the scan) }; - + template<class ScannerRowHeader, unsigned N> struct MaskCheckerBase { static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION @@ -645,7 +645,7 @@ private: } return !IsAnySet(mask); } - + static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION const Word* DoRun(const ScannerRowHeader& hdr, size_t alignOffset, const Word* begin, const Word* end) { @@ -653,12 +653,12 @@ private: return begin; } }; - + template<class ScannerRowHeader, unsigned N, unsigned Nmax> struct MaskChecker : MaskCheckerBase<ScannerRowHeader, N> { typedef MaskCheckerBase<ScannerRowHeader, N> Base; typedef MaskChecker<ScannerRowHeader, N+1, Nmax> Next; - + static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION const Word* Run(const ScannerRowHeader& hdr, size_t alignOffset, const Word* begin, const Word* end) { @@ -668,17 +668,17 @@ private: return Next::Run(hdr, alignOffset, begin, end); } }; - + template<class ScannerRowHeader, unsigned N> struct MaskChecker<ScannerRowHeader, N, N> : MaskCheckerBase<ScannerRowHeader, N> { typedef MaskCheckerBase<ScannerRowHeader, N> Base; - + static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION const Word* Run(const ScannerRowHeader& hdr, size_t alignOffset, const Word* begin, const Word* end) { return Base::DoRun(hdr, alignOffset, begin, end); } - }; + }; // Compares the ExitMask[0] value without SSE reads which seems to be more optimal template <class Relocation> @@ -704,7 +704,7 @@ public: MaskSizeInSizeT = 2 * SizeTInMaxSizeWord, }; - public: + public: static const size_t ExitMaskCount = MaskCount; inline @@ -716,14 +716,14 @@ public: Y_ASSERT(IsAligned(p, sizeof(Word))); return *p; } - + PIRE_FORCED_INLINE PIRE_HOT_FUNCTION size_t Mask(size_t i) const { Y_ASSERT(i < ExitMaskCount); return ExitMasksArray[MaskSizeInSizeT*i]; } - + void SetMask(size_t i, size_t val) { for (size_t j = 0; j < MaskSizeInSizeT; ++j) @@ -735,7 +735,7 @@ public: for (size_t i = 0; i < ExitMaskCount; ++i) SetMask(i, NO_SHORTCUT_MASK); } - + template <class OtherScanner> ExtendedRowHeader& operator =(const ExtendedRowHeader<OtherScanner>& other) { @@ -932,7 +932,7 @@ public: static inline PIRE_HOT_FUNCTION Action RunAligned(const ScannerType& scanner, typename ScannerType::State& st, const size_t* begin, const size_t* end , Pred pred) { - typename ScannerType::State state = st; + typename ScannerType::State state = st; const Word* head = AlignUp((const Word*) begin, sizeof(Word)); const Word* tail = AlignDown((const Word*) end, sizeof(Word)); for (; begin != (const size_t*) head && begin != end; ++begin) @@ -940,7 +940,7 @@ public: st = state; return Stop; } - + if (begin == end) { st = state; return Continue; @@ -949,7 +949,7 @@ public: st = state; return pred(scanner, state, ((const char*) end)); } - + // Row size should be a multiple of MaxSizeWord size. Then alignOffset is the same for any state Y_ASSERT((scanner.RowSize()*sizeof(typename ScannerType::Transition)) % sizeof(MaxSizeWord) == 0); size_t alignOffset = (AlignUp((size_t)scanner.m_transitions, sizeof(Word)) - (size_t)scanner.m_transitions) / sizeof(size_t); @@ -980,14 +980,14 @@ public: head = skipEnd; noShortcut = true; } - + for (size_t* p = (size_t*) tail; p != end; ++p) { if (RunChunk(scanner, state, p, 0, sizeof(void*), pred) == Stop) { st = state; return Stop; } } - + st = state; return Continue; } @@ -1004,36 +1004,36 @@ public: using Base::Rhs; using Base::Sc; using Base::Letters; - + typedef GluedStateLookupTable<256*1024, typename Scanner::State> InvStates; - + ScannerGlueTask(const Scanner& lhs, const Scanner& rhs) : ScannerGlueCommon<Scanner>(lhs, rhs, LettersEquality<Scanner>(lhs.m_letters, rhs.m_letters)) { } - + void AcceptStates(const TVector<State>& states) { // Make up a new scanner and fill in the final table - + size_t finalTableSize = 0; for (auto&& i : states) finalTableSize += RangeLen(Lhs().AcceptedRegexps(i.first)) + RangeLen(Rhs().AcceptedRegexps(i.second)); this->SetSc(THolder<Scanner>(new Scanner)); Sc().Init(states.size(), Letters(), finalTableSize, size_t(0), Lhs().RegexpsCount() + Rhs().RegexpsCount()); - + auto finalWriter = Sc().m_final; for (size_t state = 0; state != states.size(); ++state) { Sc().m_finalIndex[state] = finalWriter - Sc().m_final; finalWriter = Shift(Lhs().AcceptedRegexps(states[state].first), 0, finalWriter); finalWriter = Shift(Rhs().AcceptedRegexps(states[state].second), Lhs().RegexpsCount(), finalWriter); *finalWriter++ = static_cast<size_t>(-1); - + Sc().SetTag(state, ((Lhs().Final(states[state].first) || Rhs().Final(states[state].second)) ? Scanner::FinalFlag : 0) | ((Lhs().Dead(states[state].first) && Rhs().Dead(states[state].second)) ? Scanner::DeadFlag : 0)); } } - + void Connect(size_t from, size_t to, Char letter) { Sc().SetJump(from, letter, to); } const Scanner& Success() @@ -1041,8 +1041,8 @@ public: Sc().BuildShortcuts(); return Sc(); } - -private: + +private: template<class Iter> size_t RangeLen(ypair<Iter, Iter> range) const { @@ -1089,7 +1089,7 @@ Impl::Scanner<Relocation, Shortcutting> Impl::Scanner<Relocation, Shortcutting>: return rhs; if (rhs.Empty()) return lhs; - + static const size_t DefMaxSize = 80000; Impl::ScannerGlueTask< Impl::Scanner<Relocation, Shortcutting> > task(lhs, rhs); return Impl::Determine(task, maxSize ? maxSize : DefMaxSize); diff --git a/contrib/libs/pire/pire/scanners/simple.h b/contrib/libs/pire/pire/scanners/simple.h index ef959aeed1..ab0aca6ae1 100644 --- a/contrib/libs/pire/pire/scanners/simple.h +++ b/contrib/libs/pire/pire/scanners/simple.h @@ -11,7 +11,7 @@ * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Pire is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -48,7 +48,7 @@ public: typedef ui8 Tag; SimpleScanner() { Alias(Null()); } - + explicit SimpleScanner(Fsm& fsm, size_t distance = 0); size_t Size() const { return m.statesCount; } @@ -96,7 +96,7 @@ public: m.initial += (m_transitions - s.m_transitions) * sizeof(Transition); } } - + // Makes a shallow ("weak") copy of the given scanner. // The copied scanner does not maintain lifetime of the original's entrails. void Alias(const SimpleScanner& s) @@ -139,7 +139,7 @@ public: bool empty = *((const bool*) p); Impl::AdvancePtr(p, size, sizeof(empty)); Impl::AlignPtr(p, size); - + if (empty) s.Alias(Null()); else { @@ -235,7 +235,7 @@ inline SimpleScanner::SimpleScanner(Fsm& fsm, size_t distance) fsm = CreateApproxFsm(fsm, distance); } fsm.Canonize(); - + m.statesCount = fsm.Size(); m_buffer = BufferType(new char[BufSize()]); memset(m_buffer.Get(), 0, BufSize()); @@ -255,7 +255,7 @@ inline SimpleScanner::SimpleScanner(Fsm& fsm, size_t distance) } } - + } #endif diff --git a/contrib/libs/pire/pire/scanners/slow.h b/contrib/libs/pire/pire/scanners/slow.h index 6adfcb8c1d..6a12817623 100644 --- a/contrib/libs/pire/pire/scanners/slow.h +++ b/contrib/libs/pire/pire/scanners/slow.h @@ -11,7 +11,7 @@ * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * Pire is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -56,7 +56,7 @@ public: typedef ui32 Action; typedef ui8 Tag; - enum { + enum { FinalFlag = 1, DeadFlag = 0 }; @@ -84,7 +84,7 @@ public: size_t Size() const { return GetSize(); } size_t GetSize() const { return m.statesCount; } bool Empty() const { return m_finals == Null().m_finals; } - + size_t Id() const {return (size_t) -1;} size_t RegexpsCount() const { return Empty() ? 0 : 1; } @@ -170,7 +170,7 @@ public: bool CanStop(const State& s) const { return Final(s); } - + const void* Mmap(const void* ptr, size_t size) { Impl::CheckAlign(ptr); @@ -181,11 +181,11 @@ public: Locals* locals; Impl::MapPtr(locals, 1, p, size); memcpy(&s.m, locals, sizeof(s.m)); - + bool empty = *((const bool*) p); Impl::AdvancePtr(p, size, sizeof(empty)); Impl::AlignPtr(p, size); - + if (empty) s.Alias(Null()); else { @@ -213,7 +213,7 @@ public: DoSwap(m_letters, s.m_letters); DoSwap(m_pool, s.m_pool); DoSwap(m_vec, s.m_vec); - + DoSwap(m_vecptr, s.m_vecptr); DoSwap(need_actions, s.need_actions); DoSwap(m_actionsvec, s.m_actionsvec); @@ -249,7 +249,7 @@ public: m_vecptr = &m_vec; } } - + explicit SlowScanner(Fsm& fsm, bool needActions = false, bool removeEpsilons = true, size_t distance = 0) : need_actions(needActions) { @@ -365,9 +365,9 @@ private: memset(p, 0, size * sizeof(T)); m_pool.push_back(p); } - + void Alias(const SlowScanner& s) - { + { memcpy(&m, &s.m, sizeof(m)); m_vec.clear(); need_actions = s.need_actions; @@ -380,7 +380,7 @@ private: m_vecptr = s.m_vecptr; m_pool.clear(); } - + void SetJump(size_t oldState, Char c, size_t newState, unsigned long action) { Y_ASSERT(!m_vec.empty()); @@ -397,7 +397,7 @@ private: void SetInitial(size_t state) { m.start = state; } void SetTag(size_t state, ui8 tag) { m_finals[state] = (tag != 0); } - + void FinishBuild() {} static ypair<const size_t*, const size_t*> Accept() @@ -427,7 +427,7 @@ inline const SlowScanner& SlowScanner::Null() return n; } -#ifndef PIRE_DEBUG +#ifndef PIRE_DEBUG /// A specialization of Run(), since its state is much heavier than other ones /// and we thus want to avoid copying states. template<> diff --git a/contrib/libs/pire/pire/stub/stl.h b/contrib/libs/pire/pire/stub/stl.h index 98ebd9f7c6..53247b2afd 100644 --- a/contrib/libs/pire/pire/stub/stl.h +++ b/contrib/libs/pire/pire/stub/stl.h @@ -27,10 +27,10 @@ namespace Pire { using ystring = TString; - template<size_t N> using ybitset = std::bitset<N>; + template<size_t N> using ybitset = std::bitset<N>; template<typename T1, typename T2> using ypair = std::pair<T1, T2>; - template<typename T> using yauto_ptr = std::auto_ptr<T>; - template<typename Arg1, typename Arg2, typename Result> using ybinary_function = std::binary_function<Arg1, Arg2, Result>; + template<typename T> using yauto_ptr = std::auto_ptr<T>; + template<typename Arg1, typename Arg2, typename Result> using ybinary_function = std::binary_function<Arg1, Arg2, Result>; template<typename T1, typename T2> inline ypair<T1, T2> ymake_pair(T1 v1, T2 v2) { @@ -39,16 +39,16 @@ namespace Pire { template<typename T> inline T ymax(T v1, T v2) { - return std::max(v1, v2); + return std::max(v1, v2); } template<typename T> inline T ymin(T v1, T v2) { - return std::min(v1, v2); + return std::min(v1, v2); } template<class Iter, class T> - void Fill(Iter begin, Iter end, T t) { std::fill(begin, end, t); } + void Fill(Iter begin, Iter end, T t) { std::fill(begin, end, t); } class Error: public yexception { public: diff --git a/contrib/libs/pire/pire/stub/utf8.h b/contrib/libs/pire/pire/stub/utf8.h index 51ea0479d4..7bb05c8ef9 100644 --- a/contrib/libs/pire/pire/stub/utf8.h +++ b/contrib/libs/pire/pire/stub/utf8.h @@ -1,5 +1,5 @@ -#pragma once - +#pragma once + #include <library/cpp/charset/codepage.h> #include <util/charset/unidata.h> @@ -11,7 +11,7 @@ inline wchar32 to_upper(wchar32 c) { } inline bool is_digit(wchar32 c) { - return IsDigit(c); + return IsDigit(c); } inline bool is_upper(wchar32 c) { |