mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-03 07:07:19 +02:00
Parser
- Modified ::findAttributeModifier to use collect.
This commit is contained in:
parent
56ab8e7920
commit
a13c816919
2 changed files with 159 additions and 149 deletions
|
@ -182,8 +182,8 @@ Tree* Parser::parse ()
|
|||
findPattern ();
|
||||
findTag ();
|
||||
findAttribute ();
|
||||
findAttributeModifier ();
|
||||
// GOOD ^^^
|
||||
scan (&Parser::findAttributeModifier);
|
||||
scan (&Parser::findOperator);
|
||||
findCommand ();
|
||||
findUUIDList ();
|
||||
|
@ -1049,12 +1049,17 @@ void Parser::findAttribute ()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// <name>.<mod>[:=]['"]<value>['"]
|
||||
void Parser::findAttributeModifier (Tree* t)
|
||||
void Parser::findAttributeModifier ()
|
||||
{
|
||||
context.debug ("findAttributeModifier");
|
||||
context.debug (t->dump ());
|
||||
context.debug ("Parser::findAttributeModifier");
|
||||
bool action = false;
|
||||
|
||||
std::string raw = t->attribute ("raw");
|
||||
std::vector <Tree*> nodes;
|
||||
collect (nodes, false);
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = nodes.begin (); i != nodes.end (); ++i)
|
||||
{
|
||||
std::string raw = (*i)->attribute ("raw");
|
||||
Nibbler n (raw);
|
||||
|
||||
std::string name;
|
||||
|
@ -1085,114 +1090,115 @@ void Parser::findAttributeModifier (Tree* t)
|
|||
if (value == "")
|
||||
value = "''";
|
||||
|
||||
t->unTag ("?");
|
||||
t->removeAllBranches ();
|
||||
t->tag ("ATTMOD");
|
||||
t->attribute ("name", canonical);
|
||||
t->attribute ("raw", value);
|
||||
t->attribute ("modifier", modifier);
|
||||
t->attribute ("sense", sense);
|
||||
(*i)->unTag ("?");
|
||||
(*i)->removeAllBranches ();
|
||||
(*i)->tag ("ATTMOD");
|
||||
(*i)->attribute ("name", canonical);
|
||||
(*i)->attribute ("raw", value);
|
||||
(*i)->attribute ("modifier", modifier);
|
||||
(*i)->attribute ("sense", sense);
|
||||
action = true;
|
||||
|
||||
Tree* branch = t->addBranch (new Tree ("argAttmod"));
|
||||
Tree* branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", canonical);
|
||||
|
||||
if (modifier == "before" || modifier == "under" || modifier == "below")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "<");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "after" || modifier == "over" || modifier == "above")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", ">");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "none")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "==");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "''");
|
||||
}
|
||||
else if (modifier == "any")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "!=");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "''");
|
||||
}
|
||||
else if (modifier == "is" || modifier == "equals")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "==");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "isnt" || modifier == "not")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "!=");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "has" || modifier == "contains")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "hasnt")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "!~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", value);
|
||||
}
|
||||
else if (modifier == "startswith" || modifier == "left")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "'^" + value + "'");
|
||||
}
|
||||
else if (modifier == "endswith" || modifier == "right")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "'" + value + "$'");
|
||||
}
|
||||
else if (modifier == "word")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
|
||||
#if defined (DARWIN)
|
||||
branch->attribute ("raw", value);
|
||||
|
@ -1204,11 +1210,11 @@ void Parser::findAttributeModifier (Tree* t)
|
|||
}
|
||||
else if (modifier == "noword")
|
||||
{
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
branch->attribute ("raw", "!~");
|
||||
branch->tag ("OP");
|
||||
|
||||
branch = t->addBranch (new Tree ("argAttmod"));
|
||||
branch = (*i)->addBranch (new Tree ("argAttmod"));
|
||||
|
||||
#if defined (DARWIN)
|
||||
branch->attribute ("raw", value);
|
||||
|
@ -1226,13 +1232,17 @@ void Parser::findAttributeModifier (Tree* t)
|
|||
if (col != context.columns.end () &&
|
||||
col->second->modifiable ())
|
||||
{
|
||||
t->tag ("MODIFIABLE");
|
||||
(*i)->tag ("MODIFIABLE");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (action)
|
||||
context.debug (_tree->dump ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
void findSubstitution ();
|
||||
void findTag ();
|
||||
void findAttribute ();
|
||||
void findAttributeModifier (Tree*);
|
||||
void findAttributeModifier ();
|
||||
void findOperator (Tree*);
|
||||
void findFilter ();
|
||||
void findModifications ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue