mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Modified ::findAttribute to use collect.
This commit is contained in:
parent
ed07e47135
commit
56ab8e7920
2 changed files with 72 additions and 60 deletions
|
@ -181,8 +181,8 @@ Tree* Parser::parse ()
|
||||||
findSubstitution ();
|
findSubstitution ();
|
||||||
findPattern ();
|
findPattern ();
|
||||||
findTag ();
|
findTag ();
|
||||||
|
findAttribute ();
|
||||||
// GOOD ^^^
|
// GOOD ^^^
|
||||||
scan (&Parser::findAttribute);
|
|
||||||
scan (&Parser::findAttributeModifier);
|
scan (&Parser::findAttributeModifier);
|
||||||
scan (&Parser::findOperator);
|
scan (&Parser::findOperator);
|
||||||
findCommand ();
|
findCommand ();
|
||||||
|
@ -958,12 +958,17 @@ void Parser::findTag ()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// <name>:['"][<value>]['"]
|
// <name>:['"][<value>]['"]
|
||||||
void Parser::findAttribute (Tree* t)
|
void Parser::findAttribute ()
|
||||||
{
|
{
|
||||||
context.debug ("findAttribute");
|
context.debug ("Parser::findAttribute");
|
||||||
context.debug (t->dump ());
|
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);
|
Nibbler n (raw);
|
||||||
|
|
||||||
// Look for a valid attribute name.
|
// Look for a valid attribute name.
|
||||||
|
@ -985,39 +990,41 @@ void Parser::findAttribute (Tree* t)
|
||||||
std::string canonical;
|
std::string canonical;
|
||||||
if (canonicalize (canonical, "uda", name))
|
if (canonicalize (canonical, "uda", name))
|
||||||
{
|
{
|
||||||
t->tag ("UDA");
|
(*i)->tag ("UDA");
|
||||||
t->tag ("MODIFIABLE");
|
(*i)->tag ("MODIFIABLE");
|
||||||
|
action = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (canonicalize (canonical, "pseudo", name))
|
else if (canonicalize (canonical, "pseudo", name))
|
||||||
{
|
{
|
||||||
t->unTag ("?");
|
(*i)->unTag ("?");
|
||||||
t->removeAllBranches ();
|
(*i)->removeAllBranches ();
|
||||||
t->tag ("PSEUDO");
|
(*i)->tag ("PSEUDO");
|
||||||
t->attribute ("name", canonical);
|
(*i)->attribute ("name", canonical);
|
||||||
t->attribute ("raw", value);
|
(*i)->attribute ("raw", value);
|
||||||
|
action = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (canonicalize (canonical, "attribute", name))
|
else if (canonicalize (canonical, "attribute", name))
|
||||||
{
|
{
|
||||||
t->unTag ("?");
|
(*i)->unTag ("?");
|
||||||
t->removeAllBranches ();
|
(*i)->removeAllBranches ();
|
||||||
t->tag ("ATTRIBUTE");
|
(*i)->tag ("ATTRIBUTE");
|
||||||
t->attribute ("name", canonical);
|
(*i)->attribute ("name", canonical);
|
||||||
t->attribute ("raw", value);
|
(*i)->attribute ("raw", value);
|
||||||
|
|
||||||
std::map <std::string, Column*>::const_iterator col;
|
std::map <std::string, Column*>::const_iterator col;
|
||||||
col = context.columns.find (canonical);
|
col = context.columns.find (canonical);
|
||||||
if (col != context.columns.end () &&
|
if (col != context.columns.end () &&
|
||||||
col->second->modifiable ())
|
col->second->modifiable ())
|
||||||
{
|
{
|
||||||
t->tag ("MODIFIABLE");
|
(*i)->tag ("MODIFIABLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tree* branch = t->addBranch (new Tree ("argAtt"));
|
Tree* branch = (*i)->addBranch (new Tree ("argAtt"));
|
||||||
branch->attribute ("raw", canonical);
|
branch->attribute ("raw", canonical);
|
||||||
|
|
||||||
branch = t->addBranch (new Tree ("argAtt"));
|
branch = (*i)->addBranch (new Tree ("argAtt"));
|
||||||
branch->tag ("OP");
|
branch->tag ("OP");
|
||||||
|
|
||||||
// All 'project' attributes are partial matches.
|
// All 'project' attributes are partial matches.
|
||||||
|
@ -1027,14 +1034,19 @@ void Parser::findAttribute (Tree* t)
|
||||||
else
|
else
|
||||||
branch->attribute ("raw", "==");
|
branch->attribute ("raw", "==");
|
||||||
|
|
||||||
branch = t->addBranch (new Tree ("argAtt"));
|
branch = (*i)->addBranch (new Tree ("argAtt"));
|
||||||
branch->attribute ("raw", value);
|
branch->attribute ("raw", value);
|
||||||
|
action = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action)
|
||||||
|
context.debug (_tree->dump ());
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// <name>.<mod>[:=]['"]<value>['"]
|
// <name>.<mod>[:=]['"]<value>['"]
|
||||||
void Parser::findAttributeModifier (Tree* t)
|
void Parser::findAttributeModifier (Tree* t)
|
||||||
|
|
|
@ -75,7 +75,7 @@ private:
|
||||||
void findPattern ();
|
void findPattern ();
|
||||||
void findSubstitution ();
|
void findSubstitution ();
|
||||||
void findTag ();
|
void findTag ();
|
||||||
void findAttribute (Tree*);
|
void findAttribute ();
|
||||||
void findAttributeModifier (Tree*);
|
void findAttributeModifier (Tree*);
|
||||||
void findOperator (Tree*);
|
void findOperator (Tree*);
|
||||||
void findFilter ();
|
void findFilter ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue