mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Integrated Lexer::decomposePair
This commit is contained in:
parent
e6c4f48a48
commit
5a21945a0d
1 changed files with 126 additions and 142 deletions
56
src/CLI2.cpp
56
src/CLI2.cpp
|
@ -1031,32 +1031,13 @@ void CLI2::desugarFilterAttributes ()
|
|||
if (a._lextype == Lexer::Type::pair &&
|
||||
a.hasTag ("FILTER"))
|
||||
{
|
||||
changes = true;
|
||||
|
||||
auto raw = a.attribute ("raw");
|
||||
auto dot = raw.find ('.');
|
||||
auto colon = raw.find (':');
|
||||
if (colon == std::string::npos)
|
||||
colon = raw.find ('=');
|
||||
|
||||
std::string name = "";
|
||||
std::string mod = "";
|
||||
std::string value = "";
|
||||
|
||||
// If the dot appears after the colon, then it is part of the value, and
|
||||
// should be ignored.
|
||||
if (dot != std::string::npos &&
|
||||
dot < colon)
|
||||
std::string raw = a.attribute ("raw");
|
||||
std::string name;
|
||||
std::string mod;
|
||||
std::string sep;
|
||||
std::string value;
|
||||
if (Lexer::decomposePair (raw, name, mod, sep, value))
|
||||
{
|
||||
name = raw.substr (0, dot);
|
||||
mod = raw.substr (dot + 1, colon - dot - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = raw.substr (0, colon);
|
||||
}
|
||||
|
||||
value = raw.substr (colon + 1);
|
||||
if (value == "")
|
||||
value = "''";
|
||||
|
||||
|
@ -1071,18 +1052,9 @@ void CLI2::desugarFilterAttributes ()
|
|||
reconstructed.push_back (lhs);
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
else if (canonicalize (canonical, "attribute", name) ||
|
||||
canonicalize (canonical, "uda", name))
|
||||
{
|
||||
// If the name does not canonicalize to either an attribute or a UDA
|
||||
// then it is not a recognized Lexer::Type::pair, so downgrade it to
|
||||
// Lexer::Type::word.
|
||||
if (! canonicalize (canonical, "attribute", name) &&
|
||||
! canonicalize (canonical, "uda", name))
|
||||
{
|
||||
a._lextype = Lexer::Type::word;
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO The "!" modifier is being dropped.
|
||||
|
||||
A2 lhs (name, Lexer::Type::dom);
|
||||
|
@ -1182,12 +1154,24 @@ void CLI2::desugarFilterAttributes ()
|
|||
reconstructed.push_back (rhs);
|
||||
found = true;
|
||||
}
|
||||
// If the name does not canonicalize to either an attribute or a UDA
|
||||
// then it is not a recognized Lexer::Type::pair, so downgrade it to
|
||||
// Lexer::Type::word.
|
||||
else
|
||||
{
|
||||
a._lextype = Lexer::Type::word;
|
||||
}
|
||||
|
||||
if (found)
|
||||
changes = true;
|
||||
else
|
||||
reconstructed.push_back (a);
|
||||
}
|
||||
// Failed to decompose.
|
||||
else
|
||||
reconstructed.push_back (a);
|
||||
}
|
||||
// Not a FILTER pair.
|
||||
else
|
||||
reconstructed.push_back (a);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue