]> granicus.if.org Git - re2c/commitdiff
Code cleanup: use anonymous union to shorten names.
authorUlya Trofimovich <skvadrik@gmail.com>
Tue, 10 May 2016 13:12:26 +0000 (14:12 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 10 May 2016 13:12:26 +0000 (14:12 +0100)
re2c/src/ir/dfa/determinization.cc
re2c/src/ir/nfa/nfa.h
re2c/src/ir/nfa/regexps2nfa.cc

index e91d5fabd6713abed1d89ab33c8d42062749aa44..db4d25826a9efaf01a8e8e9b5de6e6b34fe19243 100644 (file)
@@ -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,
index 5d1221fbffe55cf9340f5b8a86e37e467781a591..f93d4438d8fca38af073ba22a325222a678088f4 100644 (file)
@@ -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;
index 3511ca7be6e9b9534212aa8badf3bb80513b2de1..dcb911cdff905c9e0af9a34d3138128d2e5e5dbd 100644 (file)
@@ -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<const RegExpRule*> &regexps, 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;