From e03a3c9d22b3cedc7c94f9693e93a5b831263d88 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Fri, 17 Apr 2015 18:51:29 +0100 Subject: [PATCH] Continued adding "--skeleton" switch. Simplified construction of prefixes. --- re2c/skeleton.cc | 16 +++++----------- re2c/skeleton.h | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/re2c/skeleton.cc b/re2c/skeleton.cc index 30a0398b..dfe05311 100644 --- a/re2c/skeleton.cc +++ b/re2c/skeleton.cc @@ -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, const std::vector & prefixes, std::vector & results) { if (s == NULL) { @@ -202,24 +202,19 @@ void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & pr out_arrows += i->second.size (); } - const uint prefixes_size = prefixes.size (); - for (uint i = 0; prefixes.size () < out_arrows; ++i) - { - prefixes.push_back (prefixes[i]); - } - for (; out_arrows < prefixes.size (); ++out_arrows) { s->go.begin ()->second.push_back (s->go.begin ()->second.back ()); } uint k = 0; + const uint prefixes_size = prefixes.size (); for (SkeletonState::go_t::iterator i = s->go.begin (); i != s->go.end (); ++i) { std::vector zs; - for (uint j = 0; j < i->second.size (); ++j) + for (uint j = 0; j < i->second.size (); ++j, ++k) { - zs.push_back (prefixes[k++]); + zs.push_back (prefixes[k % prefixes_size]); update (zs[j], s); zs[j].chars.push_back (i->second[j]); } @@ -230,7 +225,6 @@ void generate (DataFile & o, uint ind, SkeletonState * s, std::vector & pr append (* s->path, * i->first->path); } } - prefixes.resize (prefixes_size, prefixes[0]); } s->visited--; @@ -262,7 +256,7 @@ void Skeleton::generate_data (DataFile & o, uint ind, std::vector & resu void Skeleton::emit_data (DataFile & o) { - fprintf (stderr, "%lx\n%lx\n", 0xFFFFffffFFFFffff, count ()); +// fprintf (stderr, "%lx\n%lx\n", 0xFFFFffffFFFFffff, count ()); uint ind = 0; std::string yyctype; diff --git a/re2c/skeleton.h b/re2c/skeleton.h index f01e5865..29fd23e4 100644 --- a/re2c/skeleton.h +++ b/re2c/skeleton.h @@ -70,7 +70,7 @@ void skeleton_emit_epilog (OutputFile & o, uint ind); 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, const std::vector & prefixes, std::vector & results); } // namespace re2c -- 2.40.0