added TokenDefinition::getClassName()

This commit is contained in:
Josh Holtrop 2010-05-21 10:01:31 -04:00
parent 3f3dd81e67
commit 5219989f2a
3 changed files with 5 additions and 5 deletions

View File

@ -157,7 +157,7 @@ refptr<string> Parser::buildBuildToken()
t++) t++)
{ {
*buildToken += "case " + (*t)->getIdentifier() + ":\n"; *buildToken += "case " + (*t)->getIdentifier() + ":\n";
*buildToken += " token = new " + (*t)->getName() + "();\n"; *buildToken += " token = new " + (*t)->getClassName() + "();\n";
*buildToken += " break;\n"; *buildToken += " break;\n";
} }
return buildToken; return buildToken;

View File

@ -99,8 +99,7 @@ string TokenDefinition::getCString() const
string TokenDefinition::getClassDefinition() const string TokenDefinition::getClassDefinition() const
{ {
string ret = "class "; string ret = "class "+ getClassName() + " : public Token {\n";
ret += m_name + " : public Token {\n";
ret += "public:\n"; ret += "public:\n";
if (m_process) if (m_process)
{ {
@ -117,7 +116,7 @@ string TokenDefinition::getProcessMethod() const
string ret; string ret;
if (m_code != "") if (m_code != "")
{ {
ret += "void " + m_name + "::process(Matches matches) {\n"; ret += "void " + getClassName() + "::process(Matches matches) {\n";
ret += m_code + "\n"; ret += m_code + "\n";
ret += "}\n"; ret += "}\n";
} }

View File

@ -21,7 +21,8 @@ class TokenDefinition
std::string getCode() const { return m_code; } std::string getCode() const { return m_code; }
std::string getClassDefinition() const; std::string getClassDefinition() const;
std::string getProcessMethod() const; std::string getProcessMethod() const;
std::string getIdentifier() { return std::string("TK_") + m_name; } std::string getIdentifier() const { return "TK_" + m_name; }
std::string getClassName() const { return "Tk" + m_name; }
protected: protected:
std::string m_name; std::string m_name;