diff options
author | pavlichenko <pavlichenko@yandex-team.ru> | 2022-02-10 16:48:06 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:06 +0300 |
commit | 1916d87e4a1be8b60140240d49f0572a22e54bf8 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /contrib/libs | |
parent | 97688057f4d92d26b7ee54383bfa002579bcf3d9 (diff) | |
download | ydb-1916d87e4a1be8b60140240d49f0572a22e54bf8.tar.gz |
Restoring authorship annotation for <pavlichenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs')
25 files changed, 584 insertions, 584 deletions
diff --git a/contrib/libs/pire/pire/any.h b/contrib/libs/pire/pire/any.h index eefa20175f..4646d25781 100644 --- a/contrib/libs/pire/pire/any.h +++ b/contrib/libs/pire/pire/any.h @@ -34,7 +34,7 @@ namespace Pire { class Any { public: - Any() = default; + Any() = default; Any(const Any& any) { @@ -89,7 +89,7 @@ private: struct AbstractHolder { virtual ~AbstractHolder() { } - virtual THolder<AbstractHolder> Duplicate() const = 0; + virtual THolder<AbstractHolder> Duplicate() const = 0; virtual bool IsA(const std::type_info& id) const = 0; virtual void* Ptr() = 0; virtual const void* Ptr() const = 0; @@ -101,8 +101,8 @@ private: : d(t) { } - THolder<AbstractHolder> Duplicate() const { - return THolder<AbstractHolder>(new Holder<T>(d)); + THolder<AbstractHolder> Duplicate() const { + return THolder<AbstractHolder>(new Holder<T>(d)); } bool IsA(const std::type_info& id) const { return id == typeid(T); @@ -117,7 +117,7 @@ private: T d; }; - THolder<AbstractHolder> h; + THolder<AbstractHolder> h; }; } diff --git a/contrib/libs/pire/pire/classes.cpp b/contrib/libs/pire/pire/classes.cpp index f34535c6a8..bbf021737d 100644 --- a/contrib/libs/pire/pire/classes.cpp +++ b/contrib/libs/pire/pire/classes.cpp @@ -56,8 +56,8 @@ namespace { TSet<wchar32> ToSet() const { TSet<wchar32> ret; - for (auto&& bound : m_bounds) - for (wchar32 c = bound.first; c <= bound.second; ++c) + for (auto&& bound : m_bounds) + for (wchar32 c = bound.first; c <= bound.second; ++c) ret.insert(c); return ret; } @@ -74,7 +74,7 @@ namespace { TSet<wchar32> Get(wchar32 wc) const { - auto it = m_classes.find(to_lower(wc & ~ControlMask)); + auto it = m_classes.find(to_lower(wc & ~ControlMask)); if (it == m_classes.end()) throw Error("Unknown character class"); return it->second.ToSet(); @@ -119,18 +119,18 @@ namespace { CharSet altered; bool pos = false; bool neg = false; - for (auto&& i : old) - if (i.size() == 1 && (i[0] & ControlMask) == Control && m_table->Has(i[0])) { - if (is_upper(i[0] & ~ControlMask)) + for (auto&& i : old) + if (i.size() == 1 && (i[0] & ControlMask) == Control && m_table->Has(i[0])) { + if (is_upper(i[0] & ~ControlMask)) neg = true; else pos = true; - TSet<wchar32> klass = m_table->Get(i[0]); - for (auto&& j : klass) - altered.insert(Term::String(1, j)); + TSet<wchar32> klass = m_table->Get(i[0]); + for (auto&& j : klass) + altered.insert(Term::String(1, j)); } else - altered.insert(i); + altered.insert(i); if (neg && (pos || range.second)) Error("Positive and negative character ranges mixed"); @@ -145,7 +145,7 @@ namespace { } namespace Features { - Feature::Ptr CharClasses() { return Feature::Ptr(new CharClassesImpl); } + Feature::Ptr CharClasses() { return Feature::Ptr(new CharClassesImpl); } } } diff --git a/contrib/libs/pire/pire/determine.h b/contrib/libs/pire/pire/determine.h index 5f79bf8aad..fb48fdd0b3 100644 --- a/contrib/libs/pire/pire/determine.h +++ b/contrib/libs/pire/pire/determine.h @@ -108,24 +108,24 @@ namespace Pire { if (!task.IsRequired(states[stateIdx])) continue; TransitionTable::value_type row(task.Letters().Size()); - for (auto&& letter : task.Letters()) { - State newState = task.Next(states[stateIdx], letter.first); - auto i = invstates.find(newState); + for (auto&& letter : task.Letters()) { + State newState = task.Next(states[stateIdx], letter.first); + auto i = invstates.find(newState); if (i == invstates.end()) { if (!maxSize--) return task.Failure(); i = invstates.insert(typename InvStates::value_type(newState, states.size())).first; states.push_back(newState); } - row[letter.second.first] = i->second; + row[letter.second.first] = i->second; } transitions.push_back(row); stateIndices.push_back(stateIdx); } TVector<Char> invletters(task.Letters().Size()); - for (auto&& letter : task.Letters()) - invletters[letter.second.first] = letter.first; + for (auto&& letter : task.Letters()) + invletters[letter.second.first] = letter.first; task.AcceptStates(states); size_t from = 0; diff --git a/contrib/libs/pire/pire/easy.cpp b/contrib/libs/pire/pire/easy.cpp index b261527d04..bcb56c693b 100644 --- a/contrib/libs/pire/pire/easy.cpp +++ b/contrib/libs/pire/pire/easy.cpp @@ -27,7 +27,7 @@ namespace Pire { const Option<const Encoding&> UTF8(&Pire::Encodings::Utf8); const Option<const Encoding&> LATIN1(&Pire::Encodings::Latin1); -const Option<Feature::Ptr> I(&Pire::Features::CaseInsensitive); -const Option<Feature::Ptr> ANDNOT(&Pire::Features::AndNotSupport); +const Option<Feature::Ptr> I(&Pire::Features::CaseInsensitive); +const Option<Feature::Ptr> ANDNOT(&Pire::Features::AndNotSupport); } diff --git a/contrib/libs/pire/pire/easy.h b/contrib/libs/pire/pire/easy.h index 048b71af27..c70e965353 100644 --- a/contrib/libs/pire/pire/easy.h +++ b/contrib/libs/pire/pire/easy.h @@ -66,7 +66,7 @@ public: ~Options() { Clear(); } void Add(const Pire::Encoding& encoding) { m_encoding = &encoding; } - void Add(Feature::Ptr&& feature) { m_features.push_back(std::move(feature)); } + void Add(Feature::Ptr&& feature) { m_features.push_back(std::move(feature)); } struct Proxy { Options* const o; @@ -75,17 +75,17 @@ public: operator Proxy() { return Proxy(this); } Options(Options& o): m_encoding(o.m_encoding) { m_features.swap(o.m_features); } - Options& operator = (Options& o) { m_encoding = o.m_encoding; m_features = std::move(o.m_features); o.Clear(); return *this; } + Options& operator = (Options& o) { m_encoding = o.m_encoding; m_features = std::move(o.m_features); o.Clear(); return *this; } Options(Proxy p): m_encoding(p.o->m_encoding) { m_features.swap(p.o->m_features); } - Options& operator = (Proxy p) { m_encoding = p.o->m_encoding; m_features = std::move(p.o->m_features); p.o->Clear(); return *this; } + Options& operator = (Proxy p) { m_encoding = p.o->m_encoding; m_features = std::move(p.o->m_features); p.o->Clear(); return *this; } void Apply(Lexer& lexer) { lexer.SetEncoding(*m_encoding); - for (auto&& i : m_features) { - lexer.AddFeature(i); - i = 0; + for (auto&& i : m_features) { + lexer.AddFeature(i); + i = 0; } m_features.clear(); } @@ -97,7 +97,7 @@ public: private: const Pire::Encoding* m_encoding; - TVector<Feature::Ptr> m_features; + TVector<Feature::Ptr> m_features; void Clear() { @@ -133,8 +133,8 @@ private: extern const Option<const Encoding&> UTF8; extern const Option<const Encoding&> LATIN1; -extern const Option<Feature::Ptr> I; -extern const Option<Feature::Ptr> ANDNOT; +extern const Option<Feature::Ptr> I; +extern const Option<Feature::Ptr> ANDNOT; class Regexp { @@ -154,17 +154,17 @@ public: explicit Regexp(Scanner sc): m_scanner(sc) {} explicit Regexp(SlowScanner ssc): m_slow(ssc) {} - bool Matches(TStringBuf buf) const + bool Matches(TStringBuf buf) const { if (!m_scanner.Empty()) - return Runner(m_scanner).Begin().Run(buf).End(); + return Runner(m_scanner).Begin().Run(buf).End(); else - return Runner(m_slow).Begin().Run(buf).End(); + return Runner(m_slow).Begin().Run(buf).End(); } - - bool Matches(const char* begin, const char* end) const + + bool Matches(const char* begin, const char* end) const { - return Matches(TStringBuf(begin, end)); + return Matches(TStringBuf(begin, end)); } /// A helper class allowing '==~' operator for regexps @@ -224,10 +224,10 @@ private: while (!queue.empty()) { Set s = fsm.Destinations(queue.front(), SpecialChar::Epsilon); - for (auto&& i : s) { - if (!handled.Test(i)) { - handled.Set(i); - queue.push_back(i); + for (auto&& i : s) { + if (!handled.Test(i)) { + handled.Set(i); + queue.push_back(i); } } diff --git a/contrib/libs/pire/pire/encoding.cpp b/contrib/libs/pire/pire/encoding.cpp index 3f25b81f5d..842e2b534d 100644 --- a/contrib/libs/pire/pire/encoding.cpp +++ b/contrib/libs/pire/pire/encoding.cpp @@ -65,13 +65,13 @@ namespace { namespace UtfRanges { static const size_t MaxLen = 4; - static const size_t First[MaxLen][2] = { - {0x00, 0x80}, - {0xC0, 0xE0}, - {0xE0, 0xF0}, - {0xF0, 0xF8} + static const size_t First[MaxLen][2] = { + {0x00, 0x80}, + {0xC0, 0xE0}, + {0xE0, 0xF0}, + {0xF0, 0xF8} }; - static const size_t Next[2] = {0x80, 0xC0}; + static const size_t Next[2] = {0x80, 0xC0}; } @@ -103,10 +103,10 @@ namespace { { size_t last = fsm.Resize(fsm.Size() + UtfRanges::MaxLen); for (size_t i = 0; i < UtfRanges::MaxLen; ++i) - for (size_t letter = UtfRanges::First[i][0]; letter < UtfRanges::First[i][1]; ++letter) + for (size_t letter = UtfRanges::First[i][0]; letter < UtfRanges::First[i][1]; ++letter) fsm.ConnectFinal(fsm.Size() - i - 1, letter); for (size_t i = 0; i < UtfRanges::MaxLen - 1; ++i) - for (size_t letter = UtfRanges::Next[0]; letter < UtfRanges::Next[1]; ++letter) + for (size_t letter = UtfRanges::Next[0]; letter < UtfRanges::Next[1]; ++letter) fsm.Connect(last + i, last + i + 1, letter); fsm.ClearFinal(); fsm.SetFinal(fsm.Size() - 1, true); diff --git a/contrib/libs/pire/pire/extra/capture.cpp b/contrib/libs/pire/pire/extra/capture.cpp index 3783f00249..fb4cdf6d81 100644 --- a/contrib/libs/pire/pire/extra/capture.cpp +++ b/contrib/libs/pire/pire/extra/capture.cpp @@ -94,7 +94,7 @@ namespace { void SetRepetitionMark(Fsm& fsm, bool greedy) { - fsm.Resize(fsm.Size() + 1); + fsm.Resize(fsm.Size() + 1); fsm.ConnectFinal(fsm.Size() - 1); for (size_t state = 0; state < fsm.Size() - 1; ++state) @@ -107,7 +107,7 @@ namespace { fsm.SetFinal(fsm.Size() - 1, true); fsm.SetIsDetermined(false); } - + void SetCaptureMark(Fsm& fsm) { fsm.Resize(fsm.Size() + 2); @@ -130,6 +130,6 @@ namespace { } namespace Features { - Feature::Ptr Capture(size_t pos) { return Feature::Ptr(new CaptureImpl(pos)); } + Feature::Ptr Capture(size_t pos) { return Feature::Ptr(new CaptureImpl(pos)); } }; } diff --git a/contrib/libs/pire/pire/extra/capture.h b/contrib/libs/pire/pire/extra/capture.h index a46e803010..8399914a67 100644 --- a/contrib/libs/pire/pire/extra/capture.h +++ b/contrib/libs/pire/pire/extra/capture.h @@ -95,12 +95,12 @@ public: void TakeAction(State& s, Action a) const { - if ((a & BeginCapture) && !s.Captured()) - s.m_begin = s.m_counter - 1; - else if (a & EndCapture) { - if (s.m_end == State::npos) - s.m_end = s.m_counter - 1; - } + if ((a & BeginCapture) && !s.Captured()) + s.m_begin = s.m_counter - 1; + else if (a & EndCapture) { + if (s.m_end == State::npos) + s.m_end = s.m_counter - 1; + } } Char Translate(Char ch) const @@ -254,8 +254,8 @@ public: class State { public: State() - : m_strpos(0) - , m_matched(false) {} + : m_strpos(0) + , m_matched(false) {} size_t GetPos() const { @@ -332,8 +332,8 @@ public: } Transition(unsigned long state, Action act = 0) - : m_stateto(state) - , m_action(act) + : m_stateto(state) + , m_action(act) { } }; @@ -377,11 +377,11 @@ public: SlowScanner::State GetNextStates(const SingleState& cur, Char letter) const { - SlowScanner::State st(GetSize()); - st.states.push_back(cur.GetNum()); - SlowScanner::State nextState(GetSize()); - SlowScanner::NextTranslated(st, nextState, letter); - return nextState; + SlowScanner::State st(GetSize()); + st.states.push_back(cur.GetNum()); + SlowScanner::State nextState(GetSize()); + SlowScanner::NextTranslated(st, nextState, letter); + return nextState; } size_t GetPosition(const SingleState& state, Char letter) const @@ -416,7 +416,7 @@ public: } void NextAndGetToGroups(PriorityStates& states, const SingleState& cur, - Char letter, size_t pos, TVector<bool>& used) const + Char letter, size_t pos, TVector<bool>& used) const { TVector<Transition> nextStates; NextStates(cur, letter, nextStates); @@ -575,15 +575,15 @@ public: : SlowScanner(true) { } - + SlowCapturingScanner(Fsm& fsm, size_t distance = 0) : SlowScanner(fsm, true, false, distance) { } }; - + namespace Features { - Feature::Ptr Capture(size_t pos); + Feature::Ptr Capture(size_t pos); } } diff --git a/contrib/libs/pire/pire/extra/count.cpp b/contrib/libs/pire/pire/extra/count.cpp index 9c73ecf246..468ff61d92 100644 --- a/contrib/libs/pire/pire/extra/count.cpp +++ b/contrib/libs/pire/pire/extra/count.cpp @@ -231,7 +231,7 @@ public: for (size_t from = 0; from != Size(); ++from) { const auto fromMinimized = StateClass[from]; for (auto&& letter : mFsm.Letters()) { - const auto representative = letter.first; + const auto representative = letter.first; const auto next = Next(from, representative); const auto nextMinimized = StateClass[next]; Connect(fromMinimized, nextMinimized, representative); @@ -301,9 +301,9 @@ public: , mReInitial{reInitial} { mDeadStates = fsm.DeadStates(); - for (auto&& letter : fsm.Letters()) { - if (InvalidCharRange(letter.second.second)) { - mInvalidLetters.insert(letter.first); + for (auto&& letter : fsm.Letters()) { + if (InvalidCharRange(letter.second.second)) { + mInvalidLetters.insert(letter.first); } } } @@ -855,8 +855,8 @@ AdvancedScanner MakeAdvancedCountingScanner(const Fsm& re, const Fsm& sep, bool* AdvancedScanner scanner; scanner.Init(determined.Size(), letters, determined.Initial(), 1); for (size_t from = 0; from != determined.Size(); ++from) { - for (auto&& lettersEl : letters) { - const auto letter = lettersEl.first; + for (auto&& lettersEl : letters) { + const auto letter = lettersEl.first; const auto& tos = determined.Destinations(from, letter); Y_ASSERT(tos.size() == 1); scanner.SetJump(from, letter, *tos.begin(), scanner.RemapAction(countingFsm.Output(from, letter))); @@ -895,7 +895,7 @@ public: void AcceptStates(const TVector<State>& states) { States = states; - this->SetSc(THolder<Scanner>(new Scanner)); + 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) @@ -987,7 +987,7 @@ CountingScanner CountingScanner::Glue(const CountingScanner& lhs, const Counting if (lhs.RegexpsCount() + rhs.RegexpsCount() > MAX_RE_COUNT) { return CountingScanner(); } - static constexpr size_t DefMaxSize = 250000; + static constexpr size_t DefMaxSize = 250000; Impl::CountingScannerGlueTask<CountingScanner> task(lhs, rhs); return Impl::Determine(task, maxSize ? maxSize : DefMaxSize); } @@ -997,7 +997,7 @@ AdvancedCountingScanner AdvancedCountingScanner::Glue(const AdvancedCountingScan if (lhs.RegexpsCount() + rhs.RegexpsCount() > MAX_RE_COUNT) { return AdvancedCountingScanner(); } - static constexpr size_t DefMaxSize = 250000; + static constexpr size_t DefMaxSize = 250000; Impl::CountingScannerGlueTask<AdvancedCountingScanner> task(lhs, rhs); return Impl::Determine(task, maxSize ? maxSize : DefMaxSize); } diff --git a/contrib/libs/pire/pire/extra/glyphs.cpp b/contrib/libs/pire/pire/extra/glyphs.cpp index 27f663846e..a14d2baa56 100644 --- a/contrib/libs/pire/pire/extra/glyphs.cpp +++ b/contrib/libs/pire/pire/extra/glyphs.cpp @@ -118,13 +118,13 @@ namespace { typedef Term::CharacterRange::first_type CharSet; const CharSet& old = range.first; CharSet altered; - for (auto&& i : old) { + for (auto&& i : old) { const TVector<wchar32>* klass = 0; - if (i.size() == 1 && !(klass = &m_table->Klass(i[0]))->empty()) - for (auto&& j : *klass) - altered.insert(Term::String(1, j)); + if (i.size() == 1 && !(klass = &m_table->Klass(i[0]))->empty()) + for (auto&& j : *klass) + altered.insert(Term::String(1, j)); else - altered.insert(i); + altered.insert(i); } t = Term(t.Type(), Term::CharacterRange(altered, range.second)); @@ -137,7 +137,7 @@ namespace { } namespace Features { - Feature::Ptr GlueSimilarGlyphs() { return Feature::Ptr(new GlueSimilarGlyphsImpl); } + Feature::Ptr GlueSimilarGlyphs() { return Feature::Ptr(new GlueSimilarGlyphsImpl); } } } diff --git a/contrib/libs/pire/pire/extra/glyphs.h b/contrib/libs/pire/pire/extra/glyphs.h index b85af57d20..678b9e15c4 100644 --- a/contrib/libs/pire/pire/extra/glyphs.h +++ b/contrib/libs/pire/pire/extra/glyphs.h @@ -34,7 +34,7 @@ namespace Features { * and cyrillic letters having identical shapes * (e.g. latin A and cyrillic A). */ - Feature::Ptr GlueSimilarGlyphs(); + Feature::Ptr GlueSimilarGlyphs(); } } diff --git a/contrib/libs/pire/pire/fsm.cpp b/contrib/libs/pire/pire/fsm.cpp index 177fb62b08..984d708dfa 100644 --- a/contrib/libs/pire/pire/fsm.cpp +++ b/contrib/libs/pire/pire/fsm.cpp @@ -46,21 +46,21 @@ namespace Pire { ystring CharDump(Char c) { char buf[8]; - if (c == '"') - return ystring("\\\""); - else if (c == '[' || c == ']' || c == '-' || c == '^') { - snprintf(buf, sizeof(buf)-1, "\\\\%c", c); - return ystring(buf); - } else if (c >= 32 && c < 127) + if (c == '"') + return ystring("\\\""); + else if (c == '[' || c == ']' || c == '-' || c == '^') { + snprintf(buf, sizeof(buf)-1, "\\\\%c", c); + return ystring(buf); + } else if (c >= 32 && c < 127) return ystring(1, static_cast<char>(c)); else if (c == '\n') - return ystring("\\\\n"); + return ystring("\\\\n"); else if (c == '\t') - return ystring("\\\\t"); + return ystring("\\\\t"); else if (c == '\r') - return ystring("\\\\r"); + return ystring("\\\\r"); else if (c < 256) { - snprintf(buf, sizeof(buf)-1, "\\\\%03o", static_cast<int>(c)); + snprintf(buf, sizeof(buf)-1, "\\\\%03o", static_cast<int>(c)); return ystring(buf); } else if (c == Epsilon) return ystring("<Epsilon>"); @@ -76,84 +76,84 @@ void Fsm::DumpState(yostream& s, size_t state) const { // Fill in a 'row': Q -> exp(V) (for current state) TVector< ybitset<MaxChar> > row(Size()); - for (auto&& transition : m_transitions[state]) - for (auto&& transitionState : transition.second) { - if (transitionState >= Size()) { - std::cerr << "WTF?! Transition from " << state << " on letter " << transition.first << " leads to non-existing state " << transitionState << "\n"; + for (auto&& transition : m_transitions[state]) + for (auto&& transitionState : transition.second) { + if (transitionState >= Size()) { + std::cerr << "WTF?! Transition from " << state << " on letter " << transition.first << " leads to non-existing state " << transitionState << "\n"; Y_ASSERT(false); } - if (Letters().Contains(transition.first)) { - const TVector<Char>& letters = Letters().Klass(Letters().Representative(transition.first)); - for (auto&& letter : letters) - row[transitionState].set(letter); + if (Letters().Contains(transition.first)) { + const TVector<Char>& letters = Letters().Klass(Letters().Representative(transition.first)); + for (auto&& letter : letters) + row[transitionState].set(letter); } else - row[transitionState].set(transition.first); + row[transitionState].set(transition.first); } - bool statePrinted = false; + bool statePrinted = false; // Display each destination state - for (auto rit = row.begin(), rie = row.end(); rit != rie; ++rit) { + for (auto rit = row.begin(), rie = row.end(); rit != rie; ++rit) { unsigned begin = 0, end = 0; - ystring delimiter; - ystring label; + ystring delimiter; + ystring label; if (rit->test(Epsilon)) { - label += delimiter + CharDump(Epsilon); - delimiter = " "; + label += delimiter + CharDump(Epsilon); + delimiter = " "; } if (rit->test(BeginMark)) { - label += delimiter + CharDump(BeginMark); - delimiter = " "; + label += delimiter + CharDump(BeginMark); + delimiter = " "; } if (rit->test(EndMark)) { - label += delimiter + CharDump(EndMark); - delimiter = " "; + label += delimiter + CharDump(EndMark); + delimiter = " "; } - unsigned count = 0; - for (unsigned i = 0; i < 256; ++i) - if (rit->test(i)) - ++count; - if (count != 0 && count != 256) { - label += delimiter + "["; - bool complementary = (count > 128); - if (count > 128) - label += "^"; - while (begin < 256) { - for (begin = end; begin < 256 && (rit->test(begin) == complementary); ++begin) - ; - for (end = begin; end < 256 && (rit->test(end) == !complementary); ++end) - ; - if (begin + 1 == end) { - label += CharDump(begin); - delimiter = " "; - } else if (begin != end) { - label += CharDump(begin) + "-" + (CharDump(end-1)); - delimiter = " "; - } + unsigned count = 0; + for (unsigned i = 0; i < 256; ++i) + if (rit->test(i)) + ++count; + if (count != 0 && count != 256) { + label += delimiter + "["; + bool complementary = (count > 128); + if (count > 128) + label += "^"; + while (begin < 256) { + for (begin = end; begin < 256 && (rit->test(begin) == complementary); ++begin) + ; + for (end = begin; end < 256 && (rit->test(end) == !complementary); ++end) + ; + if (begin + 1 == end) { + label += CharDump(begin); + delimiter = " "; + } else if (begin != end) { + label += CharDump(begin) + "-" + (CharDump(end-1)); + delimiter = " "; + } } - label += "]"; - delimiter = " "; - } else if (count == 256) { - label += delimiter + "."; - delimiter = " "; + label += "]"; + delimiter = " "; + } else if (count == 256) { + label += delimiter + "."; + delimiter = " "; } - if (!label.empty()) { - if (!statePrinted) { - s << " " << state << "[shape=\"" << (IsFinal(state) ? "double" : "") << "circle\",label=\"" << state; - auto ti = tags.find(state); - if (ti != tags.end()) - s << " (tags: " << ti->second << ")"; - s << "\"]\n"; - if (Initial() == state) - s << " \"initial\" -> " << state << '\n'; - statePrinted = true; - } - s << " " << state << " -> " << std::distance(row.begin(), rit) << "[label=\"" << label; + if (!label.empty()) { + if (!statePrinted) { + s << " " << state << "[shape=\"" << (IsFinal(state) ? "double" : "") << "circle\",label=\"" << state; + auto ti = tags.find(state); + if (ti != tags.end()) + s << " (tags: " << ti->second << ")"; + s << "\"]\n"; + if (Initial() == state) + s << " \"initial\" -> " << state << '\n'; + statePrinted = true; + } + s << " " << state << " -> " << std::distance(row.begin(), rit) << "[label=\"" << label; // Display outputs - auto oit = outputs.find(state); + auto oit = outputs.find(state); if (oit != outputs.end()) { - auto oit2 = oit->second.find(std::distance(row.begin(), rit)); + auto oit2 = oit->second.find(std::distance(row.begin(), rit)); if (oit2 == oit->second.end()) ; else { @@ -162,25 +162,25 @@ void Fsm::DumpState(yostream& s, size_t state) const if (oit2->second & (1ul << i)) payload.push_back(i); if (!payload.empty()) - s << " (outputs: " << Join(payload.begin(), payload.end(), ", ") << ")"; + s << " (outputs: " << Join(payload.begin(), payload.end(), ", ") << ")"; } } - - s << "\"]\n"; + + s << "\"]\n"; } } - - if (statePrinted) - s << '\n'; + + if (statePrinted) + s << '\n'; } -void Fsm::DumpTo(yostream& s, const ystring& name) const +void Fsm::DumpTo(yostream& s, const ystring& name) const { - s << "digraph {\n \"initial\"[shape=\"plaintext\",label=\"" << name << "\"]\n\n"; + s << "digraph {\n \"initial\"[shape=\"plaintext\",label=\"" << name << "\"]\n\n"; for (size_t state = 0; state < Size(); ++state) { DumpState(s, state); } - s << "}\n\n"; + s << "}\n\n"; } yostream& operator << (yostream& s, const Fsm& fsm) { fsm.DumpTo(s); return s; } @@ -218,13 +218,13 @@ Char Fsm::Translate(Char c) const bool Fsm::Connected(size_t from, size_t to, Char c) const { - auto it = m_transitions[from].find(Translate(c)); + auto it = m_transitions[from].find(Translate(c)); return (it != m_transitions[from].end() && it->second.find(to) != it->second.end()); } bool Fsm::Connected(size_t from, size_t to) const { - for (auto i = m_transitions[from].begin(), ie = m_transitions[from].end(); i != ie; ++i) + for (auto i = m_transitions[from].begin(), ie = m_transitions[from].end(); i != ie; ++i) if (i->second.find(to) != i->second.end()) return true; return false; @@ -232,15 +232,15 @@ bool Fsm::Connected(size_t from, size_t to) const const Fsm::StatesSet& Fsm::Destinations(size_t from, Char c) const { - auto i = m_transitions[from].find(Translate(c)); + auto i = m_transitions[from].find(Translate(c)); return (i != m_transitions[from].end()) ? i->second : DefaultValue<StatesSet>(); } TSet<Char> Fsm::OutgoingLetters(size_t state) const { TSet<Char> ret; - for (auto&& i : m_transitions[state]) - ret.insert(i.first); + for (auto&& i : m_transitions[state]) + ret.insert(i.first); return ret; } @@ -294,8 +294,8 @@ Fsm& Fsm::Append(char c) Fsm& Fsm::Append(const ystring& str) { - for (auto&& i : str) - Append(i); + for (auto&& i : str) + Append(i); return *this; } @@ -311,8 +311,8 @@ Fsm& Fsm::AppendSpecial(Char c) Fsm& Fsm::AppendStrings(const TVector<ystring>& strings) { - for (auto&& i : strings) - if (i.empty()) + for (auto&& i : strings) + if (i.empty()) throw Error("None of strings passed to appendStrings() can be empty"); Resize(Size() + 1); @@ -336,7 +336,7 @@ Fsm& Fsm::AppendStrings(const TVector<ystring>& strings) TSet<Transition> usedTransitions; TSet<char> usedFirsts; - for (const auto& str : strings) { + for (const auto& str : strings) { if (str.size() > 1) { // First letter: all previously final states are connected to the new state @@ -349,7 +349,7 @@ Fsm& Fsm::AppendStrings(const TVector<ystring>& strings) // All other letters except last one size_t state = firstJump; - for (auto cit = str.begin() + 1, cie = str.end() - 1; cit != cie; ++cit) { + for (auto cit = str.begin() + 1, cie = str.end() - 1; cit != cie; ++cit) { size_t& newState = ltr[ymake_pair(state, *cit)]; if (!newState) { newState = Resize(Size() + 1); @@ -384,46 +384,46 @@ void Fsm::Import(const Fsm& rhs) size_t oldsize = Resize(Size() + rhs.Size()); - for (auto&& outer : m_transitions) { - for (auto&& letter : letters) { - auto targets = outer.find(letter.first); - if (targets == outer.end()) + for (auto&& outer : m_transitions) { + for (auto&& letter : letters) { + auto targets = outer.find(letter.first); + if (targets == outer.end()) continue; - for (auto&& character : letter.second.second) - if (character != letter.first) - outer.insert(ymake_pair(character, targets->second)); + for (auto&& character : letter.second.second) + if (character != letter.first) + outer.insert(ymake_pair(character, targets->second)); } } - auto dest = m_transitions.begin() + oldsize; - for (auto outer = rhs.m_transitions.begin(), outerEnd = rhs.m_transitions.end(); outer != outerEnd; ++outer, ++dest) { - for (auto&& inner : *outer) { + auto dest = m_transitions.begin() + oldsize; + for (auto outer = rhs.m_transitions.begin(), outerEnd = rhs.m_transitions.end(); outer != outerEnd; ++outer, ++dest) { + for (auto&& inner : *outer) { TSet<size_t> targets; - std::transform(inner.second.begin(), inner.second.end(), std::inserter(targets, targets.begin()), + std::transform(inner.second.begin(), inner.second.end(), std::inserter(targets, targets.begin()), std::bind2nd(std::plus<size_t>(), oldsize)); - dest->insert(ymake_pair(inner.first, targets)); + dest->insert(ymake_pair(inner.first, targets)); } - for (auto&& letter : rhs.letters) { - auto targets = dest->find(letter.first); - if (targets == dest->end()) + for (auto&& letter : rhs.letters) { + auto targets = dest->find(letter.first); + if (targets == dest->end()) continue; - for (auto&& character : letter.second.second) - if (character != letter.first) - dest->insert(ymake_pair(character, targets->second)); + for (auto&& character : letter.second.second) + if (character != letter.first) + dest->insert(ymake_pair(character, targets->second)); } } // Import outputs - for (auto&& output : rhs.outputs) { - auto& dest = outputs[output.first + oldsize]; - for (auto&& element : output.second) - dest.insert(ymake_pair(element.first + oldsize, element.second)); + for (auto&& output : rhs.outputs) { + auto& dest = outputs[output.first + oldsize]; + for (auto&& element : output.second) + dest.insert(ymake_pair(element.first + oldsize, element.second)); } // Import tags - for (auto&& tag : rhs.tags) - tags.insert(ymake_pair(tag.first + oldsize, tag.second)); + for (auto&& tag : rhs.tags) + tags.insert(ymake_pair(tag.first + oldsize, tag.second)); letters = LettersTbl(LettersEquality(m_transitions)); } @@ -436,14 +436,14 @@ void Fsm::Connect(size_t from, size_t to, Char c /* = Epsilon */) void Fsm::ConnectFinal(size_t to, Char c /* = Epsilon */) { - for (auto&& final : m_final) - Connect(final, to, c); + for (auto&& final : m_final) + Connect(final, to, c); ClearHints(); } void Fsm::Disconnect(size_t from, size_t to, Char c) { - auto i = m_transitions[from].find(c); + auto i = m_transitions[from].find(c); if (i != m_transitions[from].end()) i->second.erase(to); ClearHints(); @@ -451,17 +451,17 @@ void Fsm::Disconnect(size_t from, size_t to, Char c) void Fsm::Disconnect(size_t from, size_t to) { - for (auto&& i : m_transitions[from]) - i.second.erase(to); + for (auto&& i : m_transitions[from]) + i.second.erase(to); ClearHints(); } unsigned long Fsm::Output(size_t from, size_t to) const { - auto i = outputs.find(from); + auto i = outputs.find(from); if (i == outputs.end()) return 0; - auto j = i->second.find(to); + auto j = i->second.find(to); if (j == i->second.end()) return 0; else @@ -475,20 +475,20 @@ Fsm& Fsm::operator += (const Fsm& rhs) const TransitionRow& row = m_transitions[lhsSize + rhs.initial]; - for (auto&& outer : row) - for (auto&& inner : outer.second) - ConnectFinal(inner, outer.first); + for (auto&& outer : row) + for (auto&& inner : outer.second) + ConnectFinal(inner, outer.first); - auto out = rhs.outputs.find(rhs.initial); + auto out = rhs.outputs.find(rhs.initial); if (out != rhs.outputs.end()) - for (auto&& toAndOutput : out->second) { - for (auto&& final : m_final) - outputs[final].insert(ymake_pair(toAndOutput.first + lhsSize, toAndOutput.second)); + for (auto&& toAndOutput : out->second) { + for (auto&& final : m_final) + outputs[final].insert(ymake_pair(toAndOutput.first + lhsSize, toAndOutput.second)); } ClearFinal(); - for (auto&& letter : rhs.m_final) - SetFinal(letter + lhsSize, true); + for (auto&& letter : rhs.m_final) + SetFinal(letter + lhsSize, true); determined = false; ClearHints(); @@ -502,8 +502,8 @@ Fsm& Fsm::operator |= (const Fsm& rhs) size_t lhsSize = Size(); Import(rhs); - for (auto&& final : rhs.m_final) - m_final.insert(final + lhsSize); + for (auto&& final : rhs.m_final) + m_final.insert(final + lhsSize); if (!isAlternative && !rhs.isAlternative) { Resize(Size() + 1); @@ -517,9 +517,9 @@ Fsm& Fsm::operator |= (const Fsm& rhs) initial = rhs.initial + lhsSize; } else if (isAlternative && rhs.isAlternative) { const StatesSet& tos = rhs.Destinations(rhs.initial, Epsilon); - for (auto&& to : tos) { - Connect(initial, to + lhsSize, Epsilon); - Disconnect(rhs.initial + lhsSize, to + lhsSize, Epsilon); + for (auto&& to : tos) { + Connect(initial, to + lhsSize, Epsilon); + Disconnect(rhs.initial + lhsSize, to + lhsSize, Epsilon); } } @@ -607,21 +607,21 @@ Fsm& Fsm::Reverse() // Invert transitions for (size_t from = 0; from < Size(); ++from) - for (auto&& i : m_transitions[from]) - for (auto&& j : i.second) - out.Connect(j, from, i.first); + for (auto&& i : m_transitions[from]) + for (auto&& j : i.second) + out.Connect(j, from, i.first); // Invert initial and final states out.m_final.clear(); out.SetFinal(initial, true); - for (auto i : m_final) - out.Connect(Size(), i, Epsilon); + for (auto i : m_final) + out.Connect(Size(), i, Epsilon); out.SetInitial(Size()); // Invert outputs - for (auto&& i : outputs) - for (auto&& j : i.second) - out.SetOutput(j.first, i.first, j.second); + for (auto&& i : outputs) + for (auto&& j : i.second) + out.SetOutput(j.first, i.first, j.second); // Preserve tags (although thier semantics are usually heavily broken at this point) out.tags = tags; @@ -633,60 +633,60 @@ Fsm& Fsm::Reverse() TSet<size_t> Fsm::DeadStates() const { - TSet<size_t> res; - - for (int invert = 0; invert <= 1; ++invert) { - Fsm digraph; - digraph.Resize(Size()); - for (TransitionTable::const_iterator j = m_transitions.begin(), je = m_transitions.end(); j != je; ++j) { - for (TransitionRow::const_iterator k = j->begin(), ke = j->end(); k != ke; ++k) { - for (StatesSet::const_iterator toSt = k->second.begin(), toSte = k->second.end(); toSt != toSte; ++toSt) { - // We only care if the states are connected or not regerdless through what letter - if (invert) { - // Build an FSM with inverted transitions - digraph.Connect(*toSt, j - m_transitions.begin(), 0); - } else { - digraph.Connect(j - m_transitions.begin(), *toSt, 0); - } - } + TSet<size_t> res; + + for (int invert = 0; invert <= 1; ++invert) { + Fsm digraph; + digraph.Resize(Size()); + for (TransitionTable::const_iterator j = m_transitions.begin(), je = m_transitions.end(); j != je; ++j) { + for (TransitionRow::const_iterator k = j->begin(), ke = j->end(); k != ke; ++k) { + for (StatesSet::const_iterator toSt = k->second.begin(), toSte = k->second.end(); toSt != toSte; ++toSt) { + // We only care if the states are connected or not regerdless through what letter + if (invert) { + // Build an FSM with inverted transitions + digraph.Connect(*toSt, j - m_transitions.begin(), 0); + } else { + digraph.Connect(j - m_transitions.begin(), *toSt, 0); + } + } } } - TVector<bool> unchecked(Size(), true); - TVector<bool> useless(Size(), true); - TDeque<size_t> queue; - - // Put all final (or initial) states into queue, marking them useful - for (size_t i = 0; i < Size(); ++i) - if ((invert && IsFinal(i)) || (!invert && Initial() == i)) { - useless[i] = false; - queue.push_back(i); - } - - // Do the breadth-first search, marking all states - // from which already marked states are reachable - while (!queue.empty()) { - size_t to = queue.front(); - queue.pop_front(); - - // All the states that are connected to this state in the transition matrix are useful - const StatesSet& connections = (digraph.m_transitions[to])[0]; - for (auto&& fr : connections) { - // Enqueue the state for further traversal if it hasnt been already checked - if (unchecked[fr] && useless[fr]) { - useless[fr] = false; - queue.push_back(fr); - } + TVector<bool> unchecked(Size(), true); + TVector<bool> useless(Size(), true); + TDeque<size_t> queue; + + // Put all final (or initial) states into queue, marking them useful + for (size_t i = 0; i < Size(); ++i) + if ((invert && IsFinal(i)) || (!invert && Initial() == i)) { + useless[i] = false; + queue.push_back(i); } - - // Now we consider this state checked - unchecked[to] = false; + + // Do the breadth-first search, marking all states + // from which already marked states are reachable + while (!queue.empty()) { + size_t to = queue.front(); + queue.pop_front(); + + // All the states that are connected to this state in the transition matrix are useful + const StatesSet& connections = (digraph.m_transitions[to])[0]; + for (auto&& fr : connections) { + // Enqueue the state for further traversal if it hasnt been already checked + if (unchecked[fr] && useless[fr]) { + useless[fr] = false; + queue.push_back(fr); + } + } + + // Now we consider this state checked + unchecked[to] = false; } - for (size_t i = 0; i < Size(); ++i) { - if (useless[i]) { - res.insert(i); - } + for (size_t i = 0; i < Size(); ++i) { + if (useless[i]) { + res.insert(i); + } } } @@ -699,12 +699,12 @@ void Fsm::RemoveDeadEnds() TSet<size_t> dead = DeadStates(); // Erase all useless states - for (auto&& i : dead) { - PIRE_IFDEBUG(Cdbg << "Removing useless state " << i << Endl); - m_transitions[i].clear(); - for (auto&& j : m_transitions) - for (auto&& k : j) - k.second.erase(i); + for (auto&& i : dead) { + PIRE_IFDEBUG(Cdbg << "Removing useless state " << i << Endl); + m_transitions[i].clear(); + for (auto&& j : m_transitions) + for (auto&& k : j) + k.second.erase(i); } ClearHints(); @@ -725,20 +725,20 @@ void Fsm::MergeEpsilonConnection(size_t from, size_t to) } // Merge transitions from 'to' state into transitions from 'from' state - for (auto&& transition : m_transitions[to]) { + for (auto&& transition : m_transitions[to]) { TSet<size_t> connStates; - std::copy(transition.second.begin(), transition.second.end(), - std::inserter(m_transitions[from][transition.first], m_transitions[from][transition.first].end())); + std::copy(transition.second.begin(), transition.second.end(), + std::inserter(m_transitions[from][transition.first], m_transitions[from][transition.first].end())); // If there is an output of the 'from'->'to' connection it has to be set to all // new connections that were merged from 'to' state if (fsEpsOutputExists) { // Compute the set of states that are reachable from 'to' state - std::copy(transition.second.begin(), transition.second.end(), std::inserter(connStates, connStates.end())); + std::copy(transition.second.begin(), transition.second.end(), std::inserter(connStates, connStates.end())); // For each of these states add an output equal to the Epsilon-connection output - for (auto&& newConnSt : connStates) { - outputs[from][newConnSt] |= frEpsOutput; + for (auto&& newConnSt : connStates) { + outputs[from][newConnSt] |= frEpsOutput; } } } @@ -748,16 +748,16 @@ void Fsm::MergeEpsilonConnection(size_t from, size_t to) SetFinal(from, true); // Combine tags - auto ti = tags.find(to); + auto ti = tags.find(to); if (ti != tags.end()) tags[from] |= ti->second; // Merge all 'to' into 'from' outputs: // outputs[from][i] |= (outputs[from][to] | outputs[to][i]) - auto toOit = outputs.find(to); + auto toOit = outputs.find(to); if (toOit != outputs.end()) { - for (auto&& output : toOit->second) { - outputs[from][output.first] |= (frEpsOutput | output.second); + for (auto&& output : toOit->second) { + outputs[from][output.first] |= (frEpsOutput | output.second); } } } @@ -772,12 +772,12 @@ void Fsm::ShortCutEpsilon(size_t from, size_t thru, TVector< TSet<size_t> >& inv const StatesSet& to = Destinations(thru, Epsilon); Outputs::iterator outIt = outputs.find(from); unsigned long fromThruOut = Output(from, thru); - for (auto&& toElement : to) { - PIRE_IFDEBUG(Cdbg << "Epsilon connecting " << from << " --> " << thru << " --> " << toElement << "\n"); - Connect(from, toElement, Epsilon); - inveps[toElement].insert(from); + for (auto&& toElement : to) { + PIRE_IFDEBUG(Cdbg << "Epsilon connecting " << from << " --> " << thru << " --> " << toElement << "\n"); + Connect(from, toElement, Epsilon); + inveps[toElement].insert(from); if (outIt != outputs.end()) - outIt->second[toElement] |= (fromThruOut | Output(thru, toElement)); + outIt->second[toElement] |= (fromThruOut | Output(thru, toElement)); } } @@ -791,33 +791,33 @@ void Fsm::RemoveEpsilons() TVector< TSet<size_t> > inveps(Size()); // We have to use TSet<> here since we want it sorted for (size_t from = 0; from != Size(); ++from) { const StatesSet& tos = Destinations(from, Epsilon); - for (auto&& to : tos) - inveps[to].insert(from); + for (auto&& to : tos) + inveps[to].insert(from); } // Make a transitive closure of all epsilon transitions (Floyd-Warshall algorithm) // (if there exists an epsilon-path between two states, epsilon-connect them directly) for (size_t thru = 0; thru != Size(); ++thru) - for (auto&& from : inveps[thru]) + for (auto&& from : inveps[thru]) // inveps[thru] may alter during loop body, hence we cannot cache ivneps[thru].end() - if (from != thru) - ShortCutEpsilon(from, thru, inveps); + if (from != thru) + ShortCutEpsilon(from, thru, inveps); PIRE_IFDEBUG(Cdbg << "=== After epsilons shortcut\n" << *this << Endl); // Iterate through all epsilon-connected state pairs, merging states together for (size_t from = 0; from != Size(); ++from) { const StatesSet& to = Destinations(from, Epsilon); - for (auto&& toElement : to) - if (toElement != from) - MergeEpsilonConnection(from, toElement); // it's a NOP if to == from, so don't waste time + for (auto&& toElement : to) + if (toElement != from) + MergeEpsilonConnection(from, toElement); // it's a NOP if to == from, so don't waste time } PIRE_IFDEBUG(Cdbg << "=== After epsilons merged\n" << *this << Endl); // Drop all epsilon transitions - for (auto&& i : m_transitions) - i.erase(Epsilon); + for (auto&& i : m_transitions) + i.erase(Epsilon); Sparse(); ClearHints(); @@ -825,12 +825,12 @@ void Fsm::RemoveEpsilons() bool Fsm::LettersEquality::operator()(Char a, Char b) const { - for (auto&& outer : *m_tbl) { - auto ia = outer.find(a); - auto ib = outer.find(b); - if (ia == outer.end() && ib == outer.end()) + for (auto&& outer : *m_tbl) { + auto ia = outer.find(a); + auto ib = outer.find(b); + if (ia == outer.end() && ib == outer.end()) continue; - else if (ia == outer.end() || ib == outer.end() || ia->second != ib->second) { + else if (ia == outer.end() || ib == outer.end() || ia->second != ib->second) { return false; } } @@ -850,10 +850,10 @@ void Fsm::Sparse(bool needEpsilons /* = false */) void Fsm::Unsparse() { - for (auto&& letter : letters) - for (auto&& i : m_transitions) - for (auto&& j : letter.second.second) - i[j] = i[letter.first]; + for (auto&& letter : letters) + for (auto&& i : m_transitions) + for (auto&& j : letter.second.second) + i[j] = i[letter.first]; m_sparsed = false; } @@ -862,14 +862,14 @@ void Fsm::Unsparse() TSet<size_t> Fsm::TerminalStates() const { TSet<size_t> terminals; - for (auto&& final : m_final) { + for (auto&& final : m_final) { bool ok = true; - for (auto&& letter : letters) { - auto dests = m_transitions[final].find(letter.first); - ok = ok && (dests != m_transitions[final].end() && dests->second.find(final) != dests->second.end()); + for (auto&& letter : letters) { + auto dests = m_transitions[final].find(letter.first); + ok = ok && (dests != m_transitions[final].end() && dests->second.find(final) != dests->second.end()); } if (ok) - terminals.insert(final); + terminals.insert(final); } return terminals; } @@ -892,8 +892,8 @@ public: State Initial() const { return State(1, mFsm.initial); } bool IsRequired(const State& state) const { - for (auto&& i : state) - if (mTerminals.find(i) != mTerminals.end()) + for (auto&& i : state) + if (mTerminals.find(i) != mTerminals.end()) return false; return true; } @@ -902,8 +902,8 @@ public: { State next; next.reserve(20); - for (auto&& from : state) { - const auto& part = mFsm.Destinations(from, letter); + for (auto&& from : state) { + const auto& part = mFsm.Destinations(from, letter); std::copy(part.begin(), part.end(), std::back_inserter(next)); } @@ -923,20 +923,20 @@ public: mNewFsm.m_final.clear(); for (size_t ns = 0; ns < states.size(); ++ns) { PIRE_IFDEBUG(Cdbg << "State " << ns << " = [" << Join(states[ns].begin(), states[ns].end(), ", ") << "]" << Endl); - for (auto&& j : states[ns]) { + for (auto&& j : states[ns]) { // If it was a terminal state, connect it to itself - if (mTerminals.find(j) != mTerminals.end()) { - for (auto&& letter : Letters()) - mNewFsm.Connect(ns, ns, letter.first); + if (mTerminals.find(j) != mTerminals.end()) { + for (auto&& letter : Letters()) + mNewFsm.Connect(ns, ns, letter.first); mNewTerminals.insert(ns); - PIRE_IFDEBUG(Cdbg << "State " << ns << " becomes terminal because of old state " << j << Endl); + PIRE_IFDEBUG(Cdbg << "State " << ns << " becomes terminal because of old state " << j << Endl); } } - for (auto&& j : states[ns]) { + for (auto&& j : states[ns]) { // If any state containing in our one is marked final, mark the new state final as well - if (mFsm.IsFinal(j)) { - PIRE_IFDEBUG(Cdbg << "State " << ns << " becomes final because of old state " << j << Endl); + if (mFsm.IsFinal(j)) { + PIRE_IFDEBUG(Cdbg << "State " << ns << " becomes final because of old state " << j << Endl); mNewFsm.SetFinal(ns, true); if (mFsm.tags.empty()) // Weve got no tags and already know that the state is final, @@ -945,9 +945,9 @@ public: } // Bitwise OR all tags in states - auto ti = mFsm.tags.find(j); + auto ti = mFsm.tags.find(j); if (ti != mFsm.tags.end()) { - PIRE_IFDEBUG(Cdbg << "State " << ns << " carries tag " << ti->second << " because of old state " << j << Endl); + PIRE_IFDEBUG(Cdbg << "State " << ns << " carries tag " << ti->second << " because of old state " << j << Endl); mNewFsm.tags[ns] |= ti->second; } } @@ -956,18 +956,18 @@ public: typedef TMap< size_t, TVector<size_t> > Old2New; Old2New old2new; for (size_t ns = 0; ns < states.size(); ++ns) - for (auto&& j : states[ns]) - old2new[j].push_back(ns); + for (auto&& j : states[ns]) + old2new[j].push_back(ns); // Copy all outputs - for (auto&& i : mFsm.outputs) { - for (auto&& j : i.second) { - auto from = old2new.find(i.first); - auto to = old2new.find(j.first); + for (auto&& i : mFsm.outputs) { + for (auto&& j : i.second) { + auto from = old2new.find(i.first); + auto to = old2new.find(j.first); if (from != old2new.end() && to != old2new.end()) { - for (auto&& k : from->second) - for (auto&& l : to->second) - mNewFsm.outputs[k][l] |= j.second; + for (auto&& k : from->second) + for (auto&& l : to->second) + mNewFsm.outputs[k][l] |= j.second; } } } @@ -987,13 +987,13 @@ public: // remove redundant outputs oldOutputs.swap(mNewFsm.outputs); for (size_t from = 0; from < mNewFsm.Size(); ++from) { - auto fromOutput = oldOutputs.find(from); + auto fromOutput = oldOutputs.find(from); if (fromOutput == oldOutputs.end()) continue; - const auto& newTransitionsRow = mNewFsm.m_transitions[from]; - for (auto&& row : newTransitionsRow) { - for (auto&& stateIt : row.second) { - auto toOutput = fromOutput->second.find(stateIt); + const auto& newTransitionsRow = mNewFsm.m_transitions[from]; + for (auto&& row : newTransitionsRow) { + for (auto&& stateIt : row.second) { + auto toOutput = fromOutput->second.find(stateIt); if (toOutput != fromOutput->second.end()) { mNewFsm.outputs[from].insert(*toOutput); } @@ -1098,11 +1098,11 @@ public: // Unite equality classes into new states size_t fromIdx = 0; - for (auto from = mFsm.m_transitions.begin(), fromEnd = mFsm.m_transitions.end(); from != fromEnd; ++from, ++fromIdx) { + for (auto from = mFsm.m_transitions.begin(), fromEnd = mFsm.m_transitions.end(); from != fromEnd; ++from, ++fromIdx) { size_t dest = StateClass[fromIdx]; PIRE_IFDEBUG(Cdbg << "[min] State " << fromIdx << " becomes state " << dest << Endl); - for (auto&& letter : *from) { - Y_ASSERT(letter.second.size() == 1 || !"FSM::minimize(): FSM not deterministic"); + for (auto&& letter : *from) { + Y_ASSERT(letter.second.size() == 1 || !"FSM::minimize(): FSM not deterministic"); mNewFsm.Connect(dest, StateClass[*letter.second.begin()], letter.first); } if (mFsm.IsFinal(fromIdx)) { @@ -1111,7 +1111,7 @@ public: } // Append tags - auto ti = mFsm.tags.find(fromIdx); + auto ti = mFsm.tags.find(fromIdx); if (ti != mFsm.tags.end()) { mNewFsm.tags[dest] |= ti->second; PIRE_IFDEBUG(Cdbg << "[min] New state " << dest << " carries tag " << ti->second << " because of old state " << fromIdx << Endl); @@ -1120,8 +1120,8 @@ public: mNewFsm.initial = StateClass[mFsm.initial]; // Restore outputs - for (auto&& output : mFsm.outputs) - for (auto&& output2 : output.second) + for (auto&& output : mFsm.outputs) + for (auto&& output2 : output.second) mNewFsm.outputs[StateClass[output.first]].insert(ymake_pair(StateClass[output2.first], output2.second)); } @@ -1209,9 +1209,9 @@ void Fsm::Divert(size_t from, size_t to, size_t dest) return; // Assign the output - auto oi = outputs.find(from); + auto oi = outputs.find(from); if (oi != outputs.end()) { - auto oi2 = oi->second.find(to); + auto oi2 = oi->second.find(to); if (oi2 != oi->second.end()) { unsigned long output = oi2->second; oi->second.erase(oi2); @@ -1220,11 +1220,11 @@ void Fsm::Divert(size_t from, size_t to, size_t dest) } // Assign the transition - for (auto&& i : m_transitions[from]) { - auto di = i.second.find(to); - if (di != i.second.end()) { - i.second.erase(di); - i.second.insert(dest); + for (auto&& i : m_transitions[from]) { + auto di = i.second.find(to); + if (di != i.second.end()) { + i.second.erase(di); + i.second.insert(dest); } } diff --git a/contrib/libs/pire/pire/fsm.h b/contrib/libs/pire/pire/fsm.h index f47ac26d7e..4dad06ca06 100644 --- a/contrib/libs/pire/pire/fsm.h +++ b/contrib/libs/pire/pire/fsm.h @@ -120,7 +120,7 @@ namespace Pire { Scanner Compile(size_t distance = 0); void DumpState(yostream& s, size_t state) const; - void DumpTo(yostream& s, const ystring& name = "") const; + void DumpTo(yostream& s, const ystring& name = "") const; typedef TSet<size_t> StatesSet; typedef TMap<size_t, StatesSet> TransitionRow; diff --git a/contrib/libs/pire/pire/glue.h b/contrib/libs/pire/pire/glue.h index c865d3fa96..bac086f2f0 100644 --- a/contrib/libs/pire/pire/glue.h +++ b/contrib/libs/pire/pire/glue.h @@ -66,27 +66,27 @@ public: , mFilled(N, false) {} - ~GluedStateLookupTable() = default; + ~GluedStateLookupTable() = default; const_iterator end() const { - return mMap.Get() + MaxSize; + return mMap.Get() + MaxSize; } // Note that in fact mMap is sparsed and traditional [begin,end) // traversal is unavailable; hence no begin() method here. // end() is only valid for comparing with find() result. const_iterator find(const key_type& st) const { size_t ind = Search(st); - return mFilled[ind] ? (mMap.Get() + ind) : end(); + return mFilled[ind] ? (mMap.Get() + ind) : end(); } ypair<iterator, bool> insert(const value_type& v) { size_t ind = Search(v.first); if (!mFilled[ind]) { - mMap[ind] = v; + mMap[ind] = v; mFilled[ind] = true; - return ymake_pair(mMap.Get() + ind, true); + return ymake_pair(mMap.Get() + ind, true); } else - return ymake_pair(mMap.Get() + ind, false); + return ymake_pair(mMap.Get() + ind, false); } private: @@ -104,7 +104,7 @@ private: return size_t((st.first >> 2) ^ (st.second >> 4) ^ (st.second << 10)); } - TArrayHolder<value_type> mMap; + TArrayHolder<value_type> mMap; TVector<bool> mFilled; // Noncopyable @@ -116,7 +116,7 @@ template<class Scanner> class ScannerGlueCommon { public: typedef Partition< Char, Impl::LettersEquality<Scanner> > LettersTbl; - + typedef ypair<typename Scanner::InternalState, typename Scanner::InternalState> State; ScannerGlueCommon(const Scanner& lhs, const Scanner& rhs, const LettersTbl& letters) : m_lhs(lhs) @@ -130,7 +130,7 @@ public: } const LettersTbl& Letters() const { return m_letters; } - + const Scanner& Lhs() const { return m_lhs; } const Scanner& Rhs() const { return m_rhs; } @@ -142,7 +142,7 @@ public: Rhs().Next(state.second, letter); return state; } - + bool IsRequired(const State& /*state*/) const { return true; } typedef Scanner Result; @@ -151,13 +151,13 @@ public: protected: Scanner& Sc() { return *m_result; } - void SetSc(THolder<Scanner>&& sc) { m_result = std::move(sc); } + void SetSc(THolder<Scanner>&& sc) { m_result = std::move(sc); } private: const Scanner& m_lhs; const Scanner& m_rhs; LettersTbl m_letters; - THolder<Scanner> m_result; + THolder<Scanner> m_result; }; } diff --git a/contrib/libs/pire/pire/inline.l b/contrib/libs/pire/pire/inline.l index f05b284187..a4d2e1a836 100644 --- a/contrib/libs/pire/pire/inline.l +++ b/contrib/libs/pire/pire/inline.l @@ -132,7 +132,7 @@ void eatComment(void (*action)(char)); bool first = true; Pire::Scanner sc; ystring pattern; - for (auto i = args.begin(), ie = args.end(); i != ie; i += 2) { + for (auto i = args.begin(), ie = args.end(); i != ie; i += 2) { Pire::Lexer lexer(i->c_str(), i->c_str() + i->size()); bool surround = false; @@ -189,7 +189,7 @@ void eatComment(void (*action)(char)); fprintf(yyout, "Pire::MmappedScanner<Pire::Scanner>(PIRE_LITERAL( // %s \n \"", pattern.c_str()); size_t pos = 5; - for (auto i = buf.Buffer().Begin(), ie = buf.Buffer().End(); i != ie; ++i) { + for (auto i = buf.Buffer().Begin(), ie = buf.Buffer().End(); i != ie; ++i) { pos += fprintf(yyout, "\\x%02X", static_cast<unsigned char>(*i)); if (pos >= 78) { fprintf(yyout, "\"\n \""); diff --git a/contrib/libs/pire/pire/partition.h b/contrib/libs/pire/pire/partition.h index bb3156c021..85a9af8863 100644 --- a/contrib/libs/pire/pire/partition.h +++ b/contrib/libs/pire/pire/partition.h @@ -56,15 +56,15 @@ public: ConstIterator Begin() const { return m_set.begin(); } - ConstIterator begin() const { - return m_set.begin(); - } + ConstIterator begin() const { + return m_set.begin(); + } ConstIterator End() const { return m_set.end(); } - ConstIterator end() const { - return m_set.end(); - } + ConstIterator end() const { + return m_set.end(); + } size_t Size() const { return m_set.size(); } @@ -77,7 +77,7 @@ public: /// - representative(a) is equivalent to a. const T& Representative(const T& t) const { - auto it = m_inv.find(t); + auto it = m_inv.find(t); if (it != m_inv.end()) return it->second; else @@ -94,10 +94,10 @@ public: /// - 0 <= index(a) < size(). size_t Index(const T& t) const { - auto it = m_inv.find(t); + auto it = m_inv.find(t); if (it == m_inv.end()) throw Error("Partition::index(): attempted to obtain an index of nonexistent item"); - auto it2 = m_set.find(it->second); + auto it2 = m_set.find(it->second); Y_ASSERT(it2 != m_set.end()); return it2->second.first; } @@ -105,10 +105,10 @@ public: /// is returned iff representative(i) == representative(t)). const TVector<T>& Klass(const T& t) const { - auto it = m_inv.find(t); + auto it = m_inv.find(t); if (it == m_inv.end()) throw Error("Partition::index(): attempted to obtain an index of nonexistent item"); - auto it2 = m_set.find(it->second); + auto it2 = m_set.find(it->second); Y_ASSERT(it2 != m_set.end()); return it2->second.second; } @@ -124,15 +124,15 @@ public: { m_eq = eq; - for (auto&& element : m_set) - if (element.second.second.size() > 1) { - TVector<T>& v = element.second.second; - auto bound = std::partition(v.begin(), v.end(), std::bind2nd(m_eq, v[0])); + for (auto&& element : m_set) + if (element.second.second.size() > 1) { + TVector<T>& v = element.second.second; + auto bound = std::partition(v.begin(), v.end(), std::bind2nd(m_eq, v[0])); if (bound == v.end()) continue; Set delta; - for (auto it = bound, ie = v.end(); it != ie; ++it) + for (auto it = bound, ie = v.end(); it != ie; ++it) DoAppend(delta, *it); v.erase(bound, v.end()); @@ -148,8 +148,8 @@ private: void DoAppend(Set& set, const T& t) { - auto it = set.begin(); - auto end = set.end(); + auto it = set.begin(); + auto end = set.end(); for (; it != end; ++it) if (m_eq(it->first, t)) { it->second.second.push_back(t); @@ -171,15 +171,15 @@ template<class T, class Eq> yostream& operator << (yostream& stream, const Partition<T, Eq>& partition) { stream << "Partition {\n"; - for (auto&& partitionElement : partition) { - stream << " Class " << partitionElement.second.first << " \"" << partitionElement.first << "\" { "; + for (auto&& partitionElement : partition) { + stream << " Class " << partitionElement.second.first << " \"" << partitionElement.first << "\" { "; bool first = false; - for (auto&& element : partitionElement.second.second) { + for (auto&& element : partitionElement.second.second) { if (first) stream << ", "; else first = true; - stream << element; + stream << element; } stream << " }\n"; } diff --git a/contrib/libs/pire/pire/re_lexer.cpp b/contrib/libs/pire/pire/re_lexer.cpp index 03a2d422db..132fbeb039 100644 --- a/contrib/libs/pire/pire/re_lexer.cpp +++ b/contrib/libs/pire/pire/re_lexer.cpp @@ -46,7 +46,7 @@ Term Term::Dot() { return Term(TokenTypes::Dot, DotTag()); } Term Term::BeginMark() { return Term(TokenTypes::BeginMark, BeginTag()); } Term Term::EndMark() { return Term(TokenTypes::EndMark, EndTag()); } -Lexer::~Lexer() = default; +Lexer::~Lexer() = default; wchar32 Lexer::GetChar() { @@ -81,29 +81,29 @@ void Lexer::UngetChar(wchar32 c) } namespace { - class CompareFeaturesByPriority: public ybinary_function<const Feature::Ptr&, const Feature::Ptr&, bool> { + class CompareFeaturesByPriority: public ybinary_function<const Feature::Ptr&, const Feature::Ptr&, bool> { public: - bool operator()(const Feature::Ptr& a, const Feature::Ptr& b) const + bool operator()(const Feature::Ptr& a, const Feature::Ptr& b) const { return a->Priority() < b->Priority(); } }; } -Lexer& Lexer::AddFeature(Feature::Ptr& feature) +Lexer& Lexer::AddFeature(Feature::Ptr& feature) { feature->m_lexer = this; - m_features.insert(LowerBound(m_features.begin(), m_features.end(), feature, CompareFeaturesByPriority()), std::move(feature)); + m_features.insert(LowerBound(m_features.begin(), m_features.end(), feature, CompareFeaturesByPriority()), std::move(feature)); + return *this; +} + +Lexer& Lexer::AddFeature(Feature::Ptr&& feature) +{ + feature->m_lexer = this; + m_features.insert(LowerBound(m_features.begin(), m_features.end(), feature, CompareFeaturesByPriority()), std::move(feature)); return *this; } -Lexer& Lexer::AddFeature(Feature::Ptr&& feature) -{ - feature->m_lexer = this; - m_features.insert(LowerBound(m_features.begin(), m_features.end(), feature, CompareFeaturesByPriority()), std::move(feature)); - return *this; -} - Term Lexer::DoLex() { static const char* controls = "|().*+?^$\\"; @@ -112,9 +112,9 @@ Term Lexer::DoLex() wchar32 ch = PeekChar(); if (ch == End) return Term(TokenTypes::End); - for (auto&& i : m_features) { - if (i->Accepts(ch)) { - Term ret = i->Lex(); + for (auto&& i : m_features) { + if (i->Accepts(ch)) { + Term ret = i->Lex(); if (ret.Type()) return ret; } @@ -150,15 +150,15 @@ Term Lexer::Lex() { Term t = DoLex(); - for (auto i = m_features.rbegin(), ie = m_features.rend(); i != ie; ++i) + for (auto i = m_features.rbegin(), ie = m_features.rend(); i != ie; ++i) (*i)->Alter(t); if (t.Value().IsA<Term::CharacterRange>()) { - const auto& chars = t.Value().As<Term::CharacterRange>(); + const auto& chars = t.Value().As<Term::CharacterRange>(); //std::cerr << "lex: type " << t.type() << "; chars = { " << join(chars.first.begin(), chars.first.end(), ", ") << " }" << std::endl; - for (auto&& i : chars.first) - for (auto&& j : i) - if ((j & ControlMask) == Control) + for (auto&& i : chars.first) + for (auto&& j : i) + if ((j & ControlMask) == Control) Error("Control character in tokens sequence"); } @@ -187,10 +187,10 @@ Term Lexer::Lex() type = 0; return Term(type, t.Value()); } - + void Lexer::Parenthesized(Fsm& fsm) { - for (auto i = m_features.rbegin(), ie = m_features.rend(); i != ie; ++i) + for (auto i = m_features.rbegin(), ie = m_features.rend(); i != ie; ++i) (*i)->Parenthesized(fsm); } @@ -330,12 +330,12 @@ namespace { typedef Term::CharacterRange::first_type CharSet; const CharSet& old = t.Value().As<Term::CharacterRange>().first; CharSet altered; - for (auto&& i : old) { - if (i.size() == 1) { - altered.insert(Term::String(1, to_upper(i[0]))); - altered.insert(Term::String(1, to_lower(i[0]))); + for (auto&& i : old) { + if (i.size() == 1) { + altered.insert(Term::String(1, to_upper(i[0]))); + altered.insert(Term::String(1, to_lower(i[0]))); } else - altered.insert(i); + altered.insert(i); } t = Term(t.Type(), Term::CharacterRange(altered, t.Value().As<Term::CharacterRange>().second)); } @@ -366,15 +366,15 @@ namespace { } namespace Features { - Feature::Ptr CaseInsensitive() { return Feature::Ptr(new CaseInsensitiveImpl); } - Feature::Ptr CharClasses(); - Feature::Ptr AndNotSupport() { return Feature::Ptr(new AndNotSupportImpl); } + Feature::Ptr CaseInsensitive() { return Feature::Ptr(new CaseInsensitiveImpl); } + Feature::Ptr CharClasses(); + Feature::Ptr AndNotSupport() { return Feature::Ptr(new AndNotSupportImpl); } }; void Lexer::InstallDefaultFeatures() { - AddFeature(Feature::Ptr(new CharacterRangeReader)); - AddFeature(Feature::Ptr(new RepetitionCountReader)); + AddFeature(Feature::Ptr(new CharacterRangeReader)); + AddFeature(Feature::Ptr(new RepetitionCountReader)); AddFeature(Features::CharClasses()); AddFeature(Feature::Ptr(new EnableUnicodeSequencesImpl)); } diff --git a/contrib/libs/pire/pire/re_lexer.h b/contrib/libs/pire/pire/re_lexer.h index f6bb234d4f..5591c16d34 100644 --- a/contrib/libs/pire/pire/re_lexer.h +++ b/contrib/libs/pire/pire/re_lexer.h @@ -143,9 +143,9 @@ public: /// The main lexer function. Extracts and returns the next term in input sequence. Term Lex(); /// Installs an additional lexer feature. - /// We declare both lvalue and rvalue reference types to fix some linker errors. - Lexer& AddFeature(THolder<Feature>& a); - Lexer& AddFeature(THolder<Feature>&& a); + /// We declare both lvalue and rvalue reference types to fix some linker errors. + Lexer& AddFeature(THolder<Feature>& a); + Lexer& AddFeature(THolder<Feature>&& a); const Pire::Encoding& Encoding() const { return *m_encoding; } Lexer& SetEncoding(const Pire::Encoding& encoding) { m_encoding = &encoding; return *this; } @@ -172,7 +172,7 @@ private: TDeque<wchar32> m_input; const Pire::Encoding* m_encoding; - TVector<THolder<Feature>> m_features; + TVector<THolder<Feature>> m_features; Any m_retval; ystring errmsg; @@ -188,7 +188,7 @@ private: */ class Feature { public: - /// Precedence of features. The less the priority, the earlier + /// Precedence of features. The less the priority, the earlier /// will Lex() be called, and the later will Alter() and Parenthesized() be called. virtual int Priority() const { return 50; } @@ -208,10 +208,10 @@ public: /// those perl-style (?@#$%:..) clauses). virtual void Parenthesized(Fsm&) {} - using Ptr = THolder<Feature>; + using Ptr = THolder<Feature>; + + virtual ~Feature() = default; - virtual ~Feature() = default; - protected: // These functions are exposed versions of the corresponding lexer functions. @@ -229,14 +229,14 @@ private: namespace Features { /// Disables case sensitivity - Feature::Ptr CaseInsensitive(); + Feature::Ptr CaseInsensitive(); /** * Adds two more operations: * (pattern1)&(pattern2) -- matches those strings which match both /pattern1/ and /pattern2/; * ~(pattern) -- matches those strings which do not match /pattern/. */ - Feature::Ptr AndNotSupport(); + Feature::Ptr AndNotSupport(); } } diff --git a/contrib/libs/pire/pire/re_parser.y b/contrib/libs/pire/pire/re_parser.y index ea8e778f02..dbad88e287 100644 --- a/contrib/libs/pire/pire/re_parser.y +++ b/contrib/libs/pire/pire/re_parser.y @@ -180,15 +180,15 @@ void AppendRange(const Encoding& encoding, Fsm& a, const Term::CharacterRange& c { TVector<ystring> strings; - for (auto&& i : cr.first) { + for (auto&& i : cr.first) { ystring s; - for (auto&& j : i) { - ystring c = encoding.ToLocal(j); + for (auto&& j : i) { + ystring c = encoding.ToLocal(j); if (c.empty()) { s.clear(); break; } else - s += encoding.ToLocal(j); + s += encoding.ToLocal(j); } if (!s.empty()) strings.push_back(s); diff --git a/contrib/libs/pire/pire/run.h b/contrib/libs/pire/pire/run.h index bfc5611a72..f6e1ff734d 100644 --- a/contrib/libs/pire/pire/run.h +++ b/contrib/libs/pire/pire/run.h @@ -187,20 +187,20 @@ namespace Impl { /// The main function: runs a scanner through given memory range. template<class Scanner, class Pred> - inline void DoRun(const Scanner& scanner, typename Scanner::State& st, TStringBuf str, Pred pred) + inline void DoRun(const Scanner& scanner, typename Scanner::State& st, TStringBuf str, Pred pred) { - const size_t* head = reinterpret_cast<const size_t*>((reinterpret_cast<uintptr_t>(str.begin())) & ~(sizeof(size_t)-1)); - const size_t* tail = reinterpret_cast<const size_t*>((reinterpret_cast<uintptr_t>(str.end())) & ~(sizeof(size_t)-1)); + const size_t* head = reinterpret_cast<const size_t*>((reinterpret_cast<uintptr_t>(str.begin())) & ~(sizeof(size_t)-1)); + const size_t* tail = reinterpret_cast<const size_t*>((reinterpret_cast<uintptr_t>(str.end())) & ~(sizeof(size_t)-1)); size_t headSize = (sizeof(size_t) - (str.begin() - (const char*)head)); // The distance from @p begin to the end of the word containing @p begin - size_t tailSize = str.end() - (const char*) tail; // The distance from the beginning of the word containing @p end to the @p end + size_t tailSize = str.end() - (const char*) tail; // The distance from the beginning of the word containing @p end to the @p end - Y_ASSERT(headSize >= 1 && headSize <= sizeof(size_t)); - Y_ASSERT(tailSize < sizeof(size_t)); + Y_ASSERT(headSize >= 1 && headSize <= sizeof(size_t)); + Y_ASSERT(tailSize < sizeof(size_t)); if (head == tail) { - Impl::SafeRunChunk(scanner, st, head, sizeof(size_t) - headSize, str.end() - str.begin(), pred); + Impl::SafeRunChunk(scanner, st, head, sizeof(size_t) - headSize, str.end() - str.begin(), pred); return; } @@ -209,8 +209,8 @@ namespace Impl { // compiler to store it in a register. This saves some instructions and cycles typename Scanner::State state = st; - if (str.begin() != (const char*) head) { - if (Impl::RunChunk(scanner, state, head, sizeof(size_t) - headSize, headSize, pred) == Stop) { + if (str.begin() != (const char*) head) { + if (Impl::RunChunk(scanner, state, head, sizeof(size_t) - headSize, headSize, pred) == Stop) { st = state; return; } @@ -233,12 +233,12 @@ namespace Impl { /// Runs two scanners through given memory range simultaneously. /// This is several percent faster than running them independently. template<class Scanner1, class Scanner2> -inline void Run(const Scanner1& scanner1, const Scanner2& scanner2, typename Scanner1::State& state1, typename Scanner2::State& state2, TStringBuf str) +inline void Run(const Scanner1& scanner1, const Scanner2& scanner2, typename Scanner1::State& state1, typename Scanner2::State& state2, TStringBuf str) { typedef ScannerPair<Scanner1, Scanner2> Scanners; Scanners pair(scanner1, scanner2); typename Scanners::State states(state1, state2); - Run(pair, states, str); + Run(pair, states, str); state1 = states.first; state2 = states.second; } @@ -272,15 +272,15 @@ namespace Impl { #endif template<class Scanner> -void Run(const Scanner& sc, typename Scanner::State& st, TStringBuf str) -{ - Impl::DoRun(sc, st, str, Impl::RunPred<Scanner>()); -} - -template<class Scanner> +void Run(const Scanner& sc, typename Scanner::State& st, TStringBuf str) +{ + Impl::DoRun(sc, st, str, Impl::RunPred<Scanner>()); +} + +template<class Scanner> void Run(const Scanner& sc, typename Scanner::State& st, const char* begin, const char* end) { - Run(sc, st, TStringBuf(begin, end)); + Run(sc, st, TStringBuf(begin, end)); } /// Returns default constructed string_view{} if there is no matching prefix @@ -293,7 +293,7 @@ std::string_view LongestPrefix(const Scanner& sc, std::string_view str, bool thr if (throughBeginMark) Pire::Step(sc, st, BeginMark); const char* pos = (sc.Final(st) ? str.data() : nullptr); - Impl::DoRun(sc, st, str, Impl::LongestPrefixPred<Scanner>(pos)); + Impl::DoRun(sc, st, str, Impl::LongestPrefixPred<Scanner>(pos)); if (throughEndMark) { Pire::Step(sc, st, EndMark); if (sc.Final(st)) @@ -303,17 +303,17 @@ std::string_view LongestPrefix(const Scanner& sc, std::string_view str, bool thr } template<class Scanner> -const char* LongestPrefix(const Scanner& sc, const char* begin, const char* end, bool throughBeginMark = false, bool throughEndMark = false) +const char* LongestPrefix(const Scanner& sc, const char* begin, const char* end, bool throughBeginMark = false, bool throughEndMark = false) { auto prefix = LongestPrefix(sc, std::string_view(begin, end - begin), throughBeginMark, throughEndMark); return prefix.data() + prefix.size(); -} - +} + /// Returns default constructed string_view{} if there is no matching prefix /// Returns str.substr(0, 0) if matching prefix is empty -template<class Scanner> +template<class Scanner> std::string_view ShortestPrefix(const Scanner& sc, std::string_view str, bool throughBeginMark = false, bool throughEndMark = false) -{ +{ typename Scanner::State st; sc.Initialize(st); if (throughBeginMark) @@ -321,7 +321,7 @@ std::string_view ShortestPrefix(const Scanner& sc, std::string_view str, bool th if (sc.Final(st)) return str.substr(0, 0); const char* pos = nullptr; - Impl::DoRun(sc, st, str, Impl::ShortestPrefixPred<Scanner>(pos)); + Impl::DoRun(sc, st, str, Impl::ShortestPrefixPred<Scanner>(pos)); if (throughEndMark) { Pire::Step(sc, st, EndMark); if (sc.Final(st) && !pos) @@ -330,13 +330,13 @@ std::string_view ShortestPrefix(const Scanner& sc, std::string_view str, bool th return pos ? str.substr(0, pos - str.data()) : std::string_view{}; } -template<class Scanner> -const char* ShortestPrefix(const Scanner& sc, const char* begin, const char* end, bool throughBeginMark = false, bool throughEndMark = false) -{ +template<class Scanner> +const char* ShortestPrefix(const Scanner& sc, const char* begin, const char* end, bool throughBeginMark = false, bool throughEndMark = false) +{ auto prefix = ShortestPrefix(sc, std::string_view(begin, end - begin), throughBeginMark, throughEndMark); return prefix.data() + prefix.size(); -} - +} + /// The same as above, but scans string in reverse direction /// (consider using Fsm::Reverse() for using in this function). @@ -349,7 +349,7 @@ inline std::string_view LongestSuffix(const Scanner& scanner, std::string_view s scanner.Initialize(state); if (throughEndMark) Step(scanner, state, EndMark); - PIRE_IFDEBUG(Cdbg << "Running LongestSuffix on string " << ystring(str) << Endl); + PIRE_IFDEBUG(Cdbg << "Running LongestSuffix on string " << ystring(str) << Endl); PIRE_IFDEBUG(Cdbg << "Initial state " << StDump(scanner, state) << Endl); std::string_view suffix{}; @@ -371,12 +371,12 @@ inline std::string_view LongestSuffix(const Scanner& scanner, std::string_view s return suffix; } -template<class Scanner> -inline const char* LongestSuffix(const Scanner& scanner, const char* rbegin, const char* rend, bool throughEndMark = false, bool throughBeginMark = false) { +template<class Scanner> +inline const char* LongestSuffix(const Scanner& scanner, const char* rbegin, const char* rend, bool throughEndMark = false, bool throughBeginMark = false) { auto suffix = LongestSuffix(scanner, std::string_view(rend + 1, rbegin - rend), throughEndMark, throughBeginMark); return suffix.data() ? suffix.data() - 1 : nullptr; -} - +} + /// The same as above, but scans string in reverse direction /// Returns default constructed string_view{} if there is no matching suffix /// Returns str.substr(str.size(), 0) if matching suffix is empty @@ -388,7 +388,7 @@ inline std::string_view ShortestSuffix(const Scanner& scanner, std::string_view scanner.Initialize(state); if (throughEndMark) Step(scanner, state, EndMark); - PIRE_IFDEBUG(Cdbg << "Running ShortestSuffix on string " << ystring(str) << Endl); + PIRE_IFDEBUG(Cdbg << "Running ShortestSuffix on string " << ystring(str) << Endl); PIRE_IFDEBUG(Cdbg << "Initial state " << StDump(scanner, state) << Endl); while (begin != str.data() && !scanner.Final(state) && !scanner.Dead(state)) { @@ -401,13 +401,13 @@ inline std::string_view ShortestSuffix(const Scanner& scanner, std::string_view return scanner.Final(state) ? str.substr(begin - str.data()) : std::string_view{}; } -template<class Scanner> -inline const char* ShortestSuffix(const Scanner& scanner, const char* rbegin, const char* rend, bool throughEndMark = false, bool throughBeginMark = false) { +template<class Scanner> +inline const char* ShortestSuffix(const Scanner& scanner, const char* rbegin, const char* rend, bool throughEndMark = false, bool throughBeginMark = false) { auto suffix = ShortestSuffix(scanner, std::string_view(rend + 1, rbegin - rend), throughEndMark, throughBeginMark); return suffix.data() ? suffix.data() - 1 : nullptr; -} +} + - template<class Scanner> class RunHelper { public: @@ -415,9 +415,9 @@ public: explicit RunHelper(const Scanner& sc): Sc(&sc) { Sc->Initialize(St); } RunHelper<Scanner>& Step(Char letter) { Pire::Step(*Sc, St, letter); return *this; } - RunHelper<Scanner>& Run(TStringBuf str) { Pire::Run(*Sc, St, str); return *this; } - RunHelper<Scanner>& Run(const char* begin, const char* end) { return Run(TStringBuf(begin, end)); } - RunHelper<Scanner>& Run(const char* begin, size_t size) { return Run(TStringBuf(begin, begin + size)); } + RunHelper<Scanner>& Run(TStringBuf str) { Pire::Run(*Sc, St, str); return *this; } + RunHelper<Scanner>& Run(const char* begin, const char* end) { return Run(TStringBuf(begin, end)); } + RunHelper<Scanner>& Run(const char* begin, size_t size) { return Run(TStringBuf(begin, begin + size)); } RunHelper<Scanner>& Begin() { return Step(BeginMark); } RunHelper<Scanner>& End() { return Step(EndMark); } @@ -440,15 +440,15 @@ RunHelper<Scanner> Runner(const Scanner& sc, typename Scanner::State st) { retur /// Provided for testing purposes and convinience template<class Scanner> -bool Matches(const Scanner& scanner, TStringBuf str) -{ - return Runner(scanner).Run(str); -} - -template<class Scanner> +bool Matches(const Scanner& scanner, TStringBuf str) +{ + return Runner(scanner).Run(str); +} + +template<class Scanner> bool Matches(const Scanner& scanner, const char* begin, const char* end) { - return Runner(scanner).Run(TStringBuf(begin, end)); + return Runner(scanner).Run(TStringBuf(begin, end)); } /// Constructs an inline scanner in one statement diff --git a/contrib/libs/pire/pire/scanner_io.cpp b/contrib/libs/pire/pire/scanner_io.cpp index 15cc291568..3956e3c6ed 100644 --- a/contrib/libs/pire/pire/scanner_io.cpp +++ b/contrib/libs/pire/pire/scanner_io.cpp @@ -44,7 +44,7 @@ void SimpleScanner::Save(yostream* s) const Impl::AlignSave(s, sizeof(Empty())); if (!Empty()) { Y_ASSERT(m_buffer); - Impl::AlignedSaveArray(s, m_buffer.Get(), BufSize()); + Impl::AlignedSaveArray(s, m_buffer.Get(), BufSize()); } } @@ -60,9 +60,9 @@ void SimpleScanner::Load(yistream* s) if (empty) { sc.Alias(Null()); } else { - sc.m_buffer = BufferType(new char[sc.BufSize()]); - Impl::AlignedLoadArray(s, sc.m_buffer.Get(), sc.BufSize()); - sc.Markup(sc.m_buffer.Get()); + sc.m_buffer = BufferType(new char[sc.BufSize()]); + Impl::AlignedLoadArray(s, sc.m_buffer.Get(), sc.BufSize()); + sc.Markup(sc.m_buffer.Get()); sc.m.initial += reinterpret_cast<size_t>(sc.m_transitions); } Swap(sc); @@ -83,18 +83,18 @@ void SlowScanner::Save(yostream* s) const size_t c = 0; SavePodType<size_t>(s, 0); - for (auto&& i : m_vec) { - size_t n = c + i.size(); + for (auto&& i : m_vec) { + size_t n = c + i.size(); SavePodType(s, n); c = n; } Impl::AlignSave(s, (m_vec.size() + 1) * sizeof(size_t)); size_t size = 0; - for (auto&& i : m_vec) - if (!i.empty()) { - SavePodArray(s, &(i)[0], i.size()); - size += sizeof(unsigned) * i.size(); + for (auto&& i : m_vec) + if (!i.empty()) { + SavePodArray(s, &(i)[0], i.size()); + size += sizeof(unsigned) * i.size(); } Impl::AlignSave(s, size); if (need_actions) { @@ -135,11 +135,11 @@ void SlowScanner::Load(yistream* s) size_t c; LoadPodType(s, c); - auto act = sc.m_actionsvec.begin(); - for (auto&& i : sc.m_vec) { + auto act = sc.m_actionsvec.begin(); + for (auto&& i : sc.m_vec) { size_t n; LoadPodType(s, n); - i.resize(n - c); + i.resize(n - c); if (sc.need_actions) { act->resize(n - c); ++act; @@ -149,18 +149,18 @@ void SlowScanner::Load(yistream* s) Impl::AlignLoad(s, (m_vec.size() + 1) * sizeof(size_t)); size_t size = 0; - for (auto&& i : sc.m_vec) - if (!i.empty()) { - LoadPodArray(s, &(i)[0], i.size()); - size += sizeof(unsigned) * i.size(); + for (auto&& i : sc.m_vec) + if (!i.empty()) { + LoadPodArray(s, &(i)[0], i.size()); + size += sizeof(unsigned) * i.size(); } Impl::AlignLoad(s, size); size_t actSize = 0; if (sc.need_actions) { - for (auto&& i : sc.m_actionsvec) { - if (!i.empty()) { - LoadPodArray(s, &(i)[0], i.size()); - actSize += sizeof(Action) * i.size(); + for (auto&& i : sc.m_actionsvec) { + if (!i.empty()) { + LoadPodArray(s, &(i)[0], i.size()); + actSize += sizeof(Action) * i.size(); } } Impl::AlignLoad(s, actSize); @@ -201,8 +201,8 @@ void LoadedScanner::Load(yistream* s, ui32* type) } LoadPodType(s, sc.m); Impl::AlignLoad(s, sizeof(sc.m)); - sc.m_buffer = BufferType(new char[sc.BufSize()]); - sc.Markup(sc.m_buffer.Get()); + sc.m_buffer = BufferType(new char[sc.BufSize()]); + sc.Markup(sc.m_buffer.Get()); Impl::AlignedLoadArray(s, sc.m_letters, MaxChar); Impl::AlignedLoadArray(s, sc.m_jumps, sc.m.statesCount * sc.m.lettersCount); if (header.Version == Header::RE_VERSION_WITH_MACTIONS) { diff --git a/contrib/libs/pire/pire/scanners/loaded.h b/contrib/libs/pire/pire/scanners/loaded.h index 0659c4c7f7..120dc403b7 100644 --- a/contrib/libs/pire/pire/scanners/loaded.h +++ b/contrib/libs/pire/pire/scanners/loaded.h @@ -81,9 +81,9 @@ protected: LoadedScanner(const LoadedScanner& s): m(s.m) { if (s.m_buffer) { - m_buffer = BufferType(new char [BufSize()]); - memcpy(m_buffer.Get(), s.m_buffer.Get(), BufSize()); - Markup(m_buffer.Get()); + m_buffer = BufferType(new char [BufSize()]); + memcpy(m_buffer.Get(), s.m_buffer.Get(), BufSize()); + Markup(m_buffer.Get()); m.initial = (InternalState)m_jumps + (s.m.initial - (InternalState)s.m_jumps); } else { Alias(s); @@ -163,17 +163,17 @@ public: m.statesCount = states; m.lettersCount = letters.Size(); m.regexpsCount = regexpsCount; - m_buffer = BufferType(new char[BufSize()]); - memset(m_buffer.Get(), 0, BufSize()); - Markup(m_buffer.Get()); + m_buffer = BufferType(new char[BufSize()]); + memset(m_buffer.Get(), 0, BufSize()); + Markup(m_buffer.Get()); m.initial = reinterpret_cast<size_t>(m_jumps + startState * m.lettersCount); // Build letter translation table Fill(m_letters, m_letters + MaxChar, 0); - for (auto&& letter : letters) - for (auto&& character : letter.second.second) - m_letters[character] = letter.second.first; + for (auto&& letter : letters) + for (auto&& character : letter.second.second) + m_letters[character] = letter.second.first; } size_t StateSize() const @@ -235,8 +235,8 @@ protected: size_t initial; } m; - using BufferType = TArrayHolder<char>; - BufferType m_buffer; + using BufferType = TArrayHolder<char>; + BufferType m_buffer; Letter* m_letters; Transition* m_jumps; @@ -286,7 +286,7 @@ private: friend class Fsm; }; -inline LoadedScanner::~LoadedScanner() = default; +inline LoadedScanner::~LoadedScanner() = default; } diff --git a/contrib/libs/pire/pire/scanners/multi.h b/contrib/libs/pire/pire/scanners/multi.h index c9bf21fcff..29679e416e 100644 --- a/contrib/libs/pire/pire/scanners/multi.h +++ b/contrib/libs/pire/pire/scanners/multi.h @@ -194,7 +194,7 @@ public: void TakeAction(State&, Action) const {} - Scanner(const Scanner& s): m(s.m) + Scanner(const Scanner& s): m(s.m) { if (!s.m_buffer) { // Empty or mmap()-ed scanner @@ -212,7 +212,7 @@ public: } template<class AnotherRelocation> - Scanner(const Scanner<AnotherRelocation, Shortcutting>& s) + Scanner(const Scanner<AnotherRelocation, Shortcutting>& s) { if (s.Empty()) Alias(Null()); @@ -323,8 +323,8 @@ protected: size_t shortcuttingSignature; } m; - using BufferType = TArrayHolder<char>; - BufferType m_buffer; + using BufferType = TArrayHolder<char>; + BufferType m_buffer; Letter* m_letters; size_t* m_final; @@ -356,9 +356,9 @@ protected: m.regexpsCount = regexpsCount; m.finalTableSize = finalStatesCount + states; - m_buffer = BufferType(new char[BufSize() + sizeof(size_t)]); - memset(m_buffer.Get(), 0, BufSize() + sizeof(size_t)); - Markup(AlignUp(m_buffer.Get(), sizeof(size_t))); + m_buffer = BufferType(new char[BufSize() + sizeof(size_t)]); + memset(m_buffer.Get(), 0, BufSize() + sizeof(size_t)); + Markup(AlignUp(m_buffer.Get(), sizeof(size_t))); for (size_t i = 0; i != Size(); ++i) Header(IndexToState(i)) = ScannerRowHeader(); @@ -366,9 +366,9 @@ protected: m.initial = reinterpret_cast<size_t>(m_transitions + startState * RowSize()); // Build letter translation table - for (auto&& letter : letters) - for (auto&& character : letter.second.second) - m_letters[character] = letter.second.first + HEADER_SIZE; + for (auto&& letter : letters) + for (auto&& character : letter.second.second) + m_letters[character] = letter.second.first + HEADER_SIZE; } /* @@ -388,7 +388,7 @@ protected: void Alias(const Scanner<Relocation, Shortcutting>& s) { memcpy(&m, &s.m, sizeof(m)); - m_buffer.Reset(); + m_buffer.Reset(); m_letters = s.m_letters; m_final = s.m_final; m_finalIndex = s.m_finalIndex; @@ -399,16 +399,16 @@ protected: void DeepCopy(const Scanner<AnotherRelocation, Shortcutting>& s) { // Don't want memory leaks, but we cannot free the buffer because there might be aliased instances - Y_ASSERT(m_buffer == nullptr); + Y_ASSERT(m_buffer == nullptr); // Ensure that specializations of Scanner across different Relocations do not touch its Locals static_assert(sizeof(m) == sizeof(s.m), "sizeof(m) == sizeof(s.m)"); memcpy(&m, &s.m, sizeof(s.m)); m.relocationSignature = Relocation::Signature; m.shortcuttingSignature = Shortcutting::Signature; - m_buffer = BufferType(new char[BufSize() + sizeof(size_t)]); + m_buffer = BufferType(new char[BufSize() + sizeof(size_t)]); std::memset(m_buffer.Get(), 0, BufSize() + sizeof(size_t)); - Markup(AlignUp(m_buffer.Get(), sizeof(size_t))); + Markup(AlignUp(m_buffer.Get(), sizeof(size_t))); // Values in letter-to-leterclass table take into account row header size for (size_t c = 0; c < MaxChar; ++c) { @@ -493,8 +493,8 @@ protected: if (ind + letters[let].size() > Shortcutting::ExitMaskCount) break; // For each character setup a mask - for (auto&& character : letters[let]) { - Shortcutting::SetMask(header, ind, character); + for (auto&& character : letters[let]) { + Shortcutting::SetMask(header, ind, character); ++ind; } } @@ -565,7 +565,7 @@ struct ScannerSaver { SavePodType(s, scanner.Empty()); Impl::AlignSave(s, sizeof(scanner.Empty())); if (!scanner.Empty()) - Impl::AlignedSaveArray(s, scanner.m_buffer.Get(), scanner.BufSize()); + Impl::AlignedSaveArray(s, scanner.m_buffer.Get(), scanner.BufSize()); } template<class Shortcutting> @@ -586,9 +586,9 @@ struct ScannerSaver { if (empty) { sc.Alias(ScannerType::Null()); } else { - sc.m_buffer = TArrayHolder<char>(new char[sc.BufSize()]); - Impl::AlignedLoadArray(s, sc.m_buffer.Get(), sc.BufSize()); - sc.Markup(sc.m_buffer.Get()); + sc.m_buffer = TArrayHolder<char>(new char[sc.BufSize()]); + Impl::AlignedLoadArray(s, sc.m_buffer.Get(), sc.BufSize()); + sc.Markup(sc.m_buffer.Get()); sc.m.initial += reinterpret_cast<size_t>(sc.m_transitions); } scanner.Swap(sc); @@ -1017,9 +1017,9 @@ public: // 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)); + 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; diff --git a/contrib/libs/pire/pire/scanners/simple.h b/contrib/libs/pire/pire/scanners/simple.h index 019ecd859c..ef959aeed1 100644 --- a/contrib/libs/pire/pire/scanners/simple.h +++ b/contrib/libs/pire/pire/scanners/simple.h @@ -89,9 +89,9 @@ public: m_transitions = s.m_transitions; } else { // In-memory scanner, perform deep copy - m_buffer = BufferType(new char[BufSize()]); - memcpy(m_buffer.Get(), s.m_buffer.Get(), BufSize()); - Markup(m_buffer.Get()); + m_buffer = BufferType(new char[BufSize()]); + memcpy(m_buffer.Get(), s.m_buffer.Get(), BufSize()); + Markup(m_buffer.Get()); m.initial += (m_transitions - s.m_transitions) * sizeof(Transition); } @@ -102,7 +102,7 @@ public: void Alias(const SimpleScanner& s) { m = s.m; - m_buffer.Reset(); + m_buffer.Reset(); m_transitions = s.m_transitions; } @@ -116,7 +116,7 @@ public: SimpleScanner& operator = (const SimpleScanner& s) { SimpleScanner(s).Swap(*this); return *this; } - ~SimpleScanner() = default; + ~SimpleScanner() = default; /* * Constructs the scanner from mmap()-ed memory range, returning a pointer @@ -174,8 +174,8 @@ protected: size_t initial; } m; - using BufferType = TArrayHolder<char>; - BufferType m_buffer; + using BufferType = TArrayHolder<char>; + BufferType m_buffer; Transition* m_transitions; @@ -237,21 +237,21 @@ inline SimpleScanner::SimpleScanner(Fsm& fsm, size_t distance) fsm.Canonize(); m.statesCount = fsm.Size(); - m_buffer = BufferType(new char[BufSize()]); - memset(m_buffer.Get(), 0, BufSize()); - Markup(m_buffer.Get()); + m_buffer = BufferType(new char[BufSize()]); + memset(m_buffer.Get(), 0, BufSize()); + Markup(m_buffer.Get()); m.initial = reinterpret_cast<size_t>(m_transitions + fsm.Initial() * STATE_ROW_SIZE + 1); for (size_t state = 0; state < fsm.Size(); ++state) SetTag(state, fsm.Tag(state) | (fsm.IsFinal(state) ? 1 : 0)); for (size_t from = 0; from != fsm.Size(); ++from) - for (auto&& i : fsm.Letters()) { - const auto& tos = fsm.Destinations(from, i.first); + for (auto&& i : fsm.Letters()) { + const auto& tos = fsm.Destinations(from, i.first); if (tos.empty()) continue; - for (auto&& l : i.second.second) - for (auto&& to : tos) - SetJump(from, l, to); + for (auto&& l : i.second.second) + for (auto&& to : tos) + SetJump(from, l, to); } } diff --git a/contrib/libs/pire/pire/scanners/slow.h b/contrib/libs/pire/pire/scanners/slow.h index 4b18869c34..6adfcb8c1d 100644 --- a/contrib/libs/pire/pire/scanners/slow.h +++ b/contrib/libs/pire/pire/scanners/slow.h @@ -105,15 +105,15 @@ public: { next.flags.Clear(); next.states.clear(); - for (auto&& state : current.states) { + for (auto&& state : current.states) { const unsigned* begin = 0; const unsigned* end = 0; if (!m_vecptr) { - const size_t* pos = m_jumpPos + state * m.lettersCount + l; + const size_t* pos = m_jumpPos + state * m.lettersCount + l; begin = m_jumps + pos[0]; end = m_jumps + pos[1]; } else { - const auto& v = (*m_vecptr)[state * m.lettersCount + l]; + const auto& v = (*m_vecptr)[state * m.lettersCount + l]; if (!v.empty()) { begin = &v[0]; end = &v[0] + v.size(); @@ -152,8 +152,8 @@ public: bool Final(const State& s) const { - for (auto&& state : s.states) - if (m_finals[state]) + for (auto&& state : s.states) + if (m_finals[state]) return true; return false; } @@ -275,9 +275,9 @@ public: // Build letter translation table Fill(m_letters, m_letters + MaxChar, 0); - for (auto&& letter : fsm.Letters()) - for (auto&& character : letter.second.second) - m_letters[character] = letter.second.first; + for (auto&& letter : fsm.Letters()) + for (auto&& character : letter.second.second) + m_letters[character] = letter.second.first; m.start = fsm.Initial(); BuildScanner(fsm, *this); @@ -288,8 +288,8 @@ public: ~SlowScanner() { - for (auto&& i : m_pool) - free(i); + for (auto&& i : m_pool) + free(i); } void Save(yostream*) const; @@ -431,7 +431,7 @@ inline const SlowScanner& SlowScanner::Null() /// A specialization of Run(), since its state is much heavier than other ones /// and we thus want to avoid copying states. template<> -inline void Run<SlowScanner>(const SlowScanner& scanner, SlowScanner::State& state, TStringBuf str) +inline void Run<SlowScanner>(const SlowScanner& scanner, SlowScanner::State& state, TStringBuf str) { SlowScanner::State temp; scanner.Initialize(temp); @@ -439,8 +439,8 @@ inline void Run<SlowScanner>(const SlowScanner& scanner, SlowScanner::State& sta SlowScanner::State* src = &state; SlowScanner::State* dest = &temp; - for (auto it = str.begin(); it != str.end(); ++it) { - scanner.Next(*src, *dest, static_cast<unsigned char>(*it)); + for (auto it = str.begin(); it != str.end(); ++it) { + scanner.Next(*src, *dest, static_cast<unsigned char>(*it)); DoSwap(src, dest); } if (src != &state) |