CLI2: Added ::decomposeModSubstitutions

This commit is contained in:
Paul Beckingham 2015-06-21 21:08:42 -04:00
parent b4b15c7f45
commit c1f4cc3554
2 changed files with 14 additions and 28 deletions

View file

@ -536,9 +536,7 @@ void CLI2::prepareFilter (bool applyContext)
decomposeModAttributeModifiers (); decomposeModAttributeModifiers ();
*/ */
decomposeModTags (); decomposeModTags ();
/*
decomposeModSubstitutions (); decomposeModSubstitutions ();
*/
if (changes && if (changes &&
context.config.getInteger ("debug.parser") >= 3) context.config.getInteger ("debug.parser") >= 3)
@ -1667,51 +1665,39 @@ void CLI2::decomposeModTags ()
if (changes && if (changes &&
context.config.getInteger ("debug.parser") >= 3) context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze decomposeModTags")); context.debug (dump ("CLI2::prepareFilter decomposeModTags"));
} }
/*
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI2::decomposeModSubstitutions () void CLI2::decomposeModSubstitutions ()
{ {
bool changes = false; bool changes = false;
for (auto& a : _args) for (auto& a : _args)
{ {
if (a.hasTag ("TERMINATOR")) if (a._lextype == Lexer::Type::substitution &&
break; a.hasTag ("MODIFICATION"))
if (a.hasTag ("MODIFICATION"))
{ {
std::string raw = a.attribute ("raw"); std::string raw = a.attribute ("raw");
Nibbler n (raw); if (! Directory (raw).exists ())
std::string from;
std::string to;
bool global = false;
if (n.getQuoted ('/', from) &&
n.backN () &&
n.getQuoted ('/', to))
{ {
if (n.skip ('g')) auto slash1 = raw.find ("/");
global = true; auto slash2 = raw.find ("/", slash1 + 1);
auto slash3 = raw.find ("/", slash2 + 1);
if (n.depleted () && a.attribute ("from", raw.substr (slash1 + 1, slash2 - slash1 - 1));
! Directory (raw).exists ()) a.attribute ("to", raw.substr (slash2 + 1, slash3 - slash2 - 1));
{ a.attribute ("global", raw.substr (slash3 + 1) == "g" ? 1 : 0);
a.tag ("SUBSTITUTION");
a.attribute ("from", from);
a.attribute ("to", to);
a.attribute ("global", global ? 1 : 0);
changes = true; changes = true;
} }
} }
} }
}
if (changes && if (changes &&
context.config.getInteger ("debug.parser") >= 3) 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 bool CLI2::isUUIDList (const std::string& raw) const
{ {

View file

@ -116,9 +116,9 @@ private:
void decomposeModAttributeModifiers (); void decomposeModAttributeModifiers ();
*/ */
void decomposeModTags (); void decomposeModTags ();
/*
void decomposeModSubstitutions (); void decomposeModSubstitutions ();
/*
bool isUUIDList (const std::string&) const; bool isUUIDList (const std::string&) const;
// These methods come up iwht reasons not to Lex a token. Probably no longer needed. // These methods come up iwht reasons not to Lex a token. Probably no longer needed.