mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Converted ::findSubstitution to use recursive scan.
This commit is contained in:
parent
0e86233a0a
commit
c681017961
2 changed files with 25 additions and 34 deletions
|
@ -178,7 +178,7 @@ Tree* Parser::parse ()
|
||||||
findOverrides ();
|
findOverrides ();
|
||||||
applyOverrides ();
|
applyOverrides ();
|
||||||
|
|
||||||
findSubstitution ();
|
scan (&Parser::findSubstitution);
|
||||||
scan (&Parser::findPattern);
|
scan (&Parser::findPattern);
|
||||||
findTag ();
|
findTag ();
|
||||||
scan (&Parser::findAttribute);
|
scan (&Parser::findAttribute);
|
||||||
|
@ -816,42 +816,33 @@ void Parser::findPattern (Tree* t)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// /from/to/[g]
|
// /from/to/[g]
|
||||||
void Parser::findSubstitution ()
|
void Parser::findSubstitution (Tree* t)
|
||||||
{
|
{
|
||||||
std::vector <Tree*>::iterator i;
|
context.debug ("findSubstitution");
|
||||||
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 from;
|
||||||
|
std::string to;
|
||||||
|
bool global = false;
|
||||||
|
if (n.getQuoted ('/', from) &&
|
||||||
|
n.backN () &&
|
||||||
|
n.getQuoted ('/', to))
|
||||||
{
|
{
|
||||||
// Parser override operator.
|
if (n.skip ('g'))
|
||||||
if ((*i)->attribute ("raw") == "--")
|
global = true;
|
||||||
break;
|
|
||||||
|
|
||||||
// Skip known args.
|
if (n.depleted () &&
|
||||||
if (! (*i)->hasTag ("?"))
|
!Directory (raw).exists ())
|
||||||
continue;
|
|
||||||
|
|
||||||
std::string raw = (*i)->attribute ("raw");
|
|
||||||
Nibbler n (raw);
|
|
||||||
|
|
||||||
std::string from;
|
|
||||||
std::string to;
|
|
||||||
bool global = false;
|
|
||||||
if (n.getQuoted ('/', from) &&
|
|
||||||
n.backN () &&
|
|
||||||
n.getQuoted ('/', to))
|
|
||||||
{
|
{
|
||||||
if (n.skip ('g'))
|
t->unTag ("?");
|
||||||
global = true;
|
t->removeAllBranches ();
|
||||||
|
t->tag ("SUBSTITUTION");
|
||||||
if (n.depleted () &&
|
t->attribute ("from", from);
|
||||||
!Directory (raw).exists ())
|
t->attribute ("to", to);
|
||||||
{
|
t->attribute ("global", global ? 1 : 0);
|
||||||
(*i)->unTag ("?");
|
|
||||||
(*i)->removeAllBranches ();
|
|
||||||
(*i)->tag ("SUBSTITUTION");
|
|
||||||
(*i)->attribute ("from", from);
|
|
||||||
(*i)->attribute ("to", to);
|
|
||||||
(*i)->attribute ("global", global ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ private:
|
||||||
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
|
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
|
||||||
void findTerminator (Tree*);
|
void findTerminator (Tree*);
|
||||||
void findPattern (Tree*);
|
void findPattern (Tree*);
|
||||||
void findSubstitution ();
|
void findSubstitution (Tree*);
|
||||||
void findTag ();
|
void findTag ();
|
||||||
void findAttribute (Tree*);
|
void findAttribute (Tree*);
|
||||||
void findAttributeModifier (Tree*);
|
void findAttributeModifier (Tree*);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue