- Implemented the stubbed outline of ::findMissingOperators, for injecting
  'and' or 'or' into filter expressions, where needed.
This commit is contained in:
Paul Beckingham 2014-05-20 23:49:41 -04:00
parent 10d08ad4f9
commit 195fa20a48
2 changed files with 37 additions and 0 deletions

View file

@ -149,6 +149,7 @@ Tree* A3t::parse ()
findModifications ();
findPlainArgs ();
findMissingOperators ();
validate ();
@ -1361,6 +1362,41 @@ void A3t::findPlainArgs ()
}
}
////////////////////////////////////////////////////////////////////////////////
void A3t::findMissingOperators ()
{
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
{
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need
// an "and" operator inserted between them.
//
// ) <non-op> --> ) and <non-op>
// <non-op> ( --> <non-op> <and> (
// ) ( --> ) and (
// <non-op> <non-op> --> <non-op> and <non-op>
//
if (i != prev &&
(((*prev)->hasTag ("FILTER") && ! (*prev)->hasTag ("OP")) || (*prev)->attribute ("raw") == ")") &&
(! (*i)->hasTag ("OP") || (*i)->attribute ("raw") == "("))
{
std::cout << "# missingOperator '"
<< (*prev)->attribute ("raw")
<< " "
<< (*i)->attribute ("raw")
<< "' --> '"
<< (*prev)->attribute ("raw")
<< " and "
<< (*i)->attribute ("raw")
<< "'\n";
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Validate the parse tree.
void A3t::validate ()

View file

@ -72,6 +72,7 @@ private:
void findFilter ();
void findModifications ();
void findPlainArgs ();
void findMissingOperators ();
void validate ();
private: