00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef __ITOKEN_SPEC_HH__
00056 #define __ITOKEN_SPEC_HH__
00057
00058 #include <string>
00059 #include <vector>
00060 using namespace std;
00061
00062
00063 #include "parse_util.hh"
00064
00065 class ITokenDesc;
00066 class ReNode;
00067
00074 class ITokenSpec
00075 {
00076 public:
00077
00078 typedef enum t_Tkinds {regular, skip, more, keyword, special} Tkinds;
00079
00088 virtual void setClassName (const string &className) = 0;
00089
00093 virtual void setInheritance (const string &inheritance,
00094 const Position &pos) = 0;
00095
00099 virtual void setPreambleCode (const string &preambleCode,
00100 const Position &pos) = 0;
00101
00105 virtual void addCodeBlock (const string &block, const Position &pos) = 0;
00106
00107
00108
00127 virtual void addToken (const string &tokName, Tkinds tokKind,
00128 ReNode *regexp, const string &tokAction,
00129 const Position &pos) throw (ParseException) = 0;
00130
00137 virtual void addToken (const string &tokname, const Position &pos)
00138 throw (ParseException) = 0;
00139
00143 virtual bool isToken (const string &tokName) = 0;
00144
00149 virtual int getTokenId (const string &tokName) = 0;
00150
00151
00158 virtual ITokenDesc& operator [] (int tokid) = 0;
00159
00160 ITokenDesc& operator [] (const string &tokName)
00161 {
00162 return (*this)[getTokenId(tokName)];
00163 }
00164
00168 virtual int count () = 0;
00169
00170
00171
00175 virtual ~ITokenSpec () {}
00176
00177 #ifdef DEBUG
00178
00183 virtual void dump (ostream &os) const = 0;
00184
00185 #endif
00186
00187 public:
00188
00189 string className;
00190
00191 CodeChunk preambleCode;
00192
00193 vector<CodeChunk> userCode;
00194
00195 CodeChunk inheritance;
00196 };
00197
00198 class ITokenDesc
00199 {
00200 public:
00201
00202 virtual const string &name() const = 0;
00203
00204 virtual int id () const = 0;
00205
00206 virtual ITokenSpec::Tkinds kind() const = 0;
00207
00208 virtual const Position& pos () const = 0;
00209
00210 virtual const CodeChunk& tokAction() const = 0;
00211
00212 #ifdef DEBUG
00213
00218 virtual void dump (ostream &os) const = 0;
00219
00220 #endif
00221 };
00222
00223
00224 #endif