- Implemented first pass as getFilterExpression.
This commit is contained in:
Paul Beckingham 2014-04-21 16:24:19 -04:00
parent b690a8d2a3
commit 997bdbdb90
2 changed files with 79 additions and 7 deletions

View file

@ -510,6 +510,80 @@ Tree* A3t::captureFirst (const std::string& arg)
return t; return t;
} }
////////////////////////////////////////////////////////////////////////////////
const std::string A3t::getFilterExpression () const
{
// Locate and extract the filter elements.
std::string filter = "";
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
// TODO Insert implicit "and", "(" and ")" operators.
if ((*i)->hasTag ("FILTER"))
{
if ((*i)->hasTag ("ID"))
{
// TODO Construct sequence clause clause.
if (filter != "")
filter += ' ';
filter += "<id>";
}
else if ((*i)->hasTag ("UUID"))
{
// TODO Construct sequence clause clause.
if (filter != "")
filter += ' ';
filter += "<uuid>";
}
else if ((*i)->hasTag ("ATTMOD"))
{
// TODO name.mod:value --> name <op> value
if (filter != "")
filter += ' ';
filter += "<attmod>";
}
else if ((*i)->hasTag ("ATTRIBUTE"))
{
// TODO name:value --> name == value
if (filter != "")
filter += ' ';
filter += "<attribute>";
}
else if ((*i)->hasTag ("TAG"))
{
// TODO +tag --> _hastag_ tag
// TODO -tag --> _notag_ tag
if (filter != "")
filter += ' ';
filter += "<tag>";
}
else if ((*i)->hasTag ("PATTERN"))
{
// TODO /pattern/ --> description ~ pattern
if (filter != "")
filter += ' ';
filter += "<pattern>";
}
else
{
if (filter != "")
filter += ' ';
filter += (*i)->attribute ("raw");
}
}
}
return filter;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// /pattern/ // /pattern/
void A3t::findPattern () void A3t::findPattern ()

View file

@ -56,6 +56,11 @@ public:
void injectDefaults (); void injectDefaults ();
Tree* captureFirst (const std::string&); Tree* captureFirst (const std::string&);
const std::string getFilterExpression () const;
// TODO Extract words
// TODO Extract modifications
private: private:
void findTerminator (); void findTerminator ();
void findPattern (); void findPattern ();
@ -68,13 +73,6 @@ private:
void findModifications (); void findModifications ();
void validate (); void validate ();
// TODO Extract filter
// TODO Extract words
// TODO Extract modifications
// TODO Prepare infix
// TODO Expand operators
// TODO Expand sequence
private: private:
Tree* _tree; Tree* _tree;
std::multimap <std::string, std::string> _entities; std::multimap <std::string, std::string> _entities;