mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Integrated Lexer::decomposePair into A2::decompose
This commit is contained in:
parent
e36fb2f10c
commit
dcb13bd2b4
1 changed files with 18 additions and 28 deletions
40
src/CLI2.cpp
40
src/CLI2.cpp
|
@ -173,35 +173,25 @@ void A2::decompose ()
|
||||||
else if (_lextype == Lexer::Type::pair)
|
else if (_lextype == Lexer::Type::pair)
|
||||||
{
|
{
|
||||||
std::string raw = _attributes["raw"];
|
std::string raw = _attributes["raw"];
|
||||||
|
std::string name;
|
||||||
// TODO name:value --> canonical="name" value="value"
|
std::string mod;
|
||||||
// TODO name=value --> canonical="name" value="value"
|
std::string sep;
|
||||||
// TODO name:=value --> canonical="name" value="value"
|
std::string value;
|
||||||
// TODO name::value --> canonical="name" value="value"
|
if (Lexer::decomposePair (_attributes["raw"], name, mod, sep, value))
|
||||||
// TODO name.mod:value -->
|
{
|
||||||
// TODO name.mod=value -->
|
|
||||||
// TODO name.mod:=value -->
|
|
||||||
// TODO name.mod::value -->
|
|
||||||
auto colon = raw.find (':');
|
|
||||||
auto equal = raw.find ('=');
|
|
||||||
|
|
||||||
// Q: Which of ':', '=' is the separator?
|
|
||||||
// A: Whichever comes first. For example:
|
|
||||||
// name:a=b
|
|
||||||
// name=a:b
|
|
||||||
// Both are valid, and 'name' is the attribute name in each case.
|
|
||||||
std::string::size_type separator = std::min (colon, equal);
|
|
||||||
std::string name = raw.substr (0, separator);
|
|
||||||
std::string value = raw.substr (separator + 1);
|
|
||||||
|
|
||||||
attribute ("name", name);
|
attribute ("name", name);
|
||||||
|
attribute ("modifier", mod);
|
||||||
|
attribute ("separator", sep);
|
||||||
attribute ("value", value);
|
attribute ("value", value);
|
||||||
|
|
||||||
if (raw.substr (0, 3) == "rc:")
|
if (name == "rc")
|
||||||
tag ("RC");
|
{
|
||||||
|
if (mod != "")
|
||||||
if (raw.substr (0, 3) == "rc.")
|
|
||||||
tag ("CONFIG");
|
tag ("CONFIG");
|
||||||
|
else
|
||||||
|
tag ("RC");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue