From: Ulya Trofimovich Date: Fri, 3 Mar 2017 23:09:19 +0000 (+0000) Subject: '--skeleton --posix-captures': use correct capture index when checking tags. X-Git-Tag: 1.0~39^2~112 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=882e3ec82120f4fee5e140511bb572e0ec4030d7;p=re2c '--skeleton --posix-captures': use correct capture index when checking tags. Instead of skipping fixed tags, skip orbit tags. For each orbit tag there is a tag fixed on it, so if we check all fixed tags we'll surely check all orbit tags. Anyway, with '--skeleton' all fixed tags correspond to orbit tags: other fixed tags are forbidden with generic API (even zero-offset ones for now). --- diff --git a/re2c/src/ir/skeleton/generate_code.cc b/re2c/src/ir/skeleton/generate_code.cc index 7a308211..b235555e 100644 --- a/re2c/src/ir/skeleton/generate_code.cc +++ b/re2c/src/ir/skeleton/generate_code.cc @@ -358,7 +358,7 @@ void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rid) const size_t rkey = rule2key(rid, dfa.key_size, dfa.def_rule); size_t ntag = 3; for (size_t t = r.ltag; t < r.htag; ++t) { - if (t != r.ttag && !fixed(dfa.tags[t])) ++ntag; + if (t != r.ttag && !orbit(dfa.tags[t])) ++ntag; } o.wind(ind).ws("status = check_key_count_").wstring(name).ws("(keys_count, i, ") @@ -367,7 +367,7 @@ void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rid) for (size_t t = r.ltag; t < r.htag; ++t) { const Tag &tag = dfa.tags[t]; - if (t == r.ttag || fixed(tag)) continue; + if (t == r.ttag || orbit(tag)) continue; const std::string tname = tagname(tag); o.ws("\n").wind(ind + 1).ws(" || check_tag_").wstring(name) .ws("(&i, keys, ").wstring(tname).ws(", input, token, \"") diff --git a/re2c/src/ir/skeleton/generate_data.cc b/re2c/src/ir/skeleton/generate_data.cc index 26464327..7846538a 100644 --- a/re2c/src/ir/skeleton/generate_data.cc +++ b/re2c/src/ir/skeleton/generate_data.cc @@ -199,7 +199,7 @@ static void write_keys(const path_t &path, const Skeleton &skel, // keys: 1 - scanned length, 2 - matched length, 3 - matched rule, the rest - tags size_t nkey = 3; for (size_t t = ltag; t < htag; ++t) { - if (t != trail && !fixed(skel.tags[t])) ++nkey; + if (t != trail && !orbit(skel.tags[t])) ++nkey; } key_t *keys = new key_t[nkey * width], *k = keys; for (size_t w = 0; w < width; ++w) { @@ -208,8 +208,10 @@ static void write_keys(const path_t &path, const Skeleton &skel, *k++ = to_le(rule2key(rule, skel.defrule)); const size_t *ts = &tags[w * nver]; for (size_t t = ltag; t < htag; ++t) { - if (t != trail && !fixed(skel.tags[t])) { - *k++ = to_le(static_cast(ts[skel.finvers[t]])); + const Tag &tag = skel.tags[t]; + if (t != trail && !orbit(tag)) { + const size_t base = fixed(tag) ? tag.base : t; + *k++ = to_le(static_cast(ts[skel.finvers[base]])); } } }