state.h
00001 #ifndef STATE_H
00002 #define STATE_H
00003
00004 #include <stdio.h>
00005
00006 class CxxScanner;
00007 class Token;
00008 class AddTraceString;
00009 class IO;
00010
00018
00019 class State
00020 {
00021 public:
00023 enum State_t {NEUTRAL = 1, IDENT, STATICVAR, FDECL, CSTMT};
00024
00026 State(const char* nameIn) { COPY_STRING(mp_name, nameIn);}
00027
00029 virtual ~State()= 0;
00030
00032 const char* name() { return mp_name; }
00033
00035 virtual State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t) = 0;
00036
00038 Token nonCommentRead(CxxScanner& scanner, const char* errStr = 0);
00039
00040 private:
00042 char* mp_name;
00043 };
00044
00045
00060
00061 class Neutral: public State
00062 {
00063 public:
00065 ~Neutral() {}
00066
00068 State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t);
00069
00071 static State* Instance();
00072 protected:
00073
00075 Neutral() : State("%N%") {}
00076 private:
00078 static State* msp_instance;
00079 };
00080
00081
00095
00096 class Ident: public State
00097 {
00098 public:
00100 ~Ident() {}
00101
00103 State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t);
00104
00106 static State* Instance();
00107 protected:
00108
00110 Ident() : State("%Id%") {}
00111 private:
00113 static State* msp_instance;
00114 };
00115
00116
00130
00131 class StaticVar: public State
00132 {
00133 public:
00135 ~StaticVar() {}
00136
00138 State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t);
00139
00141 static State* Instance();
00142 protected:
00144 StaticVar() : State("%SVAR%") {}
00145 private:
00147 static State* msp_instance;
00148 };
00149
00150
00164
00165 class Fdecl: public State
00166 {
00167 public:
00169 ~Fdecl() {}
00170
00172 State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t);
00173
00175 static State* Instance();
00176 protected:
00178 Fdecl() : State("%FDECL%") {}
00179 private:
00181 static State* msp_instance;
00182 };
00183
00184
00198
00199 class Cstmt: public State
00200 {
00201 public:
00203 ~Cstmt() {}
00204
00206 State_t execute(AddTraceString& ats, CxxScanner& scanner, Token* t);
00207
00209 static State* Instance();
00210 protected:
00212 Cstmt() : State("%CSTMT%") {}
00213 private:
00215 static State* msp_instance;
00216 };
00217
00218
00219 #endif // STATE_H
00220