diff options
Diffstat (limited to 'lib/regexec_nfa_leftmost_trie.cc')
-rw-r--r-- | lib/regexec_nfa_leftmost_trie.cc | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/lib/regexec_nfa_leftmost_trie.cc b/lib/regexec_nfa_leftmost_trie.cc index 37d9cc56..f6f7e96c 100644 --- a/lib/regexec_nfa_leftmost_trie.cc +++ b/lib/regexec_nfa_leftmost_trie.cc @@ -4,23 +4,21 @@ #include "lib/regex.h" #include "lib/regex_impl.h" -#include "src/debug/debug.h" #include "src/dfa/closure_leftmost.h" #include "src/dfa/tag_history.h" #include "src/nfa/nfa.h" +#include "src/util/check.h" #include "src/util/range.h" - namespace re2c { namespace libre2c { -static void make_step(lzsimctx_t &, uint32_t); -static void make_final_step(lzsimctx_t &ctx); +static void make_step(lzsimctx_t&, uint32_t); +static void make_final_step(lzsimctx_t& ctx); -int regexec_nfa_leftmost_trie(const regex_t *preg, const char *string - , size_t nmatch, regmatch_t pmatch[], int) -{ - lzsimctx_t &ctx = *static_cast<lzsimctx_t*>(preg->simctx); +int regexec_nfa_leftmost_trie( + const regex_t* preg, const char* string, size_t nmatch, regmatch_t pmatch[], int) { + lzsimctx_t& ctx = *static_cast<lzsimctx_t*>(preg->simctx); init(ctx, string); const conf_t c0(ctx.nfa.root, 0/* unused */, HROOT); @@ -37,31 +35,29 @@ int regexec_nfa_leftmost_trie(const regex_t *preg, const char *string return finalize(ctx, string, nmatch, pmatch); } -void make_step(lzsimctx_t &ctx, uint32_t sym) -{ - const confset_t &state = ctx.state; - confset_t &reach = ctx.reach; +void make_step(lzsimctx_t& ctx, uint32_t sym) { + const confset_t& state = ctx.state; + confset_t& reach = ctx.reach; // in reverse, so that future closure DFS has states in stack order rcconfiter_t b = state.rbegin(), e = state.rend(), i; - DASSERT(reach.empty()); + DCHECK(reach.empty()); for (i = b; i != e; ++i) { - nfa_state_t *s = i->state; + TnfaState* s = i->state; // cleanup from previous closure s->clos = NOCLOS; - if (s->type == nfa_state_t::RAN) { - for (const Range *r = s->ran.ran; r; r = r->next()) { + if (s->kind == TnfaState::Kind::RAN) { + for (const Range* r = s->ran; r; r = r->next()) { if (r->lower() <= sym && sym < r->upper()) { - const conf_t c(s->ran.out, 0/* unused */, i->thist); + const conf_t c(s->out1, 0/* unused */, i->thist); reach.push_back(c); break; } } - } - else if (s->type == nfa_state_t::FIN) { + } else if (s->kind == TnfaState::Kind::FIN) { ctx.marker = ctx.cursor; ctx.hidx = i->thist; ctx.rule = 0; @@ -71,15 +67,14 @@ void make_step(lzsimctx_t &ctx, uint32_t sym) ++ctx.step; } -void make_final_step(lzsimctx_t &ctx) -{ +void make_final_step(lzsimctx_t& ctx) { for (confiter_t i = ctx.state.begin(), e = ctx.state.end(); i != e; ++i) { - nfa_state_t *s = i->state; + TnfaState* s = i->state; s->clos = NOCLOS; - DASSERT(s->active == 0); + DCHECK(s->active == 0); - if (s->type == nfa_state_t::FIN) { + if (s->kind == TnfaState::Kind::FIN) { ctx.marker = ctx.cursor; ctx.hidx = i->thist; ctx.rule = 0; @@ -89,4 +84,3 @@ void make_final_step(lzsimctx_t &ctx) } // namespace libre2 } // namespace re2c - |