A3t::findPattern

- Now parses patterns and extracts the pattern, which may include escaped /
  characters, which is an improvement.
This commit is contained in:
Paul Beckingham
2013-08-31 12:24:30 -04:00
parent 96a06eafbf
commit 2281c5a6bf
4 changed files with 36 additions and 4 deletions

View File

@@ -27,6 +27,7 @@
#include <iostream>
#include <A3t.h>
#include <Nibbler.h>
#include <text.h>
#include <util.h>
@@ -60,6 +61,9 @@ Tree* A3t::parse ()
findCommand ();
findFileOverride ();
findConfigOverride ();
findPattern ();
validate ();
return _tree;
}
@@ -232,9 +236,34 @@ void A3t::findConfigOverride ()
}
////////////////////////////////////////////////////////////////////////////////
// Validate the parse tree.
void A3t::validate ()
// /pattern/
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.
}
////////////////////////////////////////////////////////////////////////////////