aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/pire
diff options
context:
space:
mode:
authorbnagaev <bnagaev@yandex-team.ru>2022-02-10 16:47:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:04 +0300
commitc74559fb88da8adac0d9186cfa55a6b13c47695f (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /contrib/libs/pire
parentd6449ba66291ff0c0d352c82e6eb3efb4c8a7e8d (diff)
downloadydb-c74559fb88da8adac0d9186cfa55a6b13c47695f.tar.gz
Restoring authorship annotation for <bnagaev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/pire')
-rw-r--r--contrib/libs/pire/pire/extra/capture.h30
-rw-r--r--contrib/libs/pire/pire/extra/count.cpp6
-rw-r--r--contrib/libs/pire/pire/extra/count.h176
-rw-r--r--contrib/libs/pire/pire/fsm.cpp2
-rw-r--r--contrib/libs/pire/pire/fsm.h4
-rw-r--r--contrib/libs/pire/pire/platform.h8
-rw-r--r--contrib/libs/pire/pire/re_lexer.h8
-rw-r--r--contrib/libs/pire/pire/re_parser.y40
-rw-r--r--contrib/libs/pire/pire/run.h52
-rw-r--r--contrib/libs/pire/pire/scanner_io.cpp6
-rw-r--r--contrib/libs/pire/pire/scanners/common.h14
-rw-r--r--contrib/libs/pire/pire/scanners/loaded.h62
-rw-r--r--contrib/libs/pire/pire/scanners/multi.h58
-rw-r--r--contrib/libs/pire/pire/scanners/slow.h36
14 files changed, 251 insertions, 251 deletions
diff --git a/contrib/libs/pire/pire/extra/capture.h b/contrib/libs/pire/pire/extra/capture.h
index e69b922edf..8399914a67 100644
--- a/contrib/libs/pire/pire/extra/capture.h
+++ b/contrib/libs/pire/pire/extra/capture.h
@@ -103,23 +103,23 @@ public:
}
}
- Char Translate(Char ch) const
- {
- return m_letters[static_cast<size_t>(ch)];
- }
-
- Action NextTranslated(State& s, unsigned char c) const
- {
- Transition x = reinterpret_cast<const Transition*>(s.m_state)[c];
- s.m_state += SignExtend(x.shift);
- ++s.m_counter;
-
- return x.action;
- }
-
+ Char Translate(Char ch) const
+ {
+ return m_letters[static_cast<size_t>(ch)];
+ }
+
+ Action NextTranslated(State& s, unsigned char c) const
+ {
+ Transition x = reinterpret_cast<const Transition*>(s.m_state)[c];
+ s.m_state += SignExtend(x.shift);
+ ++s.m_counter;
+
+ return x.action;
+ }
+
Action Next(State& s, Char c) const
{
- return NextTranslated(s, Translate(c));
+ return NextTranslated(s, Translate(c));
}
Action Next(const State& current, State& n, Char c) const
diff --git a/contrib/libs/pire/pire/extra/count.cpp b/contrib/libs/pire/pire/extra/count.cpp
index 5b677666ae..468ff61d92 100644
--- a/contrib/libs/pire/pire/extra/count.cpp
+++ b/contrib/libs/pire/pire/extra/count.cpp
@@ -912,10 +912,10 @@ protected:
TVector<State> States;
TAction Action(const Scanner& sc, InternalState state, Char letter) const
{
- size_t state_index = sc.StateIdx(state);
- size_t transition_index = sc.TransitionIndex(state_index, letter);
+ size_t state_index = sc.StateIdx(state);
+ size_t transition_index = sc.TransitionIndex(state_index, letter);
const auto& tr = sc.m_jumps[transition_index];
- return tr.action;
+ return tr.action;
}
};
diff --git a/contrib/libs/pire/pire/extra/count.h b/contrib/libs/pire/pire/extra/count.h
index 35c3d24aa7..bd1526b98d 100644
--- a/contrib/libs/pire/pire/extra/count.h
+++ b/contrib/libs/pire/pire/extra/count.h
@@ -45,71 +45,71 @@ namespace Impl {
AdvancedScanner MakeAdvancedCountingScanner(const Fsm& re, const Fsm& sep, bool* simple);
};
-template<size_t I>
-class IncrementPerformer {
-public:
- template<typename State, typename Action>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Do(State& s, Action mask)
- {
- if (mask & (1 << (I - 1))) {
- Increment(s);
- }
- IncrementPerformer<I - 1>::Do(s, mask);
- }
-
-private:
- template<typename State>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Increment(State& s)
- {
- ++s.m_current[I - 1];
- }
-};
-
-template<>
-class IncrementPerformer<0> {
-public:
- template<typename State, typename Action>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Do(State&, Action)
- {
- }
-};
-
-template<size_t I>
-class ResetPerformer {
-public:
- template<typename State, typename Action>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Do(State& s, Action mask)
- {
- if (mask & (1 << (LoadedScanner::MAX_RE_COUNT + (I - 1))) && s.m_current[I - 1]) {
- Reset(s);
- }
- ResetPerformer<I - 1>::Do(s, mask);
- }
-
-private:
- template<typename State>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Reset(State& s)
- {
- s.m_total[I - 1] = ymax(s.m_total[I - 1], s.m_current[I - 1]);
- s.m_current[I - 1] = 0;
- }
-};
-
-template<>
-class ResetPerformer<0> {
-public:
- template<typename State, typename Action>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- static void Do(State&, Action)
- {
- }
-};
-
+template<size_t I>
+class IncrementPerformer {
+public:
+ template<typename State, typename Action>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Do(State& s, Action mask)
+ {
+ if (mask & (1 << (I - 1))) {
+ Increment(s);
+ }
+ IncrementPerformer<I - 1>::Do(s, mask);
+ }
+
+private:
+ template<typename State>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Increment(State& s)
+ {
+ ++s.m_current[I - 1];
+ }
+};
+
+template<>
+class IncrementPerformer<0> {
+public:
+ template<typename State, typename Action>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Do(State&, Action)
+ {
+ }
+};
+
+template<size_t I>
+class ResetPerformer {
+public:
+ template<typename State, typename Action>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Do(State& s, Action mask)
+ {
+ if (mask & (1 << (LoadedScanner::MAX_RE_COUNT + (I - 1))) && s.m_current[I - 1]) {
+ Reset(s);
+ }
+ ResetPerformer<I - 1>::Do(s, mask);
+ }
+
+private:
+ template<typename State>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Reset(State& s)
+ {
+ s.m_total[I - 1] = ymax(s.m_total[I - 1], s.m_current[I - 1]);
+ s.m_current[I - 1] = 0;
+ }
+};
+
+template<>
+class ResetPerformer<0> {
+public:
+ template<typename State, typename Action>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static void Do(State&, Action)
+ {
+ }
+};
+
/**
* A scanner which counts occurences of the
* given regexp separated by another regexp
@@ -134,29 +134,29 @@ public:
state.m_updatedMask = 0;
}
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- void TakeAction(State& s, Action a) const
- {
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ void TakeAction(State& s, Action a) const
+ {
static_cast<const DerivedScanner*>(this)->template TakeActionImpl<MAX_RE_COUNT>(s, a);
- }
-
+ }
+
bool CanStop(const State&) const { return false; }
- Char Translate(Char ch) const
- {
- return m_letters[static_cast<size_t>(ch)];
- }
-
- Action NextTranslated(State& s, Char c) const
- {
- Transition x = reinterpret_cast<const Transition*>(s.m_state)[c];
- s.m_state += SignExtend(x.shift);
- return x.action;
- }
-
+ Char Translate(Char ch) const
+ {
+ return m_letters[static_cast<size_t>(ch)];
+ }
+
+ Action NextTranslated(State& s, Char c) const
+ {
+ Transition x = reinterpret_cast<const Transition*>(s.m_state)[c];
+ s.m_state += SignExtend(x.shift);
+ return x.action;
+ }
+
Action Next(State& s, Char c) const
{
- return NextTranslated(s, Translate(c));
+ return NextTranslated(s, Translate(c));
}
Action Next(const State& current, State& n, Char c) const
@@ -177,28 +177,28 @@ protected:
using LoadedScanner::Init;
using LoadedScanner::InternalState;
- template<size_t ActualReCount>
+ template<size_t ActualReCount>
void PerformIncrement(State& s, Action mask) const
{
if (mask) {
- IncrementPerformer<ActualReCount>::Do(s, mask);
+ IncrementPerformer<ActualReCount>::Do(s, mask);
s.m_updatedMask |= ((size_t)mask) << MAX_RE_COUNT;
}
}
- template<size_t ActualReCount>
+ template<size_t ActualReCount>
void PerformReset(State& s, Action mask) const
{
mask &= s.m_updatedMask;
if (mask) {
- ResetPerformer<ActualReCount>::Do(s, mask);
+ ResetPerformer<ActualReCount>::Do(s, mask);
s.m_updatedMask &= (Action)~mask;
}
}
void Next(InternalState& s, Char c) const
{
- Transition x = reinterpret_cast<const Transition*>(s)[Translate(c)];
+ Transition x = reinterpret_cast<const Transition*>(s)[Translate(c)];
s += SignExtend(x.shift);
}
};
diff --git a/contrib/libs/pire/pire/fsm.cpp b/contrib/libs/pire/pire/fsm.cpp
index 1f153d448a..984d708dfa 100644
--- a/contrib/libs/pire/pire/fsm.cpp
+++ b/contrib/libs/pire/pire/fsm.cpp
@@ -574,7 +574,7 @@ Fsm& Fsm::Complement()
return *this;
}
-Fsm Fsm::operator *(size_t count) const
+Fsm Fsm::operator *(size_t count) const
{
Fsm ret;
while (count--)
diff --git a/contrib/libs/pire/pire/fsm.h b/contrib/libs/pire/pire/fsm.h
index 7c11ea43c3..4dad06ca06 100644
--- a/contrib/libs/pire/pire/fsm.h
+++ b/contrib/libs/pire/pire/fsm.h
@@ -81,7 +81,7 @@ namespace Pire {
Fsm operator & (const Fsm& rhs) const { Fsm a(*this); return a &= rhs; }
Fsm operator * () const { Fsm a(*this); return a.Iterate(); }
Fsm operator ~ () const { Fsm a(*this); return a.Complement(); }
- Fsm operator * (size_t count) const;
+ Fsm operator * (size_t count) const;
// === Raw FSM construction ===
@@ -94,7 +94,7 @@ namespace Pire {
/// Completely removes given transition
void Disconnect(size_t from, size_t to);
- /// Creates an FSM which matches any prefix of any word current FSM matches.
+ /// Creates an FSM which matches any prefix of any word current FSM matches.
void MakePrefix();
/// Creates an FSM which matches any suffix of any word current FSM matches.
diff --git a/contrib/libs/pire/pire/platform.h b/contrib/libs/pire/pire/platform.h
index 2f35e192ed..54ded6b387 100644
--- a/contrib/libs/pire/pire/platform.h
+++ b/contrib/libs/pire/pire/platform.h
@@ -26,13 +26,13 @@
#include <contrib/libs/pire/pire/stub/defaults.h>
#include <contrib/libs/pire/pire/static_assert.h>
-#ifndef PIRE_FORCED_INLINE
+#ifndef PIRE_FORCED_INLINE
#ifdef __GNUC__
-#define PIRE_FORCED_INLINE inline __attribute__((__always_inline__))
+#define PIRE_FORCED_INLINE inline __attribute__((__always_inline__))
#elif _MSC_VER
-#define PIRE_FORCED_INLINE __forceinline
+#define PIRE_FORCED_INLINE __forceinline
#else
-#define PIRE_FORCED_INLINE inline
+#define PIRE_FORCED_INLINE inline
#endif
#endif
diff --git a/contrib/libs/pire/pire/re_lexer.h b/contrib/libs/pire/pire/re_lexer.h
index da32fe6963..5591c16d34 100644
--- a/contrib/libs/pire/pire/re_lexer.h
+++ b/contrib/libs/pire/pire/re_lexer.h
@@ -149,9 +149,9 @@ public:
const Pire::Encoding& Encoding() const { return *m_encoding; }
Lexer& SetEncoding(const Pire::Encoding& encoding) { m_encoding = &encoding; return *this; }
- void SetError(const char* msg) { errmsg = msg; }
- void SetError(ystring msg) { errmsg = msg; }
- ystring& GetError() { return errmsg; }
+ void SetError(const char* msg) { errmsg = msg; }
+ void SetError(ystring msg) { errmsg = msg; }
+ ystring& GetError() { return errmsg; }
Any& Retval() { return m_retval; }
@@ -174,7 +174,7 @@ private:
const Pire::Encoding* m_encoding;
TVector<THolder<Feature>> m_features;
Any m_retval;
- ystring errmsg;
+ ystring errmsg;
friend class Feature;
diff --git a/contrib/libs/pire/pire/re_parser.y b/contrib/libs/pire/pire/re_parser.y
index 0663d73c01..dbad88e287 100644
--- a/contrib/libs/pire/pire/re_parser.y
+++ b/contrib/libs/pire/pire/re_parser.y
@@ -157,23 +157,23 @@ term
int yylex(YYSTYPE* lval, Pire::Lexer& rlex)
{
- try {
- Pire::Term term = rlex.Lex();
- if (!term.Value().Empty())
- *lval = new Any(term.Value());
+ try {
+ Pire::Term term = rlex.Lex();
+ if (!term.Value().Empty())
+ *lval = new Any(term.Value());
else
*lval = nullptr;
- return term.Type();
- } catch (Pire::Error &e) {
- rlex.SetError(e.what());
- return 0;
- }
+ return term.Type();
+ } catch (Pire::Error &e) {
+ rlex.SetError(e.what());
+ return 0;
+ }
}
-void yyerror(Pire::Lexer& rlex, const char* str)
+void yyerror(Pire::Lexer& rlex, const char* str)
{
- if (rlex.GetError().length() == 0)
- rlex.SetError(ystring("Regexp parse error: ").append(str));
+ if (rlex.GetError().length() == 0)
+ rlex.SetError(ystring("Regexp parse error: ").append(str));
}
void AppendRange(const Encoding& encoding, Fsm& a, const Term::CharacterRange& cr)
@@ -235,13 +235,13 @@ Fsm& ConvertToFSM(const Encoding& encoding, Any* any)
namespace Pire {
namespace Impl {
- int yre_parse(Pire::Lexer& rlex)
- {
- int rc = yyparse(rlex);
-
- if (rlex.GetError().length() != 0)
- throw Error(rlex.GetError());
- return rc;
- }
+ int yre_parse(Pire::Lexer& rlex)
+ {
+ int rc = yyparse(rlex);
+
+ if (rlex.GetError().length() != 0)
+ throw Error(rlex.GetError());
+ return rc;
+ }
}
}
diff --git a/contrib/libs/pire/pire/run.h b/contrib/libs/pire/pire/run.h
index 434ef0851e..f6e1ff734d 100644
--- a/contrib/libs/pire/pire/run.h
+++ b/contrib/libs/pire/pire/run.h
@@ -51,7 +51,7 @@ namespace Pire {
namespace Pire {
template<class Scanner>
-PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
void Step(const Scanner& scanner, typename Scanner::State& state, Char ch)
{
Y_ASSERT(ch < MaxCharUnaligned);
@@ -65,7 +65,7 @@ namespace Impl {
template<class Scanner>
struct RunPred {
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action operator()(const Scanner&, const typename Scanner::State&, const char*) const { return Continue; }
};
@@ -73,7 +73,7 @@ namespace Impl {
struct ShortestPrefixPred {
explicit ShortestPrefixPred(const char*& pos): m_pos(&pos) {}
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action operator()(const Scanner& sc, const typename Scanner::State& st, const char* pos) const
{
if (sc.Final(st)) {
@@ -91,7 +91,7 @@ namespace Impl {
struct LongestPrefixPred {
explicit LongestPrefixPred(const char*& pos): m_pos(&pos) {}
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action operator()(const Scanner& sc, const typename Scanner::State& st, const char* pos) const
{
if (sc.Final(st))
@@ -108,37 +108,37 @@ namespace Impl {
namespace Impl {
- template<class Scanner, class Pred>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
- Action SafeRunChunk(const Scanner& scanner, typename Scanner::State& state, const size_t* p, size_t pos, size_t size, Pred pred)
- {
+ template<class Scanner, class Pred>
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ Action SafeRunChunk(const Scanner& scanner, typename Scanner::State& state, const size_t* p, size_t pos, size_t size, Pred pred)
+ {
Y_ASSERT(pos <= sizeof(size_t));
Y_ASSERT(size <= sizeof(size_t));
Y_ASSERT(pos + size <= sizeof(size_t));
-
- if (PIRE_UNLIKELY(size == 0))
- return Continue;
-
- const char* ptr = (const char*) p + pos;
- for (; size--; ++ptr) {
- Step(scanner, state, (unsigned char) *ptr);
- if (pred(scanner, state, ptr + 1) == Stop)
- return Stop;
- }
- return Continue;
- }
-
+
+ if (PIRE_UNLIKELY(size == 0))
+ return Continue;
+
+ const char* ptr = (const char*) p + pos;
+ for (; size--; ++ptr) {
+ Step(scanner, state, (unsigned char) *ptr);
+ if (pred(scanner, state, ptr + 1) == Stop)
+ return Stop;
+ }
+ return Continue;
+ }
+
/// Effectively runs a scanner on a short data chunk, fit completely into one machine word.
template<class Scanner, class Pred>
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action RunChunk(const Scanner& scanner, typename Scanner::State& state, const size_t* p, size_t pos, size_t size, Pred pred)
{
Y_ASSERT(pos <= sizeof(size_t));
Y_ASSERT(size <= sizeof(size_t));
Y_ASSERT(pos + size <= sizeof(size_t));
- if (PIRE_UNLIKELY(size == 0))
- return Continue;
+ if (PIRE_UNLIKELY(size == 0))
+ return Continue;
size_t chunk = Impl::ToLittleEndian(*p) >> 8*pos;
const char* ptr = (const char*) p + pos + size + 1;
@@ -151,7 +151,7 @@ namespace Impl {
}
return Continue;
}
-
+
template<class Scanner>
struct AlignedRunner {
@@ -223,7 +223,7 @@ namespace Impl {
}
if (tailSize)
- Impl::SafeRunChunk(scanner, state, tail, 0, tailSize, pred);
+ Impl::SafeRunChunk(scanner, state, tail, 0, tailSize, pred);
st = state;
}
diff --git a/contrib/libs/pire/pire/scanner_io.cpp b/contrib/libs/pire/pire/scanner_io.cpp
index 353c80bae7..3956e3c6ed 100644
--- a/contrib/libs/pire/pire/scanner_io.cpp
+++ b/contrib/libs/pire/pire/scanner_io.cpp
@@ -205,10 +205,10 @@ void LoadedScanner::Load(yistream* s, ui32* type)
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) {
+ if (header.Version == Header::RE_VERSION_WITH_MACTIONS) {
TVector<Action> actions(sc.m.statesCount * sc.m.lettersCount);
- Impl::AlignedLoadArray(s, actions.data(), actions.size());
- }
+ Impl::AlignedLoadArray(s, actions.data(), actions.size());
+ }
Impl::AlignedLoadArray(s, sc.m_tags, sc.m.statesCount);
sc.m.initial += reinterpret_cast<size_t>(sc.m_jumps);
Swap(sc);
diff --git a/contrib/libs/pire/pire/scanners/common.h b/contrib/libs/pire/pire/scanners/common.h
index ad89ab76da..de5ea0af7b 100644
--- a/contrib/libs/pire/pire/scanners/common.h
+++ b/contrib/libs/pire/pire/scanners/common.h
@@ -50,8 +50,8 @@ namespace Pire {
ui32 HdrSize;
static const ui32 MAGIC = 0x45524950; // "PIRE" on litte-endian
- static const ui32 RE_VERSION = 7; // Should be incremented each time when the format of serialized scanner changes
- static const ui32 RE_VERSION_WITH_MACTIONS = 6; // LoadedScanner with m_actions, which is ignored
+ static const ui32 RE_VERSION = 7; // Should be incremented each time when the format of serialized scanner changes
+ static const ui32 RE_VERSION_WITH_MACTIONS = 6; // LoadedScanner with m_actions, which is ignored
explicit Header(ui32 type, size_t hdrsize)
: Magic(MAGIC)
@@ -66,7 +66,7 @@ namespace Pire {
{
if (Magic != MAGIC || PtrSize != sizeof(void*) || MaxWordSize != sizeof(Impl::MaxSizeWord))
throw Error("Serialized regexp incompatible with your system");
- if (Version != RE_VERSION && Version != RE_VERSION_WITH_MACTIONS)
+ if (Version != RE_VERSION && Version != RE_VERSION_WITH_MACTIONS)
throw Error("You are trying to used an incompatible version of a serialized regexp");
if (type != ScannerIOTypes::NoScanner && type != Type &&
!(type == ScannerIOTypes::LoadedScanner && Type == ScannerIOTypes::NoGlueLimitCountingScanner)) {
@@ -101,21 +101,21 @@ namespace Pire {
throw Error("Tried to mmap scanner at misaligned address");
}
- inline Header ValidateHeader(const size_t*& ptr, size_t& size, ui32 type, size_t hdrsize)
+ inline Header ValidateHeader(const size_t*& ptr, size_t& size, ui32 type, size_t hdrsize)
{
const Header* hdr;
MapPtr(hdr, 1, ptr, size);
hdr->Validate(type, hdrsize);
- return *hdr;
+ return *hdr;
}
- inline Header ValidateHeader(yistream* s, ui32 type, size_t hdrsize)
+ inline Header ValidateHeader(yistream* s, ui32 type, size_t hdrsize)
{
Header hdr(ScannerIOTypes::NoScanner, 0);
LoadPodType(s, hdr);
AlignLoad(s, sizeof(hdr));
hdr.Validate(type, hdrsize);
- return hdr;
+ return hdr;
}
}
}
diff --git a/contrib/libs/pire/pire/scanners/loaded.h b/contrib/libs/pire/pire/scanners/loaded.h
index f77c87cf1d..120dc403b7 100644
--- a/contrib/libs/pire/pire/scanners/loaded.h
+++ b/contrib/libs/pire/pire/scanners/loaded.h
@@ -73,8 +73,8 @@ public:
DeadFlag = 0
};
- static const size_t MAX_RE_COUNT = 16;
-
+ static const size_t MAX_RE_COUNT = 16;
+
protected:
LoadedScanner() { Alias(Null()); }
@@ -118,8 +118,8 @@ public:
size_t RegexpsCount() const { return Empty() ? 0 : m.regexpsCount; }
- size_t LettersCount() const { return m.lettersCount; }
-
+ size_t LettersCount() const { return m.lettersCount; }
+
const void* Mmap(const void* ptr, size_t size) {
return Mmap(ptr, size, nullptr);
}
@@ -140,10 +140,10 @@ public:
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) {
- Action* actions = 0;
- Impl::MapPtr(actions, s.m.statesCount * s.m.lettersCount, p, size);
- }
+ if (header.Version == Header::RE_VERSION_WITH_MACTIONS) {
+ Action* actions = 0;
+ 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);
@@ -176,27 +176,27 @@ public:
m_letters[character] = letter.second.first;
}
- size_t StateSize() const
- {
- return m.lettersCount * sizeof(*m_jumps);
- }
+ size_t StateSize() const
+ {
+ return m.lettersCount * sizeof(*m_jumps);
+ }
+
+ size_t TransitionIndex(size_t state, Char c) const
+ {
+ return state * m.lettersCount + m_letters[c];
+ }
- size_t TransitionIndex(size_t state, Char c) const
- {
- return state * m.lettersCount + m_letters[c];
- }
-
void SetJump(size_t oldState, Char c, size_t newState, Action action)
{
Y_ASSERT(m_buffer);
Y_ASSERT(oldState < m.statesCount);
Y_ASSERT(newState < m.statesCount);
- size_t shift = (newState - oldState) * StateSize();
+ size_t shift = (newState - oldState) * StateSize();
Transition tr;
tr.shift = (ui32)shift;
tr.action = action;
- m_jumps[TransitionIndex(oldState, c)] = tr;
+ m_jumps[TransitionIndex(oldState, c)] = tr;
}
Action RemapAction(Action action) { return action; }
@@ -212,19 +212,19 @@ public:
i64 SignExtend(i32 i) const { return i; }
- size_t BufSize() const
- {
- return
- MaxChar * sizeof(*m_letters)
- + m.statesCount * StateSize()
- + m.statesCount * sizeof(*m_tags)
- ;
- }
-
+ size_t BufSize() const
+ {
+ return
+ MaxChar * sizeof(*m_letters)
+ + m.statesCount * StateSize()
+ + m.statesCount * sizeof(*m_tags)
+ ;
+ }
+
protected:
- static const Action IncrementMask = (1 << MAX_RE_COUNT) - 1;
- static const Action ResetMask = IncrementMask << MAX_RE_COUNT;
+ static const Action IncrementMask = (1 << MAX_RE_COUNT) - 1;
+ static const Action ResetMask = IncrementMask << MAX_RE_COUNT;
// TODO: maybe, put fields in private section and provide data accessors
@@ -265,7 +265,7 @@ private:
{
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);
+ m_tags = reinterpret_cast<Tag*>(m_jumps + m.statesCount * m.lettersCount);
}
void Alias(const LoadedScanner& s)
diff --git a/contrib/libs/pire/pire/scanners/multi.h b/contrib/libs/pire/pire/scanners/multi.h
index 3762e1e29a..29679e416e 100644
--- a/contrib/libs/pire/pire/scanners/multi.h
+++ b/contrib/libs/pire/pire/scanners/multi.h
@@ -161,21 +161,21 @@ public:
/// Returns an initial state for this scanner
void Initialize(State& state) const { state = m.initial; }
- Char Translate(Char ch) const
+ Char Translate(Char ch) const
+ {
+ return m_letters[static_cast<size_t>(ch)];
+ }
+
+ /// Handles one letter
+ Action NextTranslated(State& state, Char letter) const
{
- return m_letters[static_cast<size_t>(ch)];
- }
-
- /// Handles one letter
- Action NextTranslated(State& state, Char letter) const
- {
PIRE_IFDEBUG(
Y_ASSERT(state >= (size_t)m_transitions);
Y_ASSERT(state < (size_t)(m_transitions + RowSize()*Size()));
Y_ASSERT((state - (size_t)m_transitions) % (RowSize()*sizeof(Transition)) == 0);
);
- state = Relocation::Go(state, reinterpret_cast<const Transition*>(state)[letter]);
+ state = Relocation::Go(state, reinterpret_cast<const Transition*>(state)[letter]);
PIRE_IFDEBUG(
Y_ASSERT(state >= (size_t)m_transitions);
@@ -186,12 +186,12 @@ public:
return 0;
}
- /// Handles one character
- Action Next(State& state, Char c) const
- {
- return NextTranslated(state, Translate(c));
- }
-
+ /// Handles one character
+ Action Next(State& state, Char c) const
+ {
+ return NextTranslated(state, Translate(c));
+ }
+
void TakeAction(State&, Action) const {}
Scanner(const Scanner& s): m(s.m)
@@ -636,7 +636,7 @@ private:
template<class ScannerRowHeader, unsigned N>
struct MaskCheckerBase {
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool Check(const ScannerRowHeader& hdr, size_t alignOffset, Word chunk)
{
Word mask = CheckBytes(hdr.Mask(N, alignOffset), chunk);
@@ -646,7 +646,7 @@ private:
return !IsAnySet(mask);
}
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
const Word* DoRun(const ScannerRowHeader& hdr, size_t alignOffset, const Word* begin, const Word* end)
{
for (; begin != end && Check(hdr, alignOffset, ToLittleEndian(*begin)); ++begin) {}
@@ -659,7 +659,7 @@ private:
typedef MaskCheckerBase<ScannerRowHeader, N> Base;
typedef MaskChecker<ScannerRowHeader, N+1, Nmax> Next;
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
const Word* Run(const ScannerRowHeader& hdr, size_t alignOffset, const Word* begin, const Word* end)
{
if (hdr.Mask(N) == hdr.Mask(N + 1))
@@ -673,7 +673,7 @@ private:
struct MaskChecker<ScannerRowHeader, N, N> : MaskCheckerBase<ScannerRowHeader, N> {
typedef MaskCheckerBase<ScannerRowHeader, N> Base;
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ 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);
@@ -682,7 +682,7 @@ private:
// Compares the ExitMask[0] value without SSE reads which seems to be more optimal
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool CheckFirstMask(const Scanner<Relocation, ExitMasks<MaskCount> >& scanner, typename Scanner<Relocation, ExitMasks<MaskCount> >::State state, size_t val)
{
return (scanner.Header(state).Mask(0) == val);
@@ -717,7 +717,7 @@ public:
return *p;
}
- PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
size_t Mask(size_t i) const
{
Y_ASSERT(i < ExitMaskCount);
@@ -791,21 +791,21 @@ public:
}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool NoExit(const Scanner<Relocation, ExitMasks<MaskCount> >& scanner, typename Scanner<Relocation, ExitMasks<MaskCount> >::State state)
{
return CheckFirstMask(scanner, state, NO_EXIT_MASK);
}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool NoShortcut(const Scanner<Relocation, ExitMasks<MaskCount> >& scanner, typename Scanner<Relocation, ExitMasks<MaskCount> >::State state)
{
return CheckFirstMask(scanner, state, NO_SHORTCUT_MASK);
}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
const Word* Run(const Scanner<Relocation, ExitMasks<MaskCount> >& scanner, typename Scanner<Relocation, ExitMasks<MaskCount> >::State state, size_t alignOffset, const Word* begin, const Word* end)
{
return MaskChecker<typename Scanner<Relocation, ExitMasks<MaskCount> >::ScannerRowHeader, 0, MaskCount - 1>::Run(scanner.Header(state), alignOffset, begin, end);
@@ -846,7 +846,7 @@ struct NoShortcuts {
static void FinishMasks(Header&, size_t) {}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool NoExit(const Scanner<Relocation, NoShortcuts>&, typename Scanner<Relocation, NoShortcuts>::State)
{
// Cannot exit prematurely
@@ -854,7 +854,7 @@ struct NoShortcuts {
}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
bool NoShortcut(const Scanner<Relocation, NoShortcuts>&, typename Scanner<Relocation, NoShortcuts>::State)
{
// There's no shortcut regardless of the state
@@ -862,7 +862,7 @@ struct NoShortcuts {
}
template <class Relocation>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
const Word* Run(const Scanner<Relocation, NoShortcuts>&, typename Scanner<Relocation, NoShortcuts>::State, size_t, const Word* begin, const Word*)
{
// Stop shortcutting right at the beginning
@@ -879,7 +879,7 @@ template <class Scanner, unsigned Count>
struct MultiChunk {
// Process Word-sized chunk which consist of >=1 size_t-sized chunks
template<class Pred>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action Process(const Scanner& scanner, typename Scanner::State& state, const size_t* p, Pred pred)
{
if (RunChunk(scanner, state, p, 0, sizeof(void*), pred) == Continue)
@@ -893,7 +893,7 @@ template <class Scanner>
struct MultiChunk<Scanner, 0> {
// Process Word-sized chunk which consist of >=1 size_t-sized chunks
template<class Pred>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action Process(const Scanner&, typename Scanner::State, const size_t*, Pred)
{
return Continue;
@@ -909,7 +909,7 @@ private:
// Processes Word-sized chuck of memory (depending on the platform a Word might
// consist of multiple size_t chuncks)
template <class Pred>
- static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
+ static PIRE_FORCED_INLINE PIRE_HOT_FUNCTION
Action RunMultiChunk(const ScannerType& scanner, typename ScannerType::State& st, const size_t* begin, Pred pred)
{
return MultiChunk<ScannerType, sizeof(Word)/sizeof(size_t)>::Process(scanner, st, begin, pred);
diff --git a/contrib/libs/pire/pire/scanners/slow.h b/contrib/libs/pire/pire/scanners/slow.h
index 6103fc5b67..6adfcb8c1d 100644
--- a/contrib/libs/pire/pire/scanners/slow.h
+++ b/contrib/libs/pire/pire/scanners/slow.h
@@ -96,13 +96,13 @@ public:
BitSet(m.statesCount).Swap(state.flags);
}
- Char Translate(Char ch) const
+ Char Translate(Char ch) const
+ {
+ return m_letters[static_cast<size_t>(ch)];
+ }
+
+ Action NextTranslated(const State& current, State& next, Char l) const
{
- return m_letters[static_cast<size_t>(ch)];
- }
-
- Action NextTranslated(const State& current, State& next, Char l) const
- {
next.flags.Clear();
next.states.clear();
for (auto&& state : current.states) {
@@ -130,26 +130,26 @@ public:
return 0;
}
- Action Next(const State& current, State& next, Char c) const
- {
- return NextTranslated(current, next, Translate(c));
- }
-
+ Action Next(const State& current, State& next, Char c) const
+ {
+ return NextTranslated(current, next, Translate(c));
+ }
+
bool TakeAction(State&, Action) const { return false; }
- Action NextTranslated(State& s, Char l) const
+ Action NextTranslated(State& s, Char l) const
{
State dest(m.statesCount);
- Action a = NextTranslated(s, dest, l);
+ Action a = NextTranslated(s, dest, l);
s.Swap(dest);
return a;
}
- Action Next(State& s, Char c) const
- {
- return NextTranslated(s, Translate(c));
- }
-
+ Action Next(State& s, Char c) const
+ {
+ return NextTranslated(s, Translate(c));
+ }
+
bool Final(const State& s) const
{
for (auto&& state : s.states)