const Rule &rule,
const std::vector<CtxVar> &contexts)
{
- for (size_t i = 0; i < rule.ctxvar.size(); ++i) {
- const CtxVar &ctx = contexts[rule.ctxvar[i]];
+ for (size_t i = rule.ltag; i < rule.htag; ++i) {
+ const CtxVar &ctx = contexts[i];
strrreplace(action, "@" + *ctx.codename,
opts->input_api.expr_ctx(ctx.expr()));
}
if (s->rule != Rule::NONE) {
const Rule &rule = dfa.rules[s->rule];
- live[i].insert(rule.ctxvar.begin(), rule.ctxvar.end());
+ for (size_t j = rule.ltag; j < rule.htag; ++j) {
+ live[i].insert(j);
+ }
if (rule.trail.type == Trail::VAR) {
live[i].insert(rule.trail.pld.var);
}
std::set<size_t> fbctxs;
for (size_t i = 0; i < fallback.size(); ++i) {
const Rule &rule = dfa.rules[dfa.states[fallback[i]]->rule];
- fbctxs.insert(rule.ctxvar.begin(), rule.ctxvar.end());
+ for (size_t j = rule.ltag; j < rule.htag; ++j) {
+ fbctxs.insert(j);
+ }
if (rule.trail.type == Trail::VAR) {
fbctxs.insert(rule.trail.pld.var);
}
nfa_state_t *t = &nfa.states[nfa.size++];
t->fin(nrule);
- std::vector<size_t> &ctxvar = r.ctxvar;
+ r.ltag = nfa.contexts.size();
std::vector<CtxFix> &ctxfix = r.ctxfix;
Trail &trail = r.trail;
// base2var is filled in right-to-left, this is crucial
const size_t idx = nfa.contexts.size();
base2var[i - 1] = idx;
nfa.contexts.push_back(CtxVar(name, nrule));
- if (name != NULL) {
- ctxvar.push_back(idx);
- } else {
+ if (name == NULL) {
+ ++r.ltag;
trail.make_var(idx);
}
nfa_state_t *q = &nfa.states[nfa.size++];
}
}
}
+ r.htag = nfa.contexts.size();
t = compile(rs[0], nfa, t);
bool null = nullable(rs[0]);
const RuleInfo *info;
- std::vector<size_t> ctxvar;
+ size_t ltag;
+ size_t htag;
std::vector<CtxFix> ctxfix;
Trail trail;
bool nullable;
Rule()
: info(NULL)
- , ctxvar()
+ , ltag(0)
+ , htag(0)
, ctxfix()
, trail()
, nullable(false)