nfa_state_t *state;
uint32_t origin;
int32_t thist;
+
+ inline conf_t(): state(NULL), origin(0), thist(history_t::ROOT) {}
+ inline conf_t(nfa_state_t *s, uint32_t o, int32_t h)
+ : state(s), origin(o), thist(h) {}
};
struct ran_or_fin_t
{
simctx_t ctx(preg, string);
- const conf_t c0 = {ctx.nfa->root, 0, history_t::ROOT};
+ const conf_t c0(ctx.nfa->root, 0, history_t::ROOT);
ctx.reach.push_back(c0);
closure_leftmost(ctx);
if (s->type == nfa_state_t::RAN) {
for (const Range *r = s->ran.ran; r; r = r->next()) {
if (r->lower() <= sym && sym < r->upper()) {
- conf_t c = {s->ran.out, s->coreid, history_t::ROOT};
+ conf_t c(s->ran.out, s->coreid, history_t::ROOT);
reach.push_back(c);
update_offsets(ctx, *i);
break;
state.clear();
for (; !wl.empty(); ) {
- conf_t x = wl.back();
- wl.pop_back();
+ const conf_t &x = wl.back();
nfa_state_t *n = x.state;
+ const uint32_t o = x.origin;
+ const int32_t h = x.thist;
+ wl.pop_back();
if (n->clos != NOCLOS) continue;
switch (n->type) {
case nfa_state_t::NIL:
- x.state = n->nil.out;
- wl.push_back(x);
+ wl.push_back(conf_t(n->nil.out, o, h));
break;
case nfa_state_t::ALT:
- x.state = n->alt.out2;
- wl.push_back(x);
- x.state = n->alt.out1;
- wl.push_back(x);
+ wl.push_back(conf_t(n->alt.out2, o, h));
+ wl.push_back(conf_t(n->alt.out1, o, h));
break;
case nfa_state_t::TAG:
- x.state = n->tag.out;
- x.thist = ctx.hist.push(x.thist, ctx.step, n->tag.info, x.origin);
- wl.push_back(x);
+ wl.push_back(conf_t(n->tag.out, o
+ , ctx.hist.push(h, ctx.step, n->tag.info, o)));
break;
default:
break;
simctx_t ctx(preg, string);
const nfa_t *nfa = ctx.nfa;
- const conf_t c0 = {nfa->root, 0, history_t::ROOT};
+ const conf_t c0(nfa->root, 0, history_t::ROOT);
ctx.reach.push_back(c0);
closure_posix(ctx);
if (s->type == nfa_state_t::RAN) {
for (const Range *r = s->ran.ran; r; r = r->next()) {
if (r->lower() <= sym && sym < r->upper()) {
- conf_t c = {s->ran.out, s->coreid, history_t::ROOT};
+ const conf_t c(s->ran.out, s->coreid, history_t::ROOT);
reach.push_back(c);
state[j++] = *i;
break;
bool scan(simctx_t &ctx, nfa_state_t *q, bool all)
{
bool any = false;
- conf_t x = ctx.state[q->clos];
+
+ const conf_t &x = ctx.state[q->clos];
+ const uint32_t o = x.origin;
+ const int32_t h = x.thist;
+
switch (q->type) {
case nfa_state_t::NIL:
if (q->arcidx == 0) {
- x.state = q->nil.out;
- any |= relax_gor1(ctx, x);
+ any |= relax_gor1(ctx, conf_t(q->nil.out, o, h));
++q->arcidx;
}
break;
case nfa_state_t::ALT:
if (q->arcidx == 0) {
- x.state = q->alt.out1;
- any |= relax_gor1(ctx, x);
+ any |= relax_gor1(ctx, conf_t(q->alt.out1, o, h));
++q->arcidx;
}
if (q->arcidx == 1 && (!any || all)) {
- x.state = q->alt.out2;
- any |= relax_gor1(ctx, x);
+ any |= relax_gor1(ctx, conf_t(q->alt.out2, o, h));
++q->arcidx;
}
break;
case nfa_state_t::TAG:
if (q->arcidx == 0) {
- x.state = q->tag.out;
- x.thist = ctx.hist.push(x.thist, ctx.step, q->tag.info, x.origin);
- any |= relax_gor1(ctx, x);
+ any |= relax_gor1(ctx, conf_t(q->tag.out, o
+ , ctx.hist.push(h, ctx.step, q->tag.info, o)));
++q->arcidx;
}
break;
default:
break;
}
+
return any;
}
nfa_state_t *q = heap.top();
heap.pop();
q->active = 0;
- conf_t x = state[q->clos];
+
+ const conf_t &x = state[q->clos];
+ const uint32_t o = x.origin;
+ const int32_t h = x.thist;
switch (q->type) {
case nfa_state_t::NIL:
- x.state = q->nil.out;
- relax_gtop(ctx, x);
+ relax_gtop(ctx, conf_t(q->nil.out, o, h));
break;
case nfa_state_t::ALT:
- x.state = q->alt.out1;
- relax_gtop(ctx, x);
- x.state = q->alt.out2;
- relax_gtop(ctx, x);
+ relax_gtop(ctx, conf_t(q->alt.out1, o, h));
+ relax_gtop(ctx, conf_t(q->alt.out2, o, h));
break;
case nfa_state_t::TAG:
- x.state = q->tag.out;
- x.thist = ctx.hist.push(x.thist, ctx.step, q->tag.info, x.origin);
- relax_gtop(ctx, x);
+ relax_gtop(ctx, conf_t(q->tag.out, o
+ , ctx.hist.push(h, ctx.step, q->tag.info, o)));
break;
default:
break;
const nfa_t *nfa = ctx.nfa;
confset_t &state = ctx.state;
- const conf_t c0 = {nfa->root, index(nfa, nfa->root), history_t::ROOT};
+ const conf_t c0(nfa->root, index(nfa, nfa->root), history_t::ROOT);
ctx.reach.push_back(c0);
closure_posix(ctx);
if (s->type == nfa_state_t::RAN) {
for (const Range *r = s->ran.ran; r; r = r->next()) {
if (r->lower() <= sym && sym < r->upper()) {
- conf_t c = {s->ran.out, index(nfa, s), i->thist};
+ const conf_t c(s->ran.out, index(nfa, s), i->thist);
reach.push_back(c);
break;
}
nfa_state_t *q = heap.top();
heap.pop();
q->active = 0;
- conf_t x = state[q->clos];
+
+ const conf_t &x = state[q->clos];
+ const uint32_t o = x.origin;
+ const int32_t h = x.thist;
switch (q->type) {
case nfa_state_t::NIL:
- x.state = q->nil.out;
- relax(ctx, x);
+ relax(ctx, conf_t(q->nil.out, o, h));
break;
case nfa_state_t::ALT:
- x.state = q->alt.out1;
- relax(ctx, x);
- x.state = q->alt.out2;
- relax(ctx, x);
+ relax(ctx, conf_t(q->alt.out1, o, h));
+ relax(ctx, conf_t(q->alt.out2, o, h));
break;
case nfa_state_t::TAG:
- x.state = q->tag.out;
- x.thist = ctx.hist.push(x.thist, ctx.step, q->tag.info, x.origin);
- relax(ctx, x);
+ relax(ctx, conf_t(q->tag.out, o
+ , ctx.hist.push(h, ctx.step, q->tag.info, o)));
break;
case nfa_state_t::FIN:
ctx.marker = ctx.cursor + 1;