mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
A3t
- Implemented first pass as getFilterExpression.
This commit is contained in:
parent
b690a8d2a3
commit
997bdbdb90
2 changed files with 79 additions and 7 deletions
74
src/A3t.cpp
74
src/A3t.cpp
|
@ -510,6 +510,80 @@ Tree* A3t::captureFirst (const std::string& arg)
|
|||
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/
|
||||
void A3t::findPattern ()
|
||||
|
|
12
src/A3t.h
12
src/A3t.h
|
@ -56,6 +56,11 @@ public:
|
|||
void injectDefaults ();
|
||||
Tree* captureFirst (const std::string&);
|
||||
|
||||
const std::string getFilterExpression () const;
|
||||
|
||||
// TODO Extract words
|
||||
// TODO Extract modifications
|
||||
|
||||
private:
|
||||
void findTerminator ();
|
||||
void findPattern ();
|
||||
|
@ -68,13 +73,6 @@ private:
|
|||
void findModifications ();
|
||||
void validate ();
|
||||
|
||||
// TODO Extract filter
|
||||
// TODO Extract words
|
||||
// TODO Extract modifications
|
||||
// TODO Prepare infix
|
||||
// TODO Expand operators
|
||||
// TODO Expand sequence
|
||||
|
||||
private:
|
||||
Tree* _tree;
|
||||
std::multimap <std::string, std::string> _entities;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue