mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 23:46:42 +02:00
A3t
- Stubbed ::patchInfix to insert missing and implied logical operators.
This commit is contained in:
parent
c1d02a7730
commit
2770f0388c
2 changed files with 47 additions and 9 deletions
53
src/A3t.cpp
53
src/A3t.cpp
|
@ -517,18 +517,16 @@ Tree* A3t::captureFirst (const std::string& arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string A3t::getFilterExpression () const
|
const std::string A3t::getFilterExpression ()
|
||||||
{
|
{
|
||||||
// Locate and extract the filter elements.
|
// Insert implicit "and", "(" and ")" operators.
|
||||||
std::string filter = "";
|
patchInfix ();
|
||||||
std::vector <Tree*>::iterator i;
|
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
|
||||||
{
|
|
||||||
// TODO Insert implicit "and", "(" and ")" operators.
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Construct an efficient ID/UUID clause.
|
// TODO Construct an efficient ID/UUID clause.
|
||||||
|
|
||||||
|
// Locate and extract the filter elements.
|
||||||
|
std::string filter = "";
|
||||||
|
std::vector <Tree*>::iterator i;
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||||
{
|
{
|
||||||
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
||||||
|
@ -1080,6 +1078,45 @@ void A3t::findModifications ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Insert 'and' operators between adjacent non-operators.
|
||||||
|
//
|
||||||
|
// ) <non-op> --> ) and <non-op>
|
||||||
|
// <non-op> ( --> <non-op> <and> (
|
||||||
|
// ) ( --> ) and (
|
||||||
|
// <non-op> <non-op> --> <non-op> and <non-op>
|
||||||
|
//
|
||||||
|
void A3t::patchInfix ()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (input.size () == 1)
|
||||||
|
return input;
|
||||||
|
|
||||||
|
Arg previous ("?", Arg::cat_op);
|
||||||
|
|
||||||
|
A3 modified;
|
||||||
|
modified._limit = input._limit;
|
||||||
|
|
||||||
|
std::vector <Arg>::const_iterator arg;
|
||||||
|
for (arg = input.begin (); arg != input.end (); ++arg)
|
||||||
|
{
|
||||||
|
// Old-style filters need 'and' conjunctions.
|
||||||
|
if ((previous._category != Arg::cat_op || previous._raw == ")") &&
|
||||||
|
(arg->_category != Arg::cat_op || arg->_raw == "("))
|
||||||
|
{
|
||||||
|
modified.push_back (Arg ("and", Arg::cat_op));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now insert the adjacent non-operator.
|
||||||
|
modified.push_back (*arg);
|
||||||
|
previous = *arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
modified.dump ("A3::infix");
|
||||||
|
return modified;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Validate the parse tree.
|
// Validate the parse tree.
|
||||||
void A3t::validate ()
|
void A3t::validate ()
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
void injectDefaults ();
|
void injectDefaults ();
|
||||||
Tree* captureFirst (const std::string&);
|
Tree* captureFirst (const std::string&);
|
||||||
|
|
||||||
const std::string getFilterExpression () const;
|
const std::string getFilterExpression ();
|
||||||
const std::vector <std::string> getWords () const;
|
const std::vector <std::string> getWords () const;
|
||||||
// TODO Extract modifications
|
// TODO Extract modifications
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ private:
|
||||||
void findOperator ();
|
void findOperator ();
|
||||||
void findFilter ();
|
void findFilter ();
|
||||||
void findModifications ();
|
void findModifications ();
|
||||||
|
void patchInfix ();
|
||||||
void validate ();
|
void validate ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue