mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-09 00:30:36 +02:00
A3t::findAttributeModifier
- Added support for attmods including :/= alternatives, which is an improvement.
This commit is contained in:
parent
70d37ab7be
commit
34db02515c
2 changed files with 58 additions and 1 deletions
|
@ -67,6 +67,7 @@ Tree* A3t::parse ()
|
||||||
findPattern ();
|
findPattern ();
|
||||||
findTag ();
|
findTag ();
|
||||||
findAttribute ();
|
findAttribute ();
|
||||||
|
findAttributeModifier ();
|
||||||
|
|
||||||
validate ();
|
validate ();
|
||||||
|
|
||||||
|
@ -417,6 +418,62 @@ void A3t::findAttribute ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// <name>.<mod>[:=]['"]<value>['"]
|
||||||
|
void A3t::findAttributeModifier ()
|
||||||
|
{
|
||||||
|
std::vector <Tree*>::iterator i;
|
||||||
|
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||||
|
{
|
||||||
|
// Parser override operator.
|
||||||
|
if ((*i)->attribute ("raw") == "--")
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Skip known args.
|
||||||
|
if (! (*i)->hasTag ("?"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::string raw = (*i)->attribute ("raw");
|
||||||
|
Nibbler n (raw);
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
if (n.getUntil (".", name))
|
||||||
|
{
|
||||||
|
std::string canonical;
|
||||||
|
if (canonicalize (canonical, "attribute", name) ||
|
||||||
|
canonicalize (canonical, "uda", name))
|
||||||
|
{
|
||||||
|
if (n.skip ('.'))
|
||||||
|
{
|
||||||
|
std::string sense = "+";
|
||||||
|
if (n.skip ('~'))
|
||||||
|
sense = "-";
|
||||||
|
|
||||||
|
std::string modifier;
|
||||||
|
n.getUntilOneOf (":=", modifier);
|
||||||
|
|
||||||
|
if (n.skip (':') ||
|
||||||
|
n.skip ('='))
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
if (n.getQuoted ('"', value) ||
|
||||||
|
n.getQuoted ('\'', value) ||
|
||||||
|
n.getUntilEOS (value))
|
||||||
|
{
|
||||||
|
(*i)->unTag ("?");
|
||||||
|
(*i)->tag ("ATTMOD");
|
||||||
|
(*i)->attribute ("name", canonical);
|
||||||
|
(*i)->attribute ("value", value);
|
||||||
|
(*i)->attribute ("modifier", modifier);
|
||||||
|
(*i)->attribute ("sense", sense);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Validate the parse tree.
|
// Validate the parse tree.
|
||||||
void A3t::validate ()
|
void A3t::validate ()
|
||||||
|
|
|
@ -50,6 +50,7 @@ private:
|
||||||
void findSubstitution ();
|
void findSubstitution ();
|
||||||
void findTag ();
|
void findTag ();
|
||||||
void findAttribute ();
|
void findAttribute ();
|
||||||
|
void findAttributeModifier ();
|
||||||
void validate ();
|
void validate ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -59,4 +60,3 @@ private:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue