- Implemented ::decomposeModЅubstitutions.
This commit is contained in:
Paul Beckingham 2014-10-20 02:03:03 -04:00
parent 5dcc415057
commit 6dea38806b
2 changed files with 35 additions and 15 deletions

View file

@ -304,6 +304,7 @@ void CLI::analyze ()
decomposeModAttributes (); decomposeModAttributes ();
decomposeModAttributeModifiers (); decomposeModAttributeModifiers ();
decomposeModTags (); decomposeModTags ();
decomposeModSubstitutions ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1179,7 +1180,6 @@ void CLI::desugarUUIDs ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModAttributes () void CLI::decomposeModAttributes ()
{ {
std::vector <A> reconstructed;
std::vector <A>::iterator a; std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a) for (a = _args.begin (); a != _args.end (); ++a)
{ {
@ -1229,17 +1229,12 @@ void CLI::decomposeModAttributes ()
} }
} }
} }
reconstructed.push_back (*a);
} }
_args = reconstructed;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModAttributeModifiers () void CLI::decomposeModAttributeModifiers ()
{ {
std::vector <A> reconstructed;
std::vector <A>::iterator a; std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a) for (a = _args.begin (); a != _args.end (); ++a)
{ {
@ -1309,17 +1304,12 @@ void CLI::decomposeModAttributeModifiers ()
} }
} }
} }
reconstructed.push_back (*a);
} }
_args = reconstructed;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModTags () void CLI::decomposeModTags ()
{ {
std::vector <A> reconstructed;
std::vector <A>::iterator a; std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a) for (a = _args.begin (); a != _args.end (); ++a)
{ {
@ -1339,11 +1329,40 @@ void CLI::decomposeModTags ()
a->tag ("TAG"); a->tag ("TAG");
} }
} }
reconstructed.push_back (*a);
} }
}
_args = reconstructed;
////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModSubstitutions ()
{
std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
if (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 (n.skip ('g'))
global = true;
if (n.depleted () &&
! Directory (raw).exists ())
{
a->tag ("SUBSTITUTION");
a->attribute ("from", from);
a->attribute ("to", to);
a->attribute ("global", global ? 1 : 0);
}
}
}
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -89,6 +89,7 @@ private:
void decomposeModAttributes (); void decomposeModAttributes ();
void decomposeModAttributeModifiers (); void decomposeModAttributeModifiers ();
void decomposeModTags (); void decomposeModTags ();
void decomposeModSubstitutions ();
public: public:
std::multimap <std::string, std::string> _entities; std::multimap <std::string, std::string> _entities;