CLI2: A2 now stores Lexer::Type.

This commit is contained in:
Paul Beckingham 2015-06-13 14:45:19 -04:00
parent 485899b0c5
commit 50cd2968b9
2 changed files with 14 additions and 10 deletions

View file

@ -52,9 +52,10 @@ A2::A2 ()
} }
*/ */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
A2::A2 (const std::string& name, const std::string& raw) A2::A2 (const std::string& name, const std::string& raw, Lexer::Type lextype)
{ {
_name = name; _name = name;
_lextype = lextype;
attribute ("raw", raw); attribute ("raw", raw);
} }
@ -344,10 +345,12 @@ 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 ()
{ {
_args.clear ();
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];
A a ("arg", raw); A2 a ("arg", raw, Lexer::Type::word);
/* /*
a.tag ("ORIGINAL"); a.tag ("ORIGINAL");

View file

@ -30,22 +30,22 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
*/
#include <Lexer.h> #include <Lexer.h>
#include <FS.h> #include <FS.h>
*/
// Represents a single argument. // Represents a single argument.
class A2 class A2
{ {
public: public:
A2 (); A2 ();
A2 (const std::string&, const std::string&); A2 (const std::string&, const std::string&, Lexer::Type);
/* /*
A (const std::string&, const int); A2 (const std::string&, const int);
A (const std::string&, const double); A2 (const std::string&, const double);
~A (); ~A2 ();
A (const A&); A2 (const A&);
A& operator= (const A&); A2& operator= (const A2&);
bool hasTag (const std::string&) const; bool hasTag (const std::string&) const;
void tag (const std::string&); void tag (const std::string&);
void unTag (const std::string&); void unTag (const std::string&);
@ -61,6 +61,7 @@ public:
*/ */
public: public:
std::string _name; std::string _name;
Lexer::Type _lextype;
/* /*
std::vector <std::string> _tags; std::vector <std::string> _tags;
*/ */
@ -150,7 +151,7 @@ public:
std::multimap <std::string, std::string> _entities; std::multimap <std::string, std::string> _entities;
std::map <std::string, std::string> _aliases; std::map <std::string, std::string> _aliases;
std::vector <std::string> _original_args; std::vector <std::string> _original_args;
std::vector <A> _args; std::vector <A2> _args;
/* /*
std::vector <std::pair <int, int>> _id_ranges; std::vector <std::pair <int, int>> _id_ranges;