00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LANGUAGEDEFINITION_H
00019 #define LANGUAGEDEFINITION_H
00020
00021 #include <string>
00022 #include <map>
00023 #include <iostream>
00024 #include <fstream>
00025 #include <iterator>
00026 #include <sstream>
00027
00028 #include "configurationreader.h"
00029 #include "platform_fs.h"
00030 #include "enums.h"
00031 #include "re/Pattern.h"
00032
00033 namespace highlight {
00034
00035 class RegexElement;
00036
00038 typedef map <string, int> KeywordMap;
00039
00040
00049 class LanguageDefinition {
00050
00051 public:
00052
00053 LanguageDefinition();
00054
00055 ~LanguageDefinition();
00056
00058 string &getSymbolString();
00059
00061 unsigned char getRawStringPrefix();
00062
00064 unsigned char getContinuationChar();
00065
00066
00067
00068
00070 bool getSyntaxHighlight();
00071
00073 bool isIgnoreCase();
00074
00077 int isKeyword(const string &s);
00078
00083 bool load(const string& langDefPath, bool clear=true);
00084
00086 bool isVHDL();
00087
00089 bool allowNestedMLComments();
00090
00092 bool highlightingDisabled();
00093
00096 bool needsReload(const string &langDefPath);
00097
00099 bool enableReformatting();
00100
00102 bool allowExtEscSeq();
00103
00106 unsigned int getDelimPrefixClassID(const string& prefix);
00107
00109 const KeywordMap& getKeywords() const;
00110
00112 const vector<string>& getKeywordClasses() const;
00113
00115 vector<RegexElement*>& getRegexElements() {return regex;};
00116
00117 private:
00118
00119 string symbolString;
00120
00121
00122 string currentPath;
00123
00124 KeywordMap keywords;
00125
00126 vector <string> keywordClasses;
00127
00128 vector <RegexElement*> regex;
00129
00130 KeywordMap delimiterPrefixes;
00131
00132
00133 bool ignoreCase,
00134 disableHighlighting,
00135 allowExtEscape,
00136
00137
00138 vhdlMode,
00139
00140
00141 allowNestedComments,
00142
00143
00144 fullLineComment,
00145
00146
00147 reformatCode;
00148
00149
00150 unsigned char rawStringPrefix,
00151 continuationChar;
00152
00154 void reset();
00155
00156
00157 void addSimpleSymbol(stringstream& symbolStream, State state,
00158 const string& paramValue );
00159
00160 void addSymbol(stringstream& symbolStream,
00161 State stateBegin,
00162 State stateEnd,
00163 bool isDelimiter,
00164 const string& paramValue,
00165 unsigned int classID=0 );
00166
00167
00168 void addDelimiterSymbol(stringstream& symbolStream,
00169 State stateBegin, State stateEnd,
00170 const string& paramValue,
00171 unsigned int classID=0);
00172
00173 bool getFlag( string& paramValue);
00174
00175 unsigned char getSymbol(const string& paramValue);
00176
00177
00178 unsigned int generateNewKWClass(const string& newClassName);
00179
00180
00181 void addKeywords(const string &kwList,State stateBegin, State stateEnd, int classID);
00182
00183 string extractRE(const string ¶mValue);
00184
00185 };
00186
00187
00188 class RegexElement {
00189 public:
00190 RegexElement():open(STANDARD), end(STANDARD), rePattern(NULL), kwClass(0)
00191 {
00192 }
00193
00194 RegexElement(State oState, State eState,
00195 Pattern *re, unsigned int cID=0):open(oState), end(eState), rePattern(re), kwClass(cID)
00196 {
00197
00198 }
00199
00200 ~RegexElement() { delete rePattern; }
00201
00202 State open, end;
00203 Pattern *rePattern;
00204 unsigned int kwClass;
00205 };
00206
00207 }
00208 #endif