From: Ulya Trofimovich Date: Fri, 17 Apr 2015 16:15:31 +0000 (+0100) Subject: Continued adding "--skeleton" switch. X-Git-Tag: 0.15~300 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92e33e31bbfd8524ae3de3b224dd04addc70b88e;p=re2c Continued adding "--skeleton" switch. Renamed: 'Prefix' -> 'Path'. --- diff --git a/re2c/skeleton.cc b/re2c/skeleton.cc index 1a99edd3..30a0398b 100644 --- a/re2c/skeleton.cc +++ b/re2c/skeleton.cc @@ -78,7 +78,7 @@ unsigned long Skeleton::count () } /* -void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector & xs, std::vector & ys) +void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector & xs, std::vector & ys) { if (is_final (s) || is_default (s)) { @@ -106,7 +106,7 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector s->visited = true; for (SkeletonState::go_t::iterator i = s->go.begin (); i != s->go.end (); ++i) { - std::vector zs; + std::vector zs; for (uint j = 0; j < xs.size (); ++j) { const bool is_accepting = s->rule != ~0u; @@ -121,12 +121,12 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector for (uint k = 0; k < i->second.size (); ++k) { z.push_back (i->second[k].first); - zs.push_back (Prefix (z, l, r)); + zs.push_back (Path (z, l, r)); if (i->second[k].first != i->second[k].second) { z.pop_back (); z.push_back (i->second[k].second); - zs.push_back (Prefix (z, l, r)); + zs.push_back (Path (z, l, r)); } z.pop_back (); } @@ -138,7 +138,7 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector } */ -void update (Prefix & p, SkeletonState * s) +void update (Path & p, SkeletonState * s) { if (s->rule != ~0u) { @@ -147,7 +147,7 @@ void update (Prefix & p, SkeletonState * s) } } -void append (Prefix & p1, const Prefix & p2) +void append (Path & p1, const Path & p2) { if (p2.rule != ~0u) { @@ -171,7 +171,7 @@ void dump_paths (DataFile & o, uint ind, const std::vector & path) o.file << "\n"; } -void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & prefixes, std::vector & results) +void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & prefixes, std::vector & results) { if (s == NULL) { @@ -187,7 +187,7 @@ void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & if (s->path != NULL) { - std::vector zs (prefixes); + std::vector zs (prefixes); for (uint i = 0; i < zs.size (); ++i) { append (zs[i], * s->path); @@ -216,7 +216,7 @@ void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & uint k = 0; for (SkeletonState::go_t::iterator i = s->go.begin (); i != s->go.end (); ++i) { - std::vector zs; + std::vector zs; for (uint j = 0; j < i->second.size (); ++j) { zs.push_back (prefixes[k++]); @@ -226,7 +226,7 @@ void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & generate (o, ind, i->first, zs, results); if (s->path == NULL && i->first->path != NULL) { - s->path = new Prefix (std::vector (1, i->second[0]), 0, s->rule); + s->path = new Path (std::vector (1, i->second[0]), 0, s->rule); append (* s->path, * i->first->path); } } @@ -245,11 +245,11 @@ void Skeleton::generate_data (DataFile & o, uint ind, std::vector & resu { if (states[i].is_end ()) { - states[i].path = new Prefix (std::vector (), 0, states[i].rule); + states[i].path = new Path (std::vector (), 0, states[i].rule); } } - std::vector prefixes; - prefixes.push_back (Prefix (std::vector (), 0, ~0)); + std::vector prefixes; + prefixes.push_back (Path (std::vector (), 0, ~0)); generate (o, ind, states, prefixes, results); diff --git a/re2c/skeleton.h b/re2c/skeleton.h index 35accabe..f01e5865 100644 --- a/re2c/skeleton.h +++ b/re2c/skeleton.h @@ -10,12 +10,12 @@ namespace re2c { -struct Prefix +struct Path { std::vector chars; uint length; uint rule; - inline Prefix (const std::vector & cs, uint l, uint r) + inline Path (const std::vector & cs, uint l, uint r) : chars (cs) , length (l) , rule (r) @@ -27,7 +27,7 @@ struct Result uint processed; uint consumed; uint rule; - inline explicit Result (const Prefix & p) + inline explicit Result (const Path & p) : processed (p.chars.size ()) , consumed (p.length) , rule (p.rule) @@ -40,7 +40,7 @@ struct SkeletonState go_t go; uint rule; uchar visited; - Prefix * path; + Path * path; inline SkeletonState () : go () , rule (~0u) @@ -67,10 +67,10 @@ struct Skeleton unsigned long count_data (SkeletonState * s, unsigned long count); void skeleton_emit_prolog (OutputFile & o, uint ind, const char * data_name); void skeleton_emit_epilog (OutputFile & o, uint ind); -void update (Prefix & p, SkeletonState * s); -void append (Prefix & p1, const Prefix * p2); +void update (Path & p, SkeletonState * s); +void append (Path & p1, const Path * p2); void dump_paths (DataFile & o, uint ind, const std::vector & path); -void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & prefixes, std::vector & results); +void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & prefixes, std::vector & results); } // namespace re2c