A3t::findTag

- Supports single-word tag add/remove, presence/absence, allowing any non-space
  character in the tag, which is an improvement.
This commit is contained in:
Paul Beckingham 2013-08-31 16:23:57 -04:00
parent 272450ff9b
commit 5a29042d3b
2 changed files with 31 additions and 0 deletions

View file

@ -64,6 +64,7 @@ Tree* A3t::parse ()
findConfigOverride ();
findSubstitution ();
findPattern ();
findTag ();
validate ();
@ -298,6 +299,35 @@ void A3t::findSubstitution ()
}
}
////////////////////////////////////////////////////////////////////////////////
// +tag
void A3t::findTag ()
{
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
// Parser override operator.
if ((*i)->attribute ("raw") == "--")
break;
std::string raw = (*i)->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)
{
(*i)->tag ("TAG");
Tree* b = (*i)->addBranch (new Tree ("metadata"));
b->attribute ("sign", sign);
b->attribute ("tag", tag);
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Validate the parse tree.
void A3t::validate ()

View file

@ -48,6 +48,7 @@ private:
void findConfigOverride ();
void findPattern ();
void findSubstitution ();
void findTag ();
void validate ();
private: