CLI2: Added CLI2::dump and A2::dump methods.

This commit is contained in:
Paul Beckingham 2015-06-13 15:01:20 -04:00
parent 50cd2968b9
commit 657d5b8310
2 changed files with 15 additions and 4 deletions

View file

@ -31,7 +31,7 @@
//#include <Nibbler.h> //#include <Nibbler.h>
//#include <Lexer.h> //#include <Lexer.h>
#include <CLI2.h> #include <CLI2.h>
//#include <Color.h> #include <Color.h>
#include <text.h> #include <text.h>
//#include <util.h> //#include <util.h>
#include <i18n.h> #include <i18n.h>
@ -175,7 +175,7 @@ void A2::removeAttribute (const std::string& name)
{ {
_attributes.erase (name); _attributes.erase (name);
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string A2::dump () const const std::string A2::dump () const
{ {
@ -194,6 +194,7 @@ const std::string A2::dump () const
if (atts.length ()) if (atts.length ())
output += " " + atts; output += " " + atts;
/*
// Dump tags. // Dump tags.
std::string tags; std::string tags;
for (auto& tag : _tags) for (auto& tag : _tags)
@ -214,10 +215,10 @@ const std::string A2::dump () const
if (tags.length ()) if (tags.length ())
output += ' ' + tags; output += ' ' + tags;
*/
return output; return output;
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Static method. // Static method.
@ -345,8 +346,10 @@ void CLI2::add (const std::string& argument)
// Intended to be called after ::add() to perform the final analysis. // Intended to be called after ::add() to perform the final analysis.
void CLI2::analyze () void CLI2::analyze ()
{ {
// Start from scratch.
_args.clear (); _args.clear ();
// Look at each arg, and decide if it warrants lexing.
for (unsigned int i = 0; i < _original_args.size (); ++i) for (unsigned int i = 0; i < _original_args.size (); ++i)
{ {
std::string raw = _original_args[i]; std::string raw = _original_args[i];
@ -382,7 +385,10 @@ void CLI2::analyze ()
} }
if (context.config.getInteger ("debug.parser") >= 3) if (context.config.getInteger ("debug.parser") >= 3)
{
context.debug (dump ());
context.debug ("CLI2::analyze end"); context.debug ("CLI2::analyze end");
}
} }
/* /*
@ -693,6 +699,7 @@ std::string CLI2::getLimit () const
return "0"; return "0";
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string CLI2::dump (const std::string& title) const const std::string CLI2::dump (const std::string& title) const
@ -717,6 +724,7 @@ const std::string CLI2::dump (const std::string& title) const
return out.str (); return out.str ();
} }
/*
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Note: This seems silly - it's essentially performing a low-quality parse. But // Note: This seems silly - it's essentially performing a low-quality parse. But
// that is really all that is needed - to separate the args that need to // that is really all that is needed - to separate the args that need to

View file

@ -57,8 +57,9 @@ public:
void attribute (const std::string&, const double); void attribute (const std::string&, const double);
const std::string attribute (const std::string&) const; const std::string attribute (const std::string&) const;
void removeAttribute (const std::string&); void removeAttribute (const std::string&);
const std::string dump () const;
*/ */
const std::string dump () const;
public: public:
std::string _name; std::string _name;
Lexer::Type _lextype; Lexer::Type _lextype;
@ -99,8 +100,10 @@ public:
std::string getBinary () const; std::string getBinary () const;
std::string getCommand () const; std::string getCommand () const;
std::string getLimit () const; std::string getLimit () const;
*/
const std::string dump (const std::string& title = "CLI2 Parser") const; const std::string dump (const std::string& title = "CLI2 Parser") const;
/*
private: private:
void addArg (const std::string&); void addArg (const std::string&);
void aliasExpansion (); void aliasExpansion ();