mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
A3t::findPattern
- Now parses patterns and extracts the pattern, which may include escaped / characters, which is an improvement.
This commit is contained in:
parent
96a06eafbf
commit
2281c5a6bf
4 changed files with 36 additions and 4 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <A3t.h>
|
#include <A3t.h>
|
||||||
|
#include <Nibbler.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ Tree* A3t::parse ()
|
||||||
findCommand ();
|
findCommand ();
|
||||||
findFileOverride ();
|
findFileOverride ();
|
||||||
findConfigOverride ();
|
findConfigOverride ();
|
||||||
|
findPattern ();
|
||||||
|
|
||||||
|
validate ();
|
||||||
|
|
||||||
return _tree;
|
return _tree;
|
||||||
}
|
}
|
||||||
|
@ -232,9 +236,34 @@ void A3t::findConfigOverride ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Validate the parse tree.
|
// /pattern/
|
||||||
void A3t::validate ()
|
void A3t::findPattern ()
|
||||||
{
|
{
|
||||||
|
std::vector <Tree*>::iterator i;
|
||||||
|
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||||
|
{
|
||||||
|
// Parser override operator.
|
||||||
|
if ((*i)->attribute ("raw") == "--")
|
||||||
|
break;
|
||||||
|
|
||||||
|
Nibbler n ((*i)->attribute ("raw"));
|
||||||
|
std::string pattern;
|
||||||
|
if (n.getQuoted ('/', pattern) &&
|
||||||
|
n.depleted () &&
|
||||||
|
pattern.length () > 0)
|
||||||
|
{
|
||||||
|
(*i)->tag ("PATTERN");
|
||||||
|
Tree* b = (*i)->addBranch (new Tree ("data"));
|
||||||
|
b->attribute ("pattern", pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Validate the parse tree.
|
||||||
|
void A3t::validate ()
|
||||||
|
{
|
||||||
|
// TODO Any RC node must have a root/*[+RC]/data[@file] that exists.
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -46,6 +46,7 @@ private:
|
||||||
void findCommand ();
|
void findCommand ();
|
||||||
void findFileOverride ();
|
void findFileOverride ();
|
||||||
void findConfigOverride ();
|
void findConfigOverride ();
|
||||||
|
void findPattern ();
|
||||||
void validate ();
|
void validate ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -55,4 +56,4 @@ private:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
|
@ -240,7 +240,8 @@ void Tree::dumpNode (Tree* t, int depth)
|
||||||
for (int i = 0; i < depth; ++i)
|
for (int i = 0; i < depth; ++i)
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
|
||||||
std::cout << t << " \033[1m" << t->_name << "\033[0m";
|
// std::cout << t << " \033[1m" << t->_name << "\033[0m";
|
||||||
|
std::cout << "\033[1m" << t->_name << "\033[0m";
|
||||||
|
|
||||||
// Dump attributes.
|
// Dump attributes.
|
||||||
std::string atts;
|
std::string atts;
|
||||||
|
|
|
@ -10,4 +10,5 @@
|
||||||
|
|
||||||
echo; ./args rc:~/.taskrc 123 mod pro:'P 1' +home /from/to/g rc.name=value
|
echo; ./args rc:~/.taskrc 123 mod pro:'P 1' +home /from/to/g rc.name=value
|
||||||
echo; ./args rc:~/..taskrc rc.name=value add -- modify +tag /from/to/g name:value
|
echo; ./args rc:~/..taskrc rc.name=value add -- modify +tag /from/to/g name:value
|
||||||
|
echo; ./args /pattern/ nex
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue