From: Ulya Trofimovich Date: Wed, 15 Apr 2015 14:02:23 +0000 (+0100) Subject: Continued adding "--skeleton" switch. X-Git-Tag: 0.15~305 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba42821176d955e91c854625f952fd4614f889f4;p=re2c Continued adding "--skeleton" switch. Code cleanup. --- diff --git a/re2c/skeleton.cc b/re2c/skeleton.cc index 95efc7ca..bdede65f 100644 --- a/re2c/skeleton.cc +++ b/re2c/skeleton.cc @@ -135,6 +135,10 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, std::vectorpath = new Prefix (std::vector (), 0, s->rule); + } for (uint i = 0; i < xs.size (); ++i) { o.file << indent (ind); @@ -152,10 +156,6 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, std::vectorrule : xs[i].rule; ys.push_back (Result (processed, consumed, rule)); - if (is_final (s)) - { - s->path = new Prefix (std::vector (), 0, s->rule); - } } } else if (s->visited < 2) @@ -164,19 +164,16 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, std::vectorrule != ~0u; if (s->path != NULL) { + const bool is_accepting_path = s->path->rule != ~0u; std::vector zs (xs); for (uint i = 0; i < zs.size (); ++i) { - zs[i].length = s->path->rule != ~0u + zs[i].length = is_accepting_path ? zs[i].chars.size () + s->path->length - : is_accepting - ? zs[i].chars.size () - : zs[i].length; - zs[i].rule = s->path->rule != ~0u + : zs[i].length; + zs[i].rule = is_accepting_path ? s->path->rule - : is_accepting - ? s->rule - : zs[i].rule; + : zs[i].rule; for (int j = s->path->chars.size () - 1; j >= 0; --j) { zs[i].chars.push_back (s->path->chars[j]);