diff --git a/src/A3t.cpp b/src/A3t.cpp index bfa766f42..56263cd18 100644 --- a/src/A3t.cpp +++ b/src/A3t.cpp @@ -519,18 +519,31 @@ Tree* A3t::captureFirst (const std::string& arg) //////////////////////////////////////////////////////////////////////////////// const std::string A3t::getFilterExpression () { - // Insert implicit "and", "(" and ")" operators. - patchInfix (); - // TODO Construct an efficient ID/UUID clause. // Locate and extract the filter elements. std::string filter = ""; + std::vector ::iterator prev = _tree->_branches.begin (); std::vector ::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. + // + // ) --> ) and + // ( --> ( + // ) ( --> ) and ( + // --> and + // + if (i != prev && + (((*prev)->hasTag ("FILTER") && ! (*prev)->hasTag ("OP")) || (*prev)->attribute ("raw") == ")") && + (! (*i)->hasTag ("OP") || (*i)->attribute ("raw") == "(")) + { + filter += " AND"; + } + if ((*i)->hasTag ("ID")) { // TODO Construct sequence clause clause. @@ -707,6 +720,8 @@ const std::string A3t::getFilterExpression () filter += (*i)->attribute ("raw"); } + + prev = i; } } @@ -1200,45 +1215,6 @@ void A3t::findModifications () } } -//////////////////////////////////////////////////////////////////////////////// -// Insert 'and' operators between adjacent non-operators. -// -// ) --> ) and -// ( --> ( -// ) ( --> ) and ( -// --> and -// -void A3t::patchInfix () -{ -/* - if (input.size () == 1) - return input; - - Arg previous ("?", Arg::cat_op); - - A3 modified; - modified._limit = input._limit; - - std::vector ::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 () diff --git a/src/A3t.h b/src/A3t.h index ef314dbc9..fc9e24509 100644 --- a/src/A3t.h +++ b/src/A3t.h @@ -71,7 +71,6 @@ private: void findOperator (); void findFilter (); void findModifications (); - void patchInfix (); void validate (); private: