CLI, Filter

- Moved parse tree dump into Context::debug output.
This commit is contained in:
Paul Beckingham 2014-10-20 01:01:27 -04:00
parent 24219e23a1
commit b484abea4a
3 changed files with 32 additions and 26 deletions

View file

@ -25,7 +25,8 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <cmake.h> #include <cmake.h>
#include <iostream> #include <sstream>
#include <iostream> // TODO Remove.
#include <Context.h> #include <Context.h>
#include <Nibbler.h> #include <Nibbler.h>
#include <Lexer.h> #include <Lexer.h>
@ -325,7 +326,6 @@ const std::string CLI::getFilter ()
} }
} }
dump ("CLI::getFilter");
return "( " + filter + " )"; return "( " + filter + " )";
} }
@ -336,7 +336,6 @@ const std::vector <std::string> CLI::getWords ()
// TODO Processing here. // TODO Processing here.
dump ("CLI::getWords");
return words; return words;
} }
@ -347,10 +346,34 @@ const std::vector <std::string> CLI::getModifications ()
// TODO Processing here. // TODO Processing here.
dump ("CLI::getModifications");
return modifications; return modifications;
} }
////////////////////////////////////////////////////////////////////////////////
const std::string CLI::dump () const
{
std::stringstream out;
out << "\033[1mCLI Parser\033[0m\n"
<< " _original_args\n ";
Color colorOrigArgs ("gray10 on gray4");
std::vector <std::string>::const_iterator i;
for (i = _original_args.begin (); i != _original_args.end (); ++i)
{
if (i != _original_args.begin ())
out << ' ';
out << colorOrigArgs.colorize (*i);
}
out << "\n";
out << " _args\n";
std::vector <A>::const_iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
out << " " << a->dump () << "\n";
return out.str ();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::aliasExpansion () void CLI::aliasExpansion ()
{ {
@ -1149,24 +1172,3 @@ void CLI::desugarUUIDs ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::dump (const std::string& label) const
{
std::cout << label << "\n"
<< " _original_args ";
Color colorOrigArgs ("gray10 on gray4");
std::vector <std::string>::const_iterator i;
for (i = _original_args.begin (); i != _original_args.end (); ++i)
{
if (i != _original_args.begin ())
std::cout << ' ';
std::cout << colorOrigArgs.colorize (*i);
}
std::cout << "\n";
std::cout << " _args\n";
std::vector <A>::const_iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
std::cout << " " << a->dump () << "\n";
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -72,6 +72,7 @@ public:
const std::string getFilter (); const std::string getFilter ();
const std::vector <std::string> getWords (); const std::vector <std::string> getWords ();
const std::vector <std::string> getModifications (); const std::vector <std::string> getModifications ();
const std::string dump () const;
private: private:
void aliasExpansion (); void aliasExpansion ();
@ -85,7 +86,6 @@ private:
void desugarPatterns (); void desugarPatterns ();
void desugarIDs (); void desugarIDs ();
void desugarUUIDs (); void desugarUUIDs ();
void dump (const std::string&) const;
public: public:
std::multimap <std::string, std::string> _entities; std::multimap <std::string, std::string> _entities;

View file

@ -74,6 +74,8 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
if (context.config.getInteger ("debug.parser") >= 1) if (context.config.getInteger ("debug.parser") >= 1)
{ {
context.debug (context.cli.dump ());
Tree* t = context.parser.tree (); Tree* t = context.parser.tree ();
if (t) if (t)
context.debug (t->dump ()); context.debug (t->dump ());
@ -121,6 +123,8 @@ void Filter::subset (std::vector <Task>& output)
if (context.config.getInteger ("debug.parser") >= 1) if (context.config.getInteger ("debug.parser") >= 1)
{ {
context.debug (context.cli.dump ());
Tree* t = context.parser.tree (); Tree* t = context.parser.tree ();
if (t) if (t)
context.debug (t->dump ()); context.debug (t->dump ());