diff --git a/TokenDefinition.cc b/TokenDefinition.cc index e085cf2..18e9c4c 100644 --- a/TokenDefinition.cc +++ b/TokenDefinition.cc @@ -22,19 +22,18 @@ static string trim(string s) return s; } -static refptr< vector > split(const string & delim, const string & str) +static refptr< vector > split(const string & delim, string str) { refptr< vector > ret = new vector(); - string s = str; size_t pos; - while ( (pos = s.find(delim)) != string::npos ) + while ( (pos = str.find(delim)) != string::npos ) { - string t = s.substr(0, pos); + string t = str.substr(0, pos); ret->push_back(t); - s.erase(0, pos + 1); + str.erase(0, pos + 1); } - if (s != "") - ret->push_back(s); + if (str != "") + ret->push_back(str); return ret; } @@ -50,6 +49,12 @@ static string c_escape(const string & orig) return result; } + +TokenDefinition::TokenDefinition() + : m_ignored(false) +{ +} + bool TokenDefinition::create(const string & name, const string & definition, const string & flags) { @@ -67,6 +72,21 @@ bool TokenDefinition::create(const string & name, pcre_free(re); refptr< vector< string > > parts = split(",", flags); + for (int i = 0, sz = parts->size(); i < sz; i++) + { + (*parts)[i] = trim((*parts)[i]); + string & s = (*parts)[i]; + if (s == "i") + { + m_ignored = true; + } + else + { + cerr << "Unknown token flag \"" << s << "\"" << endl; + return false; + } + } + return true; } diff --git a/TokenDefinition.h b/TokenDefinition.h index 003743e..65c3a23 100644 --- a/TokenDefinition.h +++ b/TokenDefinition.h @@ -7,6 +7,7 @@ class TokenDefinition { public: + TokenDefinition(); bool create(const std::string & name, const std::string & definition, const std::string & flags); std::string getCString() const; @@ -15,6 +16,7 @@ class TokenDefinition protected: std::string m_name; std::string m_definition; + bool m_ignored; }; #endif