added I_TOKENLIST definition; build test now compiling

This commit is contained in:
Josh Holtrop 2010-05-11 16:33:22 -04:00
parent b27a900b96
commit edeb857c77
4 changed files with 16 additions and 4 deletions

View File

@ -47,6 +47,17 @@ bool Parser::write(const string & fname)
writeDefine(header, "I_NAMESPACE", m_namespace); writeDefine(header, "I_NAMESPACE", m_namespace);
} }
writeDefine(header, "I_CLASSNAME", m_classname); writeDefine(header, "I_CLASSNAME", m_classname);
string tokenlist;
for (int i = 0; i < m_tokens.size(); i++)
{
if (i > 0)
tokenlist += " ";
tokenlist += "{\"" + m_tokens[i]->getName() + "\", \""
+ m_tokens[i]->getCString() + "\"}";
if (i < m_tokens.size() - 1)
tokenlist += ", \\\n";
}
writeDefine(header, "I_TOKENLIST", tokenlist);
header << endl; header << endl;
header.write((const char *) tmpl_parser_h, tmpl_parser_h_len); header.write((const char *) tmpl_parser_h, tmpl_parser_h_len);

View File

@ -10,6 +10,7 @@ class TokenDefinition
bool create(const std::string & name, bool create(const std::string & name,
const std::string & definition, const std::string & flags); const std::string & definition, const std::string & flags);
std::string getCString() const; std::string getCString() const;
std::string getName() const { return m_name; }
protected: protected:
std::string m_name; std::string m_name;

View File

@ -36,8 +36,8 @@ static void read_istream(istream & i, vector<char> & buff, int & size)
bool I_CLASSNAME::parse(istream & i) bool I_CLASSNAME::parse(istream & i)
{ {
struct { struct {
char * name; const char * name;
char * definition; const char * definition;
pcre * re; pcre * re;
pcre_extra * re_extra; pcre_extra * re_extra;
} tokens[] = { } tokens[] = {
@ -93,7 +93,7 @@ bool I_CLASSNAME::parse(istream & i)
for (int i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++) for (int i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++)
{ {
int rc = pcre_exec(tokens[i].re, tokens[i].re_extra, int rc = pcre_exec(tokens[i].re, tokens[i].re_extra,
buff, buff_size, buff_pos, &buff[0], buff_size, buff_pos,
PCRE_ANCHORED | PCRE_NOTEMPTY, PCRE_ANCHORED | PCRE_NOTEMPTY,
ovector, ovector_size); ovector, ovector_size);
if (rc > 0) if (rc > 0)

View File

@ -13,7 +13,7 @@ class I_CLASSNAME
public: public:
I_CLASSNAME(); I_CLASSNAME();
bool parse(std::istream & in); bool parse(std::istream & in);
char * getError() { return m_errstr; } const char * getError() { return m_errstr; }
protected: protected:
const char * m_errstr; const char * m_errstr;