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 __SCANNER_SPEC_HH__
00056 #define __SCANNER_SPEC_HH__
00057
00058 #include <map>
00059 #include <set>
00060
00061 #include "debug.h"
00062 #include "iscanner_spec.hh"
00063 #include "dfa_source_re.hh"
00064
00065 class DfaReNodeBuilder;
00066 class ITokenSpec;
00067 class PropRegistry;
00068
00074 class LexicalStateSpec
00075 {
00076 public:
00077
00078 string name;
00079 DfaSourceRe *regexp;
00080
00081 LexicalStateSpec (string name_, DfaSourceRe *regexp_ = NULL) :
00082 name(name_),
00083 regexp(regexp_)
00084 {}
00085
00086
00087 #ifdef DEBUG
00088
00092 void dump (ostream &os) const;
00093 #endif
00094
00095 };
00096
00097
00098 class ScannerSpec : public IScannerSpec
00099 {
00100
00101 public:
00102
00103 ScannerSpec (ITokenSpec &tokens_, PropRegistry ®istry);
00104
00105 virtual ~ScannerSpec ();
00106
00107 virtual IReNodeBuilder& getReNodeBuilder ();
00108
00109 virtual void addRegToken (const vector<string> &states,
00110 const string &name, ReNode *regexp,
00111 const string &tokenAction,
00112 const Position &pos)
00113 throw (ParseException);
00114
00115 virtual void addSkipToken (const vector<string> &states,
00116 const string &name, ReNode *regexp,
00117 const string &tokenAction,
00118 const Position &pos)
00119 throw (ParseException);
00120
00121 virtual void addMoreToken (const vector<string> &states,
00122 const string &name, ReNode *regexp,
00123 const string &tokenAction,
00124 const Position &pos)
00125 throw (ParseException);
00126
00127 virtual void addKeywordToken (const vector<string> &states,
00128 const string &name, ReNode *regexp,
00129 const string &tokenAction,
00130 const Position &pos)
00131 throw (ParseException);
00132
00133 virtual void addSpecialToken (const string &name, const Position &pos)
00134 throw (ParseException);
00135
00136 virtual void setPreambleCode (const string &block, const Position &pos);
00137
00138 virtual void addCodeBlock (const string &block, const Position &pos);
00139
00140 virtual void setInheritance (const string &inheritance,
00141 const Position &pos);
00142
00143 virtual void setClassName (const string &className_);
00144
00145 #ifdef DEBUG
00146 virtual void dump (ostream &os) const;
00147 #endif
00148
00149 private:
00150
00155 void updateStates (const vector<string> &tokStates, DfaSourceRe *regexp);
00156
00161 DfaReNodeBuilder &nodeBuilder;
00162
00163
00168 DfaSourceRe *starRe;
00169
00170
00171 public:
00172
00173
00177 string className;
00178
00179
00185 vector<LexicalStateSpec> states;
00186
00187
00191 CodeChunk preambleCode;
00192
00197 vector<CodeChunk> userCode;
00198
00203 CodeChunk inheritance;
00204
00209 ITokenSpec &tokens;
00210 };
00211
00212 #endif