mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI2: Added ::desugarFilterPlainArgs
This commit is contained in:
parent
8229d29100
commit
62307f64da
2 changed files with 24 additions and 24 deletions
46
src/CLI2.cpp
46
src/CLI2.cpp
|
@ -525,7 +525,9 @@ void CLI2::prepareFilter (bool applyContext)
|
||||||
desugarFilterPatterns ();
|
desugarFilterPatterns ();
|
||||||
/*
|
/*
|
||||||
findAttributes ();
|
findAttributes ();
|
||||||
|
*/
|
||||||
desugarFilterPlainArgs ();
|
desugarFilterPlainArgs ();
|
||||||
|
/*
|
||||||
insertJunctions (); // Deliberately after all desugar calls.
|
insertJunctions (); // Deliberately after all desugar calls.
|
||||||
|
|
||||||
// Decompose the elements for MODIFICATIONs.
|
// Decompose the elements for MODIFICATIONs.
|
||||||
|
@ -1424,44 +1426,41 @@ void CLI2::insertIDExpr ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI2::desugarFilterPlainArgs ()
|
void CLI2::desugarFilterPlainArgs ()
|
||||||
{
|
{
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
std::vector <A> reconstructed;
|
std::vector <A2> reconstructed;
|
||||||
auto prev = _args.begin ();
|
auto& prev = _args[0];
|
||||||
for (auto a = _args.begin (); a != _args.end (); ++a)
|
for (auto& a : _args)
|
||||||
{
|
{
|
||||||
if (a != prev && // Not the first arg.
|
if (prev._lextype != Lexer::Type::op &&
|
||||||
! prev->hasTag ("OP") && // An OP before protects the arg.
|
a.hasTag ("FILTER") &&
|
||||||
a->hasTag ("FILTER") &&
|
(a._lextype == Lexer::Type::dom ||
|
||||||
! a->hasTag ("ATTRIBUTE") &&
|
a._lextype == Lexer::Type::identifier ||
|
||||||
! a->hasTag ("ATTMOD") &&
|
a._lextype == Lexer::Type::word ||
|
||||||
! a->hasTag ("OP") &&
|
a._lextype == Lexer::Type::string ||
|
||||||
! a->hasTag ("REGEX") &&
|
a._lextype == Lexer::Type::number ||
|
||||||
! a->hasTag ("LITERAL"))
|
a._lextype == Lexer::Type::hex))
|
||||||
{
|
{
|
||||||
A lhs ("argPattern", "description");
|
changes = true;
|
||||||
lhs.tag ("ATTRIBUTE");
|
|
||||||
|
A2 lhs ("description", Lexer::Type::dom);
|
||||||
lhs.tag ("FILTER");
|
lhs.tag ("FILTER");
|
||||||
reconstructed.push_back (lhs);
|
reconstructed.push_back (lhs);
|
||||||
|
|
||||||
A op ("argPattern", "~");
|
A2 op ("~", Lexer::Type::op);
|
||||||
op.tag ("OP");
|
|
||||||
op.tag ("FILTER");
|
op.tag ("FILTER");
|
||||||
reconstructed.push_back (op);
|
reconstructed.push_back (op);
|
||||||
|
|
||||||
std::string pattern = a->attribute ("raw");
|
std::string raw = a.attribute ("raw");
|
||||||
Lexer::dequote (pattern);
|
Lexer::dequote (raw);
|
||||||
A rhs ("argPattern", "'" + pattern + "'");
|
A2 rhs (raw, Lexer::Type::string);
|
||||||
rhs.tag ("LITERAL");
|
|
||||||
rhs.tag ("FILTER");
|
rhs.tag ("FILTER");
|
||||||
reconstructed.push_back (rhs);
|
reconstructed.push_back (rhs);
|
||||||
changes = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reconstructed.push_back (*a);
|
reconstructed.push_back (a);
|
||||||
|
|
||||||
prev = a;
|
prev = a;
|
||||||
}
|
}
|
||||||
|
@ -1471,10 +1470,11 @@ void CLI2::desugarFilterPlainArgs ()
|
||||||
_args = reconstructed;
|
_args = reconstructed;
|
||||||
|
|
||||||
if (context.config.getInteger ("debug.parser") >= 3)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
context.debug (dump ("CLI2::analyze desugarFilterPlainArgs"));
|
context.debug (dump ("CLI2::prepareFilter desugarFilterPlainArgs"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI2::findAttributes ()
|
void CLI2::findAttributes ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,8 +110,8 @@ private:
|
||||||
void findIDs ();
|
void findIDs ();
|
||||||
void findUUIDs ();
|
void findUUIDs ();
|
||||||
void insertIDExpr ();
|
void insertIDExpr ();
|
||||||
/*
|
|
||||||
void desugarFilterPlainArgs ();
|
void desugarFilterPlainArgs ();
|
||||||
|
/*
|
||||||
void findAttributes ();
|
void findAttributes ();
|
||||||
void insertJunctions ();
|
void insertJunctions ();
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue