From b6899234750df2235043b17b69fb03f4b3753a87 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 21 May 2010 11:05:26 -0400 Subject: [PATCH] user data in "public" section by default now; storing list of tokens in the generated parser for use later by the rules --- TokenDefinition.cc | 2 +- tmpl/parser.cc | 1 + tmpl/parser.h | 26 +++++++++++++++----------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/TokenDefinition.cc b/TokenDefinition.cc index 3545e41..634aaf3 100644 --- a/TokenDefinition.cc +++ b/TokenDefinition.cc @@ -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; diff --git a/tmpl/parser.cc b/tmpl/parser.cc index 05c6eb9..76cb238 100644 --- a/tmpl/parser.cc +++ b/tmpl/parser.cc @@ -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; } } diff --git a/tmpl/parser.h b/tmpl/parser.h index e802b81..f27f86a 100644 --- a/tmpl/parser.h +++ b/tmpl/parser.h @@ -10,6 +10,7 @@ #include #include #include +#include {%user_includes%} @@ -119,17 +120,6 @@ template void refptr::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 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 m_tokens; +}; + #ifdef I_NAMESPACE }; #endif