user data in "public" section by default now; storing list of tokens in the generated parser for use later by the rules

This commit is contained in:
Josh Holtrop 2010-05-21 11:05:26 -04:00
parent dfbd319329
commit b689923475
3 changed files with 17 additions and 12 deletions

View File

@ -105,7 +105,7 @@ string TokenDefinition::getClassDefinition() const
{
ret += " virtual void process(const Matches & matches);\n";
}
ret += "protected:\n";
ret += "\n";
ret += m_data + "\n";
ret += "};\n";
return ret;

View File

@ -138,6 +138,7 @@ bool I_CLASSNAME::parse(istream & i)
return false;
}
token->process(matches);
m_tokens.push_back(token);
buff_pos += longest_match_length;
}
}

View File

@ -10,6 +10,7 @@
#include <iostream>
#include <map>
#include <vector>
#include <list>
{%user_includes%}
@ -119,17 +120,6 @@ template <typename T> void refptr<T>::destroy()
#endif
class I_CLASSNAME
{
public:
I_CLASSNAME();
bool parse(std::istream & in);
const char * getError() { return m_errstr; }
protected:
const char * m_errstr;
};
class Matches
{
public:
@ -165,12 +155,26 @@ class Token : public Node
protected:
int m_type;
public:
{%token_data%}
};
typedef refptr<Token> TokenRef;
{%token_classes%}
class I_CLASSNAME
{
public:
I_CLASSNAME();
bool parse(std::istream & in);
const char * getError() { return m_errstr; }
protected:
const char * m_errstr;
std::list<TokenRef> m_tokens;
};
#ifdef I_NAMESPACE
};
#endif