- Stubbed ::patchInfix to insert missing and implied logical operators.
This commit is contained in:
Paul Beckingham 2014-04-26 14:47:53 -07:00
parent c1d02a7730
commit 2770f0388c
2 changed files with 47 additions and 9 deletions

View file

@ -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.
std::string filter = "";
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
// TODO Insert implicit "and", "(" and ")" operators.
}
// Insert implicit "and", "(" and ")" operators.
patchInfix ();
// 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)
{
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.
void A3t::validate ()

View file

@ -57,7 +57,7 @@ public:
void injectDefaults ();
Tree* captureFirst (const std::string&);
const std::string getFilterExpression () const;
const std::string getFilterExpression ();
const std::vector <std::string> getWords () const;
// TODO Extract modifications
@ -71,6 +71,7 @@ private:
void findOperator ();
void findFilter ();
void findModifications ();
void patchInfix ();
void validate ();
private: