typedef confset_t::const_iterator cconfiter_t;
typedef confset_t::const_reverse_iterator rcconfiter_t;
-template<sema_t SEMA, eval_t EVAL>
+template<typename history_type_t>
struct simctx_t
{
typedef libre2c::conf_t conf_t;
typedef confset_t::const_iterator cconfiter_t;
typedef confset_t::reverse_iterator rconfiter_t;
typedef confset_t::const_reverse_iterator rcconfiter_t;
- typedef typename history_type_t<SEMA, EVAL>::type history_t;
+ typedef history_type_t history_t;
const nfa_t &nfa;
const nfa_t *nfa0;
FORBID_COPY(simctx_t);
};
-typedef simctx_t<POSIX, STRICT> psimctx_t;
-typedef simctx_t<LEFTMOST, STRICT> lsimctx_t;
-typedef simctx_t<POSIX, LAZY> pzsimctx_t;
-typedef simctx_t<LEFTMOST, LAZY> lzsimctx_t;
+typedef simctx_t<phistory_t> psimctx_t;
+typedef simctx_t<lhistory_t> lsimctx_t;
+typedef simctx_t<zhistory_t> pzsimctx_t;
+typedef simctx_t<zhistory_t> lzsimctx_t;
int regexec_dfa(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
int regexec_nfa_posix(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
int regexec_nfa_leftmost(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
int regexec_nfa_leftmost_trie(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
-template<sema_t SEMA, eval_t EVAL>
-simctx_t<SEMA, EVAL>::simctx_t(const nfa_t &nfa, const nfa_t *nfa0, size_t re_nsub, int flags)
+template<typename history_t>
+simctx_t<history_t>::simctx_t(const nfa_t &nfa, const nfa_t *nfa0, size_t re_nsub, int flags)
: nfa(nfa)
, nfa0(nfa0)
, nsub(2 * (re_nsub - 1))
}
}
-template<sema_t SEMA, eval_t EVAL>
-simctx_t<SEMA, EVAL>::~simctx_t()
+template<typename history_t>
+simctx_t<history_t>::~simctx_t()
{
delete[] done;
if (!(flags & REG_TRIE)) {
}
}
-template<sema_t SEMA, eval_t EVAL>
-void init(simctx_t<SEMA, EVAL> &ctx, const char *string)
+template<typename history_t>
+void init(simctx_t<history_t> &ctx, const char *string)
{
ctx.reach.clear();
ctx.state.clear();
DASSERT(ctx.gtop_heap.empty());
}
-template<sema_t SEMA>
-int finalize(const simctx_t<SEMA, LAZY> &ctx, const char *string, size_t nmatch,
+template<typename history_t>
+int finalize(const simctx_t<history_t> &ctx, const char *string, size_t nmatch,
regmatch_t pmatch[])
{
if (ctx.rule == Rule::NONE) {
memset(done, 0, ctx.nsub * sizeof(bool));
for (int32_t i = ctx.hidx; todo > 0 && i != HROOT; ) {
- const typename simctx_t<SEMA, LAZY>::history_t::node_t &n = ctx.history.node(i);
+ const typename history_t::node_t &n = ctx.history.node(i);
const Tag &tag = tags[n.info.idx];
const size_t t = tag.ncap;
if (!fictive(tag) && t < nmatch * 2 && !done[t]) {
}
}
-template<sema_t SEMA>
-determ_context_t<SEMA>::determ_context_t(const opt_t *opts, Msg &msg
+template<typename history_t>
+determ_context_t<history_t>::determ_context_t(const opt_t *opts, Msg &msg
, const std::string &condname, const nfa_t &nfa, dfa_t &dfa)
: dc_opts(opts)
, dc_msg(msg)
, dc_kernels()
, dc_buffers(dc_allocator)
, dc_hc_caches()
- , dc_newvers(newver_cmp_t<typename determ_context_t<SEMA>::history_t>(history, dc_hc_caches))
+ , dc_newvers(newver_cmp_t<history_t>(history, dc_hc_caches))
, dc_path1()
, dc_path2()
, dc_path3()
dc_path3.reserve(ntags);
dc_tagcount.resize(ntags);
- if (SEMA == POSIX) {
+ if (opts->posix_semantics) {
newprectbl = new prectable_t[ncores * ncores];
histlevel = new histleaf_t[ncores];
sortcores.reserve(ncores);
}
}
-template<sema_t SEMA>
-determ_context_t<SEMA>::~determ_context_t()
+template<typename history_t>
+determ_context_t<history_t>::~determ_context_t()
{
- if (SEMA == POSIX) {
- delete[] newprectbl;
- delete[] histlevel;
- }
+ delete[] newprectbl;
+ delete[] histlevel;
}
} // namespace re2c
typedef std::priority_queue<nfa_state_t*, std::vector<nfa_state_t*>
, cmp_gtop_t> gtop_heap_t;
-template<sema_t SEMA>
+template<typename history_type_t>
struct determ_context_t
{
typedef clos_t conf_t;
typedef confset_t::const_iterator cconfiter_t;
typedef confset_t::reverse_iterator rconfiter_t;
typedef confset_t::const_reverse_iterator rcconfiter_t;
- typedef typename history_type_t<SEMA, STRICT>::type history_t;
+ typedef history_type_t history_t;
typedef std::map<newver_t, tagver_t, newver_cmp_t<history_t> > newvers_t;
// determinization input
FORBID_COPY(determ_context_t);
};
-typedef determ_context_t<POSIX> pdetctx_t;
-typedef determ_context_t<LEFTMOST> ldetctx_t;
+typedef determ_context_t<phistory_t> pdetctx_t;
+typedef determ_context_t<lhistory_t> ldetctx_t;
template<typename ctx_t> void tagged_epsilon_closure(ctx_t &ctx);
template<typename ctx_t> void find_state(ctx_t &ctx);
static const uint32_t NONFIN = ~0u;
static const uint32_t USED = NONFIN - 1;
-enum sema_t {POSIX, LEFTMOST};
-enum eval_t {STRICT, LAZY};
-
// tag history for POSIX semantics
struct phistory_t
{
return i;
}
-// history type selector
-template<sema_t SEMA, eval_t EVAL> struct history_type_t;
-template<> struct history_type_t<POSIX, STRICT> {typedef phistory_t type;};
-template<> struct history_type_t<LEFTMOST, STRICT> {typedef lhistory_t type;};
-template<sema_t SEMA> struct history_type_t<SEMA, LAZY> {typedef zhistory_t type;};
-
template<typename history_t>
tagver_t last(const history_t &h, hidx_t i, size_t t)
{