From: Ulya Trofimovich Date: Tue, 10 May 2016 13:12:26 +0000 (+0100) Subject: Code cleanup: use anonymous union to shorten names. X-Git-Tag: 1.0~39^2~312 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae9dbe4ac9af5ef76ff683725caa64a5785743fa;p=re2c Code cleanup: use anonymous union to shorten names. --- diff --git a/re2c/src/ir/dfa/determinization.cc b/re2c/src/ir/dfa/determinization.cc index e91d5fab..db4d2582 100644 --- a/re2c/src/ir/dfa/determinization.cc +++ b/re2c/src/ir/dfa/determinization.cc @@ -73,14 +73,14 @@ static void closure(kitem_t *const kernel, kitem_t *&kend, n->mark = true; switch (n->type) { case nfa_state_t::ALT: - closure(kernel, kend, n->value.alt.out2, tags, badtags, ntags); - closure(kernel, kend, n->value.alt.out1, tags, badtags, ntags); + closure(kernel, kend, n->alt.out2, tags, badtags, ntags); + closure(kernel, kend, n->alt.out1, tags, badtags, ntags); break; case nfa_state_t::TAG: { - const size_t t = n->value.tag.info; + const size_t t = n->tag.info; const bool old = tags[t]; tags[t] = true; - closure(kernel, kend, n->value.tag.out, tags, badtags, ntags); + closure(kernel, kend, n->tag.out, tags, badtags, ntags); tags[t] = old; break; } @@ -170,9 +170,9 @@ dfa_t::dfa_t(const nfa_t &nfa, const bool *newtags = tagpool[kernel[j].tagidx]; switch (n->type) { case nfa_state_t::RAN: { - nfa_state_t *m = n->value.ran.out; + nfa_state_t *m = n->ran.out; size_t c = 0; - for (const Range *r = n->value.ran.ran; r; r = r->next ()) { + for (const Range *r = n->ran.ran; r; r = r->next ()) { for (; charset[c] != r->lower(); ++c); for (; charset[c] != r->upper(); ++c) { merge_tags_with_mask(&arctags[c * ntags], newtags, diff --git a/re2c/src/ir/nfa/nfa.h b/re2c/src/ir/nfa/nfa.h index 5d1221fb..f93d4438 100644 --- a/re2c/src/ir/nfa/nfa.h +++ b/re2c/src/ir/nfa/nfa.h @@ -33,35 +33,35 @@ struct nfa_state_t nfa_state_t *out; size_t info; } tag; - } value; + }; size_t rule; bool mark; - void alt(size_t r, nfa_state_t *s1, nfa_state_t *s2) + void make_alt(size_t r, nfa_state_t *s1, nfa_state_t *s2) { type = ALT; - value.alt.out1 = s1; - value.alt.out2 = s2; + alt.out1 = s1; + alt.out2 = s2; rule = r; mark = false; } - void ran(size_t r, nfa_state_t *s, const Range *p) + void make_ran(size_t r, nfa_state_t *s, const Range *p) { type = RAN; - value.ran.out = s; - value.ran.ran = p; + ran.out = s; + ran.ran = p; rule = r; mark = false; } - void tag(size_t r, nfa_state_t *s, size_t i) + void make_tag(size_t r, nfa_state_t *s, size_t i) { type = TAG; - value.tag.out = s; - value.tag.info = i; + tag.out = s; + tag.info = i; rule = r; mark = false; } - void fin(size_t r) + void make_fin(size_t r) { type = FIN; rule = r; diff --git a/re2c/src/ir/nfa/regexps2nfa.cc b/re2c/src/ir/nfa/regexps2nfa.cc index 3511ca7b..dcb911cd 100644 --- a/re2c/src/ir/nfa/regexps2nfa.cc +++ b/re2c/src/ir/nfa/regexps2nfa.cc @@ -12,11 +12,11 @@ static nfa_state_t *regexp2nfa(nfa_t &nfa, size_t nrule, break; case RegExp::SYM: s = &nfa.states[nfa.size++]; - s->ran(nrule, t, re->sym); + s->make_ran(nrule, t, re->sym); break; case RegExp::ALT: s = &nfa.states[nfa.size++]; - s->alt(nrule, + s->make_alt(nrule, regexp2nfa(nfa, nrule, tagidx, re->alt.re1, t), regexp2nfa(nfa, nrule, tagidx, re->alt.re2, t)); break; @@ -26,12 +26,12 @@ static nfa_state_t *regexp2nfa(nfa_t &nfa, size_t nrule, break; case RegExp::ITER: s = &nfa.states[nfa.size++]; - s->alt(nrule, t, regexp2nfa(nfa, nrule, tagidx, re->iter, s)); + s->make_alt(nrule, t, regexp2nfa(nfa, nrule, tagidx, re->iter, s)); break; case RegExp::TAG: if ((*nfa.tags)[tagidx].type == Tag::VAR) { s = &nfa.states[nfa.size++]; - s->tag(nrule, t, tagidx); + s->make_tag(nrule, t, tagidx); } else { s = t; } @@ -45,7 +45,7 @@ static nfa_state_t *regexp2nfa_rule(nfa_t &nfa, size_t nrule, size_t &tagidx, const RegExpRule *rule) { nfa_state_t *s = &nfa.states[nfa.size++]; - s->fin(nrule); + s->make_fin(nrule); return regexp2nfa(nfa, nrule, tagidx, rule->re, s); } @@ -61,7 +61,7 @@ void regexps2nfa(const std::vector ®exps, nfa_t &nfa) nfa_state_t *s = regexp2nfa_rule(nfa, 0, tagidx, regexps[0]); for (size_t i = 1; i < nregexps; ++i) { nfa_state_t *t = &nfa.states[nfa.size++]; - t->alt(i, s, regexp2nfa_rule(nfa, i, tagidx, regexps[i])); + t->make_alt(i, s, regexp2nfa_rule(nfa, i, tagidx, regexps[i])); s = t; } nfa.root = s;