- Implemented ::unsweetenTags, which resolves the syntactic sugar to an expression.
This commit is contained in:
Paul Beckingham
2014-10-15 00:02:45 -04:00
parent 34fd7b4b04
commit c2f8c81a88
2 changed files with 32 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include <cmake.h>
#include <iostream>
#include <Context.h>
#include <Nibbler.h>
#include <Lexer.h>
#include <CLI.h>
#include <Color.h>
@@ -307,6 +308,36 @@ bool CLI::canonicalize (
return false;
}
////////////////////////////////////////////////////////////////////////////////
// +tag --> tags _hastag_ tag
// -tag --> tags _notag_ tag
void CLI::unsweetenTags ()
{
std::vector <std::string> reconstructed;
std::vector <std::string>::iterator i;
for (i = _filter.begin (); i != _filter.end (); ++i)
{
Nibbler n (*i);
std::string tag;
std::string sign;
if (n.getN (1, sign) &&
(sign == "+" || sign == "-") &&
n.getUntilEOS (tag) &&
tag.find (' ') == std::string::npos)
{
reconstructed.push_back ("tags");
reconstructed.push_back (sign == "+" ? "_hastag_" : "_notag_");
reconstructed.push_back (tag);
}
else
reconstructed.push_back (*i);
}
_filter = reconstructed;
}
////////////////////////////////////////////////////////////////////////////////
void CLI::dump (const std::string& label) const
{