mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-03 07:07:19 +02:00
Parser
- Converted ::findTag to use recursive scan.
This commit is contained in:
parent
c681017961
commit
34215449a8
2 changed files with 27 additions and 36 deletions
|
@ -180,7 +180,7 @@ Tree* Parser::parse ()
|
||||||
|
|
||||||
scan (&Parser::findSubstitution);
|
scan (&Parser::findSubstitution);
|
||||||
scan (&Parser::findPattern);
|
scan (&Parser::findPattern);
|
||||||
findTag ();
|
scan (&Parser::findTag);
|
||||||
scan (&Parser::findAttribute);
|
scan (&Parser::findAttribute);
|
||||||
scan (&Parser::findAttributeModifier);
|
scan (&Parser::findAttributeModifier);
|
||||||
findOperator ();
|
findOperator ();
|
||||||
|
@ -849,45 +849,36 @@ void Parser::findSubstitution (Tree* t)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// +tag
|
// +tag
|
||||||
void Parser::findTag ()
|
void Parser::findTag (Tree* t)
|
||||||
{
|
{
|
||||||
std::vector <Tree*>::iterator i;
|
context.debug ("findTag");
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
context.debug (t->dump ());
|
||||||
|
|
||||||
|
std::string raw = t->attribute ("raw");
|
||||||
|
Nibbler n (raw);
|
||||||
|
|
||||||
|
std::string tag;
|
||||||
|
std::string sign;
|
||||||
|
if (n.getN (1, sign) &&
|
||||||
|
(sign == "+" || sign == "-") &&
|
||||||
|
n.getUntilEOS (tag) &&
|
||||||
|
tag.find (' ') == std::string::npos)
|
||||||
{
|
{
|
||||||
// Parser override operator.
|
t->unTag ("?");
|
||||||
if ((*i)->attribute ("raw") == "--")
|
t->removeAllBranches ();
|
||||||
break;
|
t->tag ("TAG");
|
||||||
|
t->attribute ("sign", sign);
|
||||||
|
t->attribute ("tag", tag);
|
||||||
|
|
||||||
// Skip known args.
|
Tree* branch = t->addBranch (new Tree ("argTag"));
|
||||||
if (! (*i)->hasTag ("?"))
|
branch->attribute ("raw", "tags");
|
||||||
continue;
|
|
||||||
|
|
||||||
std::string raw = (*i)->attribute ("raw");
|
branch = t->addBranch (new Tree ("argTag"));
|
||||||
Nibbler n (raw);
|
branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_"));
|
||||||
|
branch->tag ("OP");
|
||||||
|
|
||||||
std::string tag;
|
branch = t->addBranch (new Tree ("argTag"));
|
||||||
std::string sign;
|
branch->attribute ("raw", tag);
|
||||||
if (n.getN (1, sign) &&
|
|
||||||
(sign == "+" || sign == "-") &&
|
|
||||||
n.getUntilEOS (tag) &&
|
|
||||||
tag.find (' ') == std::string::npos)
|
|
||||||
{
|
|
||||||
(*i)->unTag ("?");
|
|
||||||
(*i)->removeAllBranches ();
|
|
||||||
(*i)->tag ("TAG");
|
|
||||||
(*i)->attribute ("sign", sign);
|
|
||||||
(*i)->attribute ("tag", tag);
|
|
||||||
|
|
||||||
Tree* branch = (*i)->addBranch (new Tree ("argTag"));
|
|
||||||
branch->attribute ("raw", "tags");
|
|
||||||
|
|
||||||
branch = (*i)->addBranch (new Tree ("argTag"));
|
|
||||||
branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_"));
|
|
||||||
branch->tag ("OP");
|
|
||||||
|
|
||||||
branch = (*i)->addBranch (new Tree ("argTag"));
|
|
||||||
branch->attribute ("raw", tag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ private:
|
||||||
void findTerminator (Tree*);
|
void findTerminator (Tree*);
|
||||||
void findPattern (Tree*);
|
void findPattern (Tree*);
|
||||||
void findSubstitution (Tree*);
|
void findSubstitution (Tree*);
|
||||||
void findTag ();
|
void findTag (Tree*);
|
||||||
void findAttribute (Tree*);
|
void findAttribute (Tree*);
|
||||||
void findAttributeModifier (Tree*);
|
void findAttributeModifier (Tree*);
|
||||||
void findOperator ();
|
void findOperator ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue