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 &&
|
if (a._lextype == Lexer::Type::pair &&
|
||||||
a.hasTag ("FILTER"))
|
a.hasTag ("FILTER"))
|
||||||
{
|
{
|
||||||
changes = true;
|
std::string raw = a.attribute ("raw");
|
||||||
|
std::string name;
|
||||||
auto raw = a.attribute ("raw");
|
std::string mod;
|
||||||
auto dot = raw.find ('.');
|
std::string sep;
|
||||||
auto colon = raw.find (':');
|
std::string value;
|
||||||
if (colon == std::string::npos)
|
if (Lexer::decomposePair (raw, name, mod, sep, value))
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
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 == "")
|
if (value == "")
|
||||||
value = "''";
|
value = "''";
|
||||||
|
|
||||||
|
@ -1071,18 +1052,9 @@ void CLI2::desugarFilterAttributes ()
|
||||||
reconstructed.push_back (lhs);
|
reconstructed.push_back (lhs);
|
||||||
found = true;
|
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.
|
// TODO The "!" modifier is being dropped.
|
||||||
|
|
||||||
A2 lhs (name, Lexer::Type::dom);
|
A2 lhs (name, Lexer::Type::dom);
|
||||||
|
@ -1182,12 +1154,24 @@ void CLI2::desugarFilterAttributes ()
|
||||||
reconstructed.push_back (rhs);
|
reconstructed.push_back (rhs);
|
||||||
found = true;
|
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)
|
if (found)
|
||||||
changes = true;
|
changes = true;
|
||||||
else
|
else
|
||||||
reconstructed.push_back (a);
|
reconstructed.push_back (a);
|
||||||
}
|
}
|
||||||
|
// Failed to decompose.
|
||||||
|
else
|
||||||
|
reconstructed.push_back (a);
|
||||||
|
}
|
||||||
|
// Not a FILTER pair.
|
||||||
else
|
else
|
||||||
reconstructed.push_back (a);
|
reconstructed.push_back (a);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue