- Implemented ::unsweetenPatterns.
This commit is contained in:
Paul Beckingham 2014-10-16 00:53:59 -04:00
parent 932865d3b5
commit 8d359ddd70
2 changed files with 40 additions and 1 deletions

View file

@ -294,7 +294,8 @@ const std::string CLI::getFilter ()
unsweetenTags ();
unsweetenAttributes ();
unsweetenAttributeModifiers ();
// TODO all the other types: pattern, id, uuid ...
unsweetenPatterns ();
// TODO all the other types: id, uuid ...
std::string filter = "";
if (_args.size ())
@ -801,6 +802,43 @@ void CLI::unsweetenAttributeModifiers ()
_args = reconstructed;
}
////////////////////////////////////////////////////////////////////////////////
// /pattern/ --> description ~ pattern
void CLI::unsweetenPatterns ()
{
std::vector <A> reconstructed;
std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
Nibbler n (a->attribute ("raw"));
std::string pattern;
if (n.getQuoted ('/', pattern) &&
n.depleted () &&
pattern.length () > 0)
{
A lhs ("argPattern", "description");
lhs.tag ("ATT");
lhs.tag ("FILTER");
reconstructed.push_back (lhs);
A op ("argPattern", "~");
op.tag ("OP");
op.tag ("FILTER");
reconstructed.push_back (op);
A rhs ("argPattern", "'" + pattern + "'");
rhs.tag ("LITERAL");
rhs.tag ("FILTER");
reconstructed.push_back (rhs);
}
else
reconstructed.push_back (*a);
}
_args = reconstructed;
}
////////////////////////////////////////////////////////////////////////////////
void CLI::dump (const std::string& label) const
{

View file

@ -79,6 +79,7 @@ private:
void unsweetenTags ();
void unsweetenAttributes ();
void unsweetenAttributeModifiers ();
void unsweetenPatterns ();
void dump (const std::string&) const;
public: