From 87514d62b4e02d993731b8c96418bcbfc88b3137 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 13 Aug 2018 22:43:16 +0100 Subject: [PATCH] Renamed a couple of structs. --- re2c/Makefile.am | 8 ++--- re2c/src/dfa/closure.cc | 33 ++++++++++--------- re2c/src/dfa/determinization.cc | 14 ++++---- re2c/src/dfa/determinization.h | 34 ++++++++++---------- re2c/src/dfa/dfa.h | 1 - re2c/src/dfa/dump.cc | 33 ++++++++++--------- re2c/src/dfa/find_state.cc | 25 +++++++------- re2c/src/dfa/{tagtree.cc => tag_history.cc} | 28 ++++++++-------- re2c/src/dfa/{tagtree.h => tag_history.h} | 12 +++---- re2c/src/dfa/{tagpool.cc => tagver_table.cc} | 14 ++++---- re2c/src/dfa/{tagpool.h => tagver_table.h} | 14 ++++---- re2c/src/dfa/tcmd.cc | 2 +- re2c/src/dfa/tcmd.h | 4 +-- 13 files changed, 110 insertions(+), 112 deletions(-) rename re2c/src/dfa/{tagtree.cc => tag_history.cc} (80%) rename re2c/src/dfa/{tagtree.h => tag_history.h} (84%) rename re2c/src/dfa/{tagpool.cc => tagver_table.cc} (76%) rename re2c/src/dfa/{tagpool.h => tagver_table.h} (71%) diff --git a/re2c/Makefile.am b/re2c/Makefile.am index abffc587..6a2f2dbd 100644 --- a/re2c/Makefile.am +++ b/re2c/Makefile.am @@ -26,8 +26,8 @@ SRC_HDR = \ src/dfa/determinization.h \ src/dfa/dfa.h \ src/dfa/dump.h \ - src/dfa/tagpool.h \ - src/dfa/tagtree.h \ + src/dfa/tag_history.h \ + src/dfa/tagver_table.h \ src/dfa/tcmd.h \ src/nfa/nfa.h \ src/re/encoding/case.h \ @@ -109,8 +109,8 @@ SRC = \ src/dfa/fillpoints.cc \ src/dfa/find_state.cc \ src/dfa/minimization.cc \ - src/dfa/tagpool.cc \ - src/dfa/tagtree.cc \ + src/dfa/tag_history.cc \ + src/dfa/tagver_table.cc \ src/dfa/tcmd.cc \ src/re/encoding/enc.cc \ src/re/encoding/range_suffix.cc \ diff --git a/re2c/src/dfa/closure.cc b/re2c/src/dfa/closure.cc index 17e1f58f..26c95982 100644 --- a/re2c/src/dfa/closure.cc +++ b/re2c/src/dfa/closure.cc @@ -11,7 +11,6 @@ #include "src/conf/opt.h" #include "src/dfa/determinization.h" #include "src/dfa/dfa.h" -#include "src/dfa/tagpool.h" #include "src/dfa/tcmd.h" #include "src/nfa/nfa.h" #include "src/re/rule.h" @@ -192,7 +191,7 @@ nfa_state_t *explore(determ_context_t &ctx, nfa_state_t *q) case nfa_state_t::TAG: if (q->arcidx == 0) { x.state = q->tag.out; - x.tlook = ctx.dc_tagtrie.push(x.tlook, q->tag.info); + x.tlook = ctx.dc_taghistory.push(x.tlook, q->tag.info); p = relax(ctx, x); ++q->arcidx; } @@ -332,7 +331,7 @@ void closure_leftmost(determ_context_t &ctx) break; case nfa_state_t::TAG: x.state = n->tag.out; - x.tlook = ctx.dc_tagtrie.push(x.tlook, n->tag.info); + x.tlook = ctx.dc_taghistory.push(x.tlook, n->tag.info); todo.push(x); break; case nfa_state_t::RAN: @@ -389,14 +388,14 @@ void generate_versions(determ_context_t &ctx) const std::vector &tags = dfa.tags; const size_t ntag = tags.size(); tagver_t &maxver = dfa.maxtagver; - Tagpool &tagpool = ctx.dc_tagpool; - tagver_t *vers = tagpool.buffer; + tagver_table_t &tvtbl = ctx.dc_tagvertbl; + tagver_t *vers = tvtbl.buffer; closure_t &clos = ctx.dc_closure; - tagtree_t &tagtree = ctx.dc_tagtrie; + tag_history_t &thist = ctx.dc_taghistory; newvers_t &newvers = ctx.dc_newvers; clositer_t b = clos.begin(), e = clos.end(), c; - newver_cmp_t cmp(tagtree); + newver_cmp_t cmp(thist); newvers_t newacts(cmp); tcmd_t *cmd = NULL; @@ -408,12 +407,12 @@ void generate_versions(determ_context_t &ctx) const hidx_t l = c->tlook, h = c->ttran; if (h == HROOT) continue; - const tagver_t *vs = tagpool[c->tvers]; + const tagver_t *vs = tvtbl[c->tvers]; for (size_t t = 0; t < ntag; ++t) { const Tag &tag = tags[t]; const tagver_t - h0 = tagtree.last(h, t), - l0 = tagtree.last(l, t); + h0 = thist.last(h, t), + l0 = thist.last(l, t); if (h0 == TAGVER_ZERO) continue; @@ -436,15 +435,17 @@ void generate_versions(determ_context_t &ctx) const hidx_t h = i->first.history; const size_t t = i->first.tag; if (history(tags[t])) { - cmd = dfa.tcpool.make_add(cmd, abs(m), abs(v), tagtree, h, t); + cmd = dfa.tcpool.make_add(cmd, abs(m), abs(v), thist, h, t); } else { - cmd = dfa.tcpool.make_set(cmd, abs(m), tagtree.last(h, t)); + cmd = dfa.tcpool.make_set(cmd, abs(m), thist.last(h, t)); } } // mark tags with history for (newvers_t::iterator j = newvers.begin(); j != newvers.end(); ++j) { - if (history(tags[j->first.tag])) dfa.mtagvers.insert(abs(j->second)); + if (history(tags[j->first.tag])) { + dfa.mtagvers.insert(abs(j->second)); + } } // update tag versions in closure @@ -452,11 +453,11 @@ void generate_versions(determ_context_t &ctx) const hidx_t h = c->ttran; if (h == HROOT) continue; - const tagver_t *vs = tagpool[c->tvers]; + const tagver_t *vs = tvtbl[c->tvers]; for (size_t t = 0; t < ntag; ++t) { const tagver_t v0 = vs[t], - h0 = tagtree.last(h, t), + h0 = thist.last(h, t), v = history(tags[t]) ? v0 : TAGVER_ZERO; if (h0 == TAGVER_ZERO) { vers[t] = v0; @@ -465,7 +466,7 @@ void generate_versions(determ_context_t &ctx) vers[t] = newvers[x]; } } - c->tvers = tagpool.insert(vers); + c->tvers = tvtbl.insert(vers); } ctx.dc_actions = cmd; diff --git a/re2c/src/dfa/determinization.cc b/re2c/src/dfa/determinization.cc index 2bff8819..5e0a5ab3 100644 --- a/re2c/src/dfa/determinization.cc +++ b/re2c/src/dfa/determinization.cc @@ -13,8 +13,6 @@ #include "src/dfa/dfa.h" #include "src/dfa/determinization.h" #include "src/dfa/dump.h" -#include "src/dfa/tagpool.h" -#include "src/dfa/tagtree.h" #include "src/dfa/tcmd.h" #include "src/nfa/nfa.h" #include "src/re/rule.h" @@ -70,10 +68,10 @@ static uint32_t init_tag_versions(determ_context_t &ctx) const size_t ntags = dfa.tags.size(); // all-zero tag configuration must have static number zero - assert(ZERO_TAGS == ctx.dc_tagpool.insert_const(TAGVER_ZERO)); + assert(ZERO_TAGS == ctx.dc_tagvertbl.insert_const(TAGVER_ZERO)); // initial tag versions: [1 .. N] - const uint32_t INITIAL_TAGS = ctx.dc_tagpool.insert_succ(1); + const uint32_t INITIAL_TAGS = ctx.dc_tagvertbl.insert_succ(1); // other versions: [ .. -(N + 1)] and [N + 1 .. ] dfa.maxtagver = static_cast(ntags); @@ -178,7 +176,7 @@ void warn_nondeterministic_tags(const determ_context_t &ctx) for (size_t t = rule.ltag; t < rule.htag; ++t) { uniq.clear(); for (size_t m = l; m < u; ++m) { - uniq.insert(ctx.dc_tagpool[v[m]][t]); + uniq.insert(ctx.dc_tagvertbl[v[m]][t]); } maxv[t] = std::max(maxv[t], uniq.size()); } @@ -213,11 +211,11 @@ determ_context_t::determ_context_t(const opt_t *opts, Warn &warn , dc_reached() , dc_closure() , dc_prectbl(NULL) - , dc_tagpool(nfa.tags.size()) - , dc_tagtrie() + , dc_tagvertbl(nfa.tags.size()) + , dc_taghistory() , dc_kernels() , dc_buffers(dc_allocator) - , dc_newvers(newver_cmp_t(dc_tagtrie)) + , dc_newvers(newver_cmp_t(dc_taghistory)) , dc_stack_topsort() , dc_stack_linear() , dc_stack_dfs() diff --git a/re2c/src/dfa/determinization.h b/re2c/src/dfa/determinization.h index 3cb28cd9..35a88d46 100644 --- a/re2c/src/dfa/determinization.h +++ b/re2c/src/dfa/determinization.h @@ -10,8 +10,8 @@ #include "src/nfa/nfa.h" #include "src/dfa/dump.h" -#include "src/dfa/tagpool.h" -#include "src/dfa/tagtree.h" +#include "src/dfa/tagver_table.h" +#include "src/dfa/tag_history.h" #include "src/util/forbid_copy.h" #include "src/util/lookup.h" #include "src/util/slab_allocator.h" @@ -60,9 +60,9 @@ struct newver_t struct newver_cmp_t { - tagtree_t &history; + tag_history_t &history; - explicit newver_cmp_t(tagtree_t &h) : history(h) {} + explicit newver_cmp_t(tag_history_t &h) : history(h) {} bool operator()(const newver_t &, const newver_t &) const; }; @@ -105,26 +105,26 @@ typedef lookup_t kernels_t; struct determ_context_t { // determinization input - const opt_t *dc_opts; // options - Warn &dc_warn; // warnings - const std::string &dc_condname; // the name of current condition (with -c) - const nfa_t &dc_nfa; // TNFA + const opt_t *dc_opts; // options + Warn &dc_warn; // warnings + const std::string &dc_condname; // the name of current condition (with -c) + const nfa_t &dc_nfa; // TNFA // determinization output - dfa_t &dc_dfa; // resulting TDFA + dfa_t &dc_dfa; // resulting TDFA // temporary structures used by determinization allocator_t dc_allocator; - uint32_t dc_origin; // from-state of the current transition - uint32_t dc_target; // to-state of the current transition - uint32_t dc_symbol; // alphabet symbol of the current transition - tcmd_t *dc_actions; // tag actions of the current transition + uint32_t dc_origin; // from-state of the current transition + uint32_t dc_target; // to-state of the current transition + uint32_t dc_symbol; // alphabet symbol of the current transition + tcmd_t *dc_actions; // tag actions of the current transition closure_t dc_reached; closure_t dc_closure; - prectable_t *dc_prectbl; // precedence table for Okui POSIX disambiguation - Tagpool dc_tagpool; - tagtree_t dc_tagtrie; // prefix trie of tag histories - kernels_t dc_kernels; // TDFA states under construction + prectable_t *dc_prectbl; // precedence table for Okui POSIX disambiguation + tagver_table_t dc_tagvertbl; + tag_history_t dc_taghistory; // prefix trie of tag histories + kernels_t dc_kernels; // TDFA states under construction kernel_buffers_t dc_buffers; newvers_t dc_newvers; std::stack dc_stack_topsort; diff --git a/re2c/src/dfa/dfa.h b/re2c/src/dfa/dfa.h index a6a17ba1..ce27789a 100644 --- a/re2c/src/dfa/dfa.h +++ b/re2c/src/dfa/dfa.h @@ -17,7 +17,6 @@ namespace re2c struct nfa_t; struct opt_t; -struct Tagpool; struct dfa_state_t { diff --git a/re2c/src/dfa/dump.cc b/re2c/src/dfa/dump.cc index 98fa4870..eaf96e9d 100644 --- a/re2c/src/dfa/dump.cc +++ b/re2c/src/dfa/dump.cc @@ -8,8 +8,8 @@ #include "src/dfa/dfa.h" #include "src/dfa/determinization.h" #include "src/dfa/dump.h" -#include "src/dfa/tagpool.h" -#include "src/dfa/tagtree.h" +#include "src/dfa/tag_history.h" +#include "src/dfa/tagver_table.h" #include "src/dfa/tcmd.h" #include "src/nfa/nfa.h" #include "src/re/rule.h" @@ -21,7 +21,7 @@ namespace re2c static void dump_tcmd_or_tcid(tcmd_t *const *, const tcid_t *, size_t, const tcpool_t &); static const char *tagname(const Tag &); -static void dump_tags(const Tagpool &, const tagtree_t &, hidx_t, uint32_t); +static void dump_tags(const tagver_table_t &, const tag_history_t &, hidx_t, uint32_t); dump_dfa_t::dump_dfa_t(const opt_t *opts) @@ -45,7 +45,7 @@ dump_dfa_t::~dump_dfa_t() } -static void dump_history(const dfa_t &dfa, const tagtree_t &h, hidx_t i) +static void dump_history(const dfa_t &dfa, const tag_history_t &h, hidx_t i) { if (i == HROOT) { fprintf(stderr, " /"); @@ -76,7 +76,8 @@ void dump_dfa_t::state(const determ_context_t &ctx, bool isnew) const uint32_t target = ctx.dc_target; const uint32_t symbol = ctx.dc_symbol; const dfa_t &dfa = ctx.dc_dfa; - const Tagpool &tagpool = ctx.dc_tagpool; + const tagver_table_t &tvtbl = ctx.dc_tagvertbl; + const tag_history_t &thist = ctx.dc_taghistory; uint32_t i; if (target == dfa_t::NIL) return; @@ -96,7 +97,7 @@ void dump_dfa_t::state(const determ_context_t &ctx, bool isnew) i, style, static_cast(c->state - ctx.dc_nfa.states)); if (c->tvers != ZERO_TAGS) { - const tagver_t *vers = tagpool[c->tvers]; + const tagver_t *vers = tvtbl[c->tvers]; const size_t ntag = dfa.tags.size(); for (size_t t = 0; t < ntag; ++t) { @@ -104,7 +105,7 @@ void dump_dfa_t::state(const determ_context_t &ctx, bool isnew) } if (c->tlook != HROOT) { - dump_history(dfa, ctx.dc_tagtrie, c->tlook); + dump_history(dfa, thist, c->tlook); } } @@ -119,7 +120,7 @@ void dump_dfa_t::state(const determ_context_t &ctx, bool isnew) uint32_t i = 0; for (c = b; c != e; ++c, ++i) { fprintf(stderr, " void -> 0:%u:w [style=dotted label=\"", i); - dump_tags(tagpool, ctx.dc_tagtrie, c->ttran, c->tvers); + dump_tags(tvtbl, thist, c->ttran, c->tvers); fprintf(stderr, "\"]\n"); } } @@ -140,7 +141,7 @@ void dump_dfa_t::state(const determ_context_t &ctx, bool isnew) fprintf(stderr, " %u:%u:e -> %s%u:%u:w [label=\"%u", origin, c->origin, prefix, state, i, symbol); - dump_tags(tagpool, ctx.dc_tagtrie, c->ttran, c->tvers); + dump_tags(tvtbl, thist, c->ttran, c->tvers); fprintf(stderr, "\"]\n"); } } @@ -271,25 +272,25 @@ const char *tagname(const Tag &t) } -void dump_tags(const Tagpool &tagpool, const tagtree_t &tagtrie, +void dump_tags(const tagver_table_t &tagvertbl, const tag_history_t &taghistory, hidx_t ttran, uint32_t tvers) { if (ttran == HROOT) return; fprintf(stderr, "/"); - const tagver_t *vers = tagpool[tvers]; - for (size_t i = 0; i < tagpool.ntags; ++i) { + const tagver_t *vers = tagvertbl[tvers]; + for (size_t i = 0; i < tagvertbl.ntags; ++i) { - if (tagtrie.last(ttran, i) == TAGVER_ZERO) { + if (taghistory.last(ttran, i) == TAGVER_ZERO) { continue; } fprintf(stderr, "%d", abs(vers[i])); - for (hidx_t t = ttran; t != HROOT; t = tagtrie.pred(t)) { - if (tagtrie.tag(t) != i) { + for (hidx_t t = ttran; t != HROOT; t = taghistory.pred(t)) { + if (taghistory.tag(t) != i) { continue; } - else if (tagtrie.elem(t) < TAGVER_ZERO) { + else if (taghistory.elem(t) < TAGVER_ZERO) { fprintf(stderr, "↓"); } else if (t > TAGVER_ZERO) { diff --git a/re2c/src/dfa/find_state.cc b/re2c/src/dfa/find_state.cc index 3b68795e..05a057b2 100644 --- a/re2c/src/dfa/find_state.cc +++ b/re2c/src/dfa/find_state.cc @@ -7,7 +7,6 @@ #include "src/dfa/determinization.h" #include "src/dfa/dfa.h" #include "src/dfa/dump.h" -#include "src/dfa/tagpool.h" #include "src/dfa/tcmd.h" #include "src/nfa/nfa.h" #include "src/re/rule.h" @@ -236,19 +235,19 @@ bool equal_lookahead_tags(const kernel_t *x, const kernel_t *y, const determ_con return true; } - const tagtree_t &trie = ctx.dc_tagtrie; - const Tagpool &tagpool = ctx.dc_tagpool; + const tag_history_t &thist = ctx.dc_taghistory; + const tagver_table_t &tvtbl = ctx.dc_tagvertbl; const std::vector &tags = ctx.dc_dfa.tags; for (size_t i = 0; i < x->size; ++i) { const hidx_t xl = x->tlook[i], yl = y->tlook[i]; - for (size_t t = 0; t < tagpool.ntags; ++t) { + for (size_t t = 0; t < tvtbl.ntags; ++t) { if (history(tags[t])) { // compare full tag sequences - if (trie.compare_reversed(xl, yl, t) != 0) return false; + if (thist.compare_reversed(xl, yl, t) != 0) return false; } else { // compare only the last pair of tags - if (trie.last(xl, t) != trie.last(yl, t)) return false; + if (thist.last(xl, t) != thist.last(yl, t)) return false; } } } @@ -293,13 +292,13 @@ bool kernel_map_t::operator()(const kernel_t *x, const kernel_t *y) std::fill(y2x - max, y2x + max, TAGVER_ZERO); for (size_t i = 0; i < n; ++i) { const tagver_t - *xvs = ctx.dc_tagpool[x->tvers[i]], - *yvs = ctx.dc_tagpool[y->tvers[i]]; + *xvs = ctx.dc_tagvertbl[x->tvers[i]], + *yvs = ctx.dc_tagvertbl[y->tvers[i]]; const hidx_t xl = x->tlook[i]; for (size_t t = 0; t < ntag; ++t) { // see note [mapping ignores items with lookahead tags] - if (ctx.dc_tagtrie.last(xl, t) != TAGVER_ZERO + if (ctx.dc_taghistory.last(xl, t) != TAGVER_ZERO && !history(tags[t])) continue; const tagver_t xv = xvs[t], yv = yvs[t]; @@ -407,9 +406,9 @@ tcmd_t *final_actions(determ_context_t &ctx, const clos_t &fin) { dfa_t &dfa = ctx.dc_dfa; const Rule &rule = dfa.rules[fin.state->rule]; - const tagver_t *vers = ctx.dc_tagpool[fin.tvers]; + const tagver_t *vers = ctx.dc_tagvertbl[fin.tvers]; const hidx_t look = fin.tlook; - const tagtree_t &hist = ctx.dc_tagtrie; + const tag_history_t &thist = ctx.dc_taghistory; tcpool_t &tcpool = dfa.tcpool; tcmd_t *copy = NULL, *save = NULL, **p; @@ -418,12 +417,12 @@ tcmd_t *final_actions(determ_context_t &ctx, const clos_t &fin) const Tag &tag = dfa.tags[t]; if (fixed(tag)) continue; - const tagver_t v = abs(vers[t]), l = hist.last(look, t); + const tagver_t v = abs(vers[t]), l = thist.last(look, t); tagver_t &f = dfa.finvers[t]; if (l == TAGVER_ZERO) { copy = tcpool.make_copy(copy, f, v); } else if (history(tag)) { - save = tcpool.make_add(save, f, v, hist, look, t); + save = tcpool.make_add(save, f, v, thist, look, t); } else { save = tcpool.make_set(save, f, l); } diff --git a/re2c/src/dfa/tagtree.cc b/re2c/src/dfa/tag_history.cc similarity index 80% rename from re2c/src/dfa/tagtree.cc rename to re2c/src/dfa/tag_history.cc index d984e50c..b2a82f09 100644 --- a/re2c/src/dfa/tagtree.cc +++ b/re2c/src/dfa/tag_history.cc @@ -2,7 +2,7 @@ #include #include "src/dfa/determinization.h" -#include "src/dfa/tagtree.h" +#include "src/dfa/tag_history.h" namespace re2c @@ -11,22 +11,22 @@ namespace re2c static const tagver_t DELIM = TAGVER_CURSOR - 1; -tagtree_t::tagtree_t(): nodes(), path1(), path2() {} +tag_history_t::tag_history_t(): nodes(), path1(), path2() {} -hidx_t tagtree_t::pred(hidx_t i) const { return nodes[i].pred; } +hidx_t tag_history_t::pred(hidx_t i) const { return nodes[i].pred; } -tag_info_t tagtree_t::info(hidx_t i) const { return nodes[i].info; } +tag_info_t tag_history_t::info(hidx_t i) const { return nodes[i].info; } -tagver_t tagtree_t::elem(hidx_t i) const { return nodes[i].info.neg ? TAGVER_BOTTOM : TAGVER_CURSOR; } +tagver_t tag_history_t::elem(hidx_t i) const { return nodes[i].info.neg ? TAGVER_BOTTOM : TAGVER_CURSOR; } -size_t tagtree_t::tag(hidx_t i) const { return nodes[i].info.idx; } +size_t tag_history_t::tag(hidx_t i) const { return nodes[i].info.idx; } -hidx_t tagtree_t::push(hidx_t idx, tag_info_t info) +hidx_t tag_history_t::push(hidx_t idx, tag_info_t info) { node_t x = {idx, info}; nodes.push_back(x); @@ -34,7 +34,7 @@ hidx_t tagtree_t::push(hidx_t idx, tag_info_t info) } -tagver_t tagtree_t::last(hidx_t i, size_t t) const +tagver_t tag_history_t::last(hidx_t i, size_t t) const { for (; i != HROOT; i = pred(i)) { if (tag(i) == t) return elem(i); @@ -43,7 +43,7 @@ tagver_t tagtree_t::last(hidx_t i, size_t t) const } -int32_t tagtree_t::compare_reversed(hidx_t x, hidx_t y, size_t t) const +int32_t tag_history_t::compare_reversed(hidx_t x, hidx_t y, size_t t) const { // compare in reverse, from tail to head: direction makes // no difference when comparing for exact coincidence @@ -61,7 +61,7 @@ int32_t tagtree_t::compare_reversed(hidx_t x, hidx_t y, size_t t) const } -static void reconstruct_history(const tagtree_t &history, +static void reconstruct_history(const tag_history_t &history, tag_path_t &path, hidx_t idx) { path.clear(); @@ -96,10 +96,10 @@ int32_t precedence(determ_context_t &ctx, return 0; } - tagtree_t &trie = ctx.dc_tagtrie; - tag_path_t &p1 = trie.path1, &p2 = trie.path2; - reconstruct_history(trie, p1, xl); - reconstruct_history(trie, p2, yl); + tag_history_t &thist = ctx.dc_taghistory; + tag_path_t &p1 = thist.path1, &p2 = thist.path2; + reconstruct_history(thist, p1, xl); + reconstruct_history(thist, p2, yl); tag_path_t::const_reverse_iterator i1 = p1.rbegin(), e1 = p1.rend(), j1 = i1, g1, i2 = p2.rbegin(), e2 = p2.rend(), j2 = i2, g2; diff --git a/re2c/src/dfa/tagtree.h b/re2c/src/dfa/tag_history.h similarity index 84% rename from re2c/src/dfa/tagtree.h rename to re2c/src/dfa/tag_history.h index f13bd120..bca3d1d9 100644 --- a/re2c/src/dfa/tagtree.h +++ b/re2c/src/dfa/tag_history.h @@ -1,5 +1,5 @@ -#ifndef _RE2C_DFA_TAGTREE_ -#define _RE2C_DFA_TAGTREE_ +#ifndef _RE2C_DFA_TAG_HISTORY_ +#define _RE2C_DFA_TAG_HISTORY_ #include #include "src/util/c99_stdint.h" @@ -20,7 +20,7 @@ static const hidx_t HROOT = ~0u; typedef std::vector tag_path_t; -struct tagtree_t +struct tag_history_t { // the whole tree of tags found by the epsilon-closure // (a bunch of separate subtrees for each tag with common root) @@ -34,7 +34,7 @@ struct tagtree_t tag_path_t path1; tag_path_t path2; - tagtree_t(); + tag_history_t(); hidx_t pred(hidx_t i) const; tag_info_t info(hidx_t i) const; tagver_t elem(hidx_t i) const; @@ -43,9 +43,9 @@ struct tagtree_t tagver_t last(hidx_t i, size_t t) const; int32_t compare_reversed(hidx_t x, hidx_t y, size_t t) const; - FORBID_COPY(tagtree_t); + FORBID_COPY(tag_history_t); }; } // namespace re2c -#endif // _RE2C_DFA_TAGTREE_ +#endif // _RE2C_DFA_TAG_HISTORY_ diff --git a/re2c/src/dfa/tagpool.cc b/re2c/src/dfa/tagver_table.cc similarity index 76% rename from re2c/src/dfa/tagpool.cc rename to re2c/src/dfa/tagver_table.cc index f2756aac..e4ee24cb 100644 --- a/re2c/src/dfa/tagpool.cc +++ b/re2c/src/dfa/tagver_table.cc @@ -2,7 +2,7 @@ #include // memcpy, memcmp #include -#include "src/dfa/tagpool.h" +#include "src/dfa/tagver_table.h" #include "src/util/hash32.h" namespace re2c @@ -20,14 +20,14 @@ struct eqtag_t }; -Tagpool::Tagpool(size_t n) +tagver_table_t::tagver_table_t(size_t n) : lookup() , ntags(n) , buffer(new tagver_t[n]) {} -Tagpool::~Tagpool() +tagver_table_t::~tagver_table_t() { delete[] buffer; const size_t n = lookup.size(); @@ -37,14 +37,14 @@ Tagpool::~Tagpool() } -uint32_t Tagpool::insert_const(tagver_t ver) +uint32_t tagver_table_t::insert_const(tagver_t ver) { std::fill(buffer, buffer + ntags, ver); return insert(buffer); } -uint32_t Tagpool::insert_succ(tagver_t fst) +uint32_t tagver_table_t::insert_succ(tagver_t fst) { for (uint32_t i = 0; i < ntags; ++i) { buffer[i] = fst++; @@ -53,7 +53,7 @@ uint32_t Tagpool::insert_succ(tagver_t fst) } -uint32_t Tagpool::insert(const tagver_t *tags) +uint32_t tagver_table_t::insert(const tagver_t *tags) { const size_t size = ntags * sizeof(tagver_t); const uint32_t hash = hash32(0, tags, size); @@ -70,7 +70,7 @@ uint32_t Tagpool::insert(const tagver_t *tags) } -const tagver_t *Tagpool::operator[](uint32_t idx) const +const tagver_t *tagver_table_t::operator[](uint32_t idx) const { return lookup[idx]; } diff --git a/re2c/src/dfa/tagpool.h b/re2c/src/dfa/tagver_table.h similarity index 71% rename from re2c/src/dfa/tagpool.h rename to re2c/src/dfa/tagver_table.h index 4f275379..4d584fa6 100644 --- a/re2c/src/dfa/tagpool.h +++ b/re2c/src/dfa/tagver_table.h @@ -1,5 +1,5 @@ -#ifndef _RE2C_DFA_TAGPOOL_ -#define _RE2C_DFA_TAGPOOL_ +#ifndef _RE2C_DFA_TAGVER_TABLE_ +#define _RE2C_DFA_TAGVER_TABLE_ #include #include "src/util/c99_stdint.h" @@ -14,7 +14,7 @@ namespace re2c static const size_t ZERO_TAGS = 0; -struct Tagpool +struct tagver_table_t { private: typedef lookup_t taglookup_t; @@ -24,15 +24,15 @@ public: const size_t ntags; tagver_t *buffer; - explicit Tagpool(size_t n); - ~Tagpool(); + explicit tagver_table_t(size_t n); + ~tagver_table_t(); uint32_t insert_const(tagver_t ver); uint32_t insert_succ(tagver_t fst); uint32_t insert(const tagver_t *tags); const tagver_t *operator[](uint32_t idx) const; - FORBID_COPY(Tagpool); + FORBID_COPY(tagver_table_t); }; } // namespace re2c -#endif // _RE2C_DFA_TAGPOOL_ +#endif // _RE2C_DFA_TAGVER_TABLE_ diff --git a/re2c/src/dfa/tcmd.cc b/re2c/src/dfa/tcmd.cc index 4fffd2d1..9fd9258d 100644 --- a/re2c/src/dfa/tcmd.cc +++ b/re2c/src/dfa/tcmd.cc @@ -157,7 +157,7 @@ tcmd_t *tcpool_t::make_set(tcmd_t *next, tagver_t lhs, tagver_t set) tcmd_t *tcpool_t::make_add(tcmd_t *next, tagver_t lhs, tagver_t rhs, - const tagtree_t &history, hidx_t hidx, size_t tag) + const tag_history_t &history, hidx_t hidx, size_t tag) { size_t hlen = 0; for (hidx_t i = hidx; i != HROOT; i = history.pred(i)) { diff --git a/re2c/src/dfa/tcmd.h b/re2c/src/dfa/tcmd.h index a2203f28..40f70b28 100644 --- a/re2c/src/dfa/tcmd.h +++ b/re2c/src/dfa/tcmd.h @@ -4,7 +4,7 @@ #include #include "src/util/c99_stdint.h" -#include "src/dfa/tagtree.h" +#include "src/dfa/tag_history.h" #include "src/re/tag.h" #include "src/util/lookup.h" #include "src/util/slab_allocator.h" @@ -43,7 +43,7 @@ public: tcpool_t(); tcmd_t *make_copy(tcmd_t *next, tagver_t lhs, tagver_t rhs); tcmd_t *make_set(tcmd_t *next, tagver_t lhs, tagver_t set); - tcmd_t *make_add(tcmd_t *next, tagver_t lhs, tagver_t rhs, const tagtree_t &history, hidx_t hidx, size_t tag); + tcmd_t *make_add(tcmd_t *next, tagver_t lhs, tagver_t rhs, const tag_history_t &history, hidx_t hidx, size_t tag); tcmd_t *copy_add(tcmd_t *next, tagver_t lhs, tagver_t rhs, const tagver_t *history); tcid_t insert(const tcmd_t *tcmd); const tcmd_t *operator[](tcid_t id) const; -- 2.40.0