CLI2: Added ::insertJunctions

This commit is contained in:
Paul Beckingham 2015-06-21 20:15:05 -04:00
parent cd8eb4b1b0
commit 706ca72a75
2 changed files with 9 additions and 13 deletions

View file

@ -521,10 +521,10 @@ void CLI2::prepareFilter (bool applyContext)
findStrayModifications (); findStrayModifications ();
desugarFilterAttributes (); desugarFilterAttributes ();
desugarFilterPatterns (); desugarFilterPatterns ();
/*
insertJunctions (); // Deliberately after all desugar calls. insertJunctions (); // Deliberately after all desugar calls.
// Decompose the elements for MODIFICATIONs. // Decompose the elements for MODIFICATIONs.
/*
decomposeModAttributes (); decomposeModAttributes ();
decomposeModAttributeModifiers (); decomposeModAttributeModifiers ();
decomposeModTags (); decomposeModTags ();
@ -1360,7 +1360,6 @@ void CLI2::desugarFilterPlainArgs ()
} }
} }
/*
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an // Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an
// "and" operator inserted between them. // "and" operator inserted between them.
@ -1373,8 +1372,9 @@ void CLI2::desugarFilterPlainArgs ()
void CLI2::insertJunctions () void CLI2::insertJunctions ()
{ {
bool changes = false; bool changes = false;
std::vector <A> reconstructed; std::vector <A2> reconstructed;
auto prev = _args.begin (); auto prev = _args.begin ();
for (auto a = _args.begin (); a != _args.end (); ++a) for (auto a = _args.begin (); a != _args.end (); ++a)
{ {
if (a->hasTag ("FILTER")) if (a->hasTag ("FILTER"))
@ -1386,14 +1386,13 @@ void CLI2::insertJunctions ()
// Insert AND between terms. // Insert AND between terms.
else if (a != prev) else if (a != prev)
{ {
if ((! prev->hasTag ("OP") && a->attribute ("raw") == "(") || if ((prev->_lextype != Lexer::Type::op && a->attribute ("raw") == "(") ||
(! prev->hasTag ("OP") && ! a->hasTag ("OP")) || (prev->_lextype != Lexer::Type::op && a->_lextype != Lexer::Type::op) ||
(prev->attribute ("raw") == ")" && ! a->hasTag ("OP")) || (prev->attribute ("raw") == ")" && a->_lextype != Lexer::Type::op) ||
(prev->attribute ("raw") == ")" && a->attribute ("raw") == "(")) (prev->attribute ("raw") == ")" && a->attribute ("raw") == "("))
{ {
A opOr ("argOp", "and"); A2 opOr ("and", Lexer::Type::op);
opOr.tag ("FILTER"); opOr.tag ("FILTER");
opOr.tag ("OP");
reconstructed.push_back (opOr); reconstructed.push_back (opOr);
changes = true; changes = true;
} }
@ -1411,10 +1410,9 @@ void CLI2::insertJunctions ()
_args = reconstructed; _args = reconstructed;
if (context.config.getInteger ("debug.parser") >= 3) if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze insertJunctions")); context.debug (dump ("CLI2::prepareFilter insertJunctions"));
} }
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI2::defaultCommand () void CLI2::defaultCommand ()
{ {

View file

@ -108,9 +108,7 @@ private:
void findUUIDs (); void findUUIDs ();
void insertIDExpr (); void insertIDExpr ();
void desugarFilterPlainArgs (); void desugarFilterPlainArgs ();
/*
void insertJunctions (); void insertJunctions ();
*/
void defaultCommand (); void defaultCommand ();
/* /*
void decomposeModAttributes (); void decomposeModAttributes ();