From c1f4cc35547614b51ee373ea0a972e3af4593607 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 21 Jun 2015 21:08:42 -0400 Subject: [PATCH] CLI2: Added ::decomposeModSubstitutions --- src/CLI2.cpp | 40 +++++++++++++--------------------------- src/CLI2.h | 2 +- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index d80075c90..ae4134276 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -536,9 +536,7 @@ void CLI2::prepareFilter (bool applyContext) decomposeModAttributeModifiers (); */ decomposeModTags (); -/* decomposeModSubstitutions (); -*/ if (changes && context.config.getInteger ("debug.parser") >= 3) @@ -1667,51 +1665,39 @@ void CLI2::decomposeModTags () if (changes && context.config.getInteger ("debug.parser") >= 3) - context.debug (dump ("CLI2::analyze decomposeModTags")); + context.debug (dump ("CLI2::prepareFilter decomposeModTags")); } -/* //////////////////////////////////////////////////////////////////////////////// void CLI2::decomposeModSubstitutions () { bool changes = false; for (auto& a : _args) { - if (a.hasTag ("TERMINATOR")) - break; - - if (a.hasTag ("MODIFICATION")) + if (a._lextype == Lexer::Type::substitution && + a.hasTag ("MODIFICATION")) { std::string raw = a.attribute ("raw"); - Nibbler n (raw); - std::string from; - std::string to; - bool global = false; - if (n.getQuoted ('/', from) && - n.backN () && - n.getQuoted ('/', to)) + if (! Directory (raw).exists ()) { - if (n.skip ('g')) - global = true; + auto slash1 = raw.find ("/"); + auto slash2 = raw.find ("/", slash1 + 1); + auto slash3 = raw.find ("/", slash2 + 1); - if (n.depleted () && - ! Directory (raw).exists ()) - { - a.tag ("SUBSTITUTION"); - a.attribute ("from", from); - a.attribute ("to", to); - a.attribute ("global", global ? 1 : 0); - changes = true; - } + a.attribute ("from", raw.substr (slash1 + 1, slash2 - slash1 - 1)); + a.attribute ("to", raw.substr (slash2 + 1, slash3 - slash2 - 1)); + a.attribute ("global", raw.substr (slash3 + 1) == "g" ? 1 : 0); + changes = true; } } } if (changes && context.config.getInteger ("debug.parser") >= 3) - context.debug (dump ("CLI2::analyze decomposeModSubstitutions")); + context.debug (dump ("CLI2::prepareFilter decomposeModSubstitutions")); } +/* //////////////////////////////////////////////////////////////////////////////// bool CLI2::isUUIDList (const std::string& raw) const { diff --git a/src/CLI2.h b/src/CLI2.h index 70dd178b4..4640d118a 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -116,9 +116,9 @@ private: void decomposeModAttributeModifiers (); */ void decomposeModTags (); -/* void decomposeModSubstitutions (); +/* bool isUUIDList (const std::string&) const; // These methods come up iwht reasons not to Lex a token. Probably no longer needed.