CLI
- Implemented ::unsweetenPatterns.
This commit is contained in:
40
src/CLI.cpp
40
src/CLI.cpp
@@ -294,7 +294,8 @@ const std::string CLI::getFilter ()
|
|||||||
unsweetenTags ();
|
unsweetenTags ();
|
||||||
unsweetenAttributes ();
|
unsweetenAttributes ();
|
||||||
unsweetenAttributeModifiers ();
|
unsweetenAttributeModifiers ();
|
||||||
// TODO all the other types: pattern, id, uuid ...
|
unsweetenPatterns ();
|
||||||
|
// TODO all the other types: id, uuid ...
|
||||||
|
|
||||||
std::string filter = "";
|
std::string filter = "";
|
||||||
if (_args.size ())
|
if (_args.size ())
|
||||||
@@ -801,6 +802,43 @@ void CLI::unsweetenAttributeModifiers ()
|
|||||||
_args = reconstructed;
|
_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
|
void CLI::dump (const std::string& label) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ private:
|
|||||||
void unsweetenTags ();
|
void unsweetenTags ();
|
||||||
void unsweetenAttributes ();
|
void unsweetenAttributes ();
|
||||||
void unsweetenAttributeModifiers ();
|
void unsweetenAttributeModifiers ();
|
||||||
|
void unsweetenPatterns ();
|
||||||
void dump (const std::string&) const;
|
void dump (const std::string&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user