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 <Lexer.h>
#include <CLI2.h>
//#include <Color.h>
#include <Color.h>
#include <text.h>
//#include <util.h>
#include <i18n.h>
@ -175,7 +175,7 @@ void A2::removeAttribute (const std::string& name)
{
_attributes.erase (name);
}
*/
////////////////////////////////////////////////////////////////////////////////
const std::string A2::dump () const
{
@ -194,6 +194,7 @@ const std::string A2::dump () const
if (atts.length ())
output += " " + atts;
/*
// Dump tags.
std::string tags;
for (auto& tag : _tags)
@ -214,10 +215,10 @@ const std::string A2::dump () const
if (tags.length ())
output += ' ' + tags;
*/
return output;
}
*/
////////////////////////////////////////////////////////////////////////////////
// Static method.
@ -345,8 +346,10 @@ void CLI2::add (const std::string& argument)
// Intended to be called after ::add() to perform the final analysis.
void CLI2::analyze ()
{
// Start from scratch.
_args.clear ();
// Look at each arg, and decide if it warrants lexing.
for (unsigned int i = 0; i < _original_args.size (); ++i)
{
std::string raw = _original_args[i];
@ -382,8 +385,11 @@ void CLI2::analyze ()
}
if (context.config.getInteger ("debug.parser") >= 3)
{
context.debug (dump ());
context.debug ("CLI2::analyze end");
}
}
/*
////////////////////////////////////////////////////////////////////////////////
@ -693,6 +699,7 @@ std::string CLI2::getLimit () const
return "0";
}
*/
////////////////////////////////////////////////////////////////////////////////
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 ();
}
/*
////////////////////////////////////////////////////////////////////////////////
// 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

View file

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