1 // Scintilla source code edit control
\r
2 /** @file KeyWords.cxx
\r
3 ** Colourise for particular languages.
\r
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
\r
6 // The License.txt file describes the conditions under which this software may be distributed.
\r
14 #include "Platform.h"
\r
16 #include "PropSet.h"
\r
17 #include "Accessor.h"
\r
18 #include "KeyWords.h"
\r
19 #include "Scintilla.h"
\r
20 #include "SciLexer.h"
\r
22 #ifdef SCI_NAMESPACE
\r
23 using namespace Scintilla;
\r
26 const LexerModule *LexerModule::base = 0;
\r
27 int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
\r
29 LexerModule::LexerModule(int language_,
\r
30 LexerFunction fnLexer_,
\r
31 const char *languageName_,
\r
32 LexerFunction fnFolder_,
\r
33 const char * const wordListDescriptions_[],
\r
35 language(language_),
\r
37 fnFolder(fnFolder_),
\r
38 wordListDescriptions(wordListDescriptions_),
\r
39 styleBits(styleBits_),
\r
40 languageName(languageName_) {
\r
43 if (language == SCLEX_AUTOMATIC) {
\r
44 language = nextLanguage;
\r
49 int LexerModule::GetNumWordLists() const {
\r
50 if (wordListDescriptions == NULL) {
\r
53 int numWordLists = 0;
\r
55 while (wordListDescriptions[numWordLists]) {
\r
59 return numWordLists;
\r
63 const char *LexerModule::GetWordListDescription(int index) const {
\r
64 static const char *emptyStr = "";
\r
66 PLATFORM_ASSERT(index < GetNumWordLists());
\r
67 if (index >= GetNumWordLists()) {
\r
70 return wordListDescriptions[index];
\r
74 int LexerModule::GetStyleBitsNeeded() const {
\r
78 const LexerModule *LexerModule::Find(int language) {
\r
79 const LexerModule *lm = base;
\r
81 if (lm->language == language) {
\r
89 const LexerModule *LexerModule::Find(const char *languageName) {
\r
91 const LexerModule *lm = base;
\r
93 if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
\r
102 void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
\r
103 WordList *keywordlists[], Accessor &styler) const {
\r
105 fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
\r
108 void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
\r
109 WordList *keywordlists[], Accessor &styler) const {
\r
111 int lineCurrent = styler.GetLine(startPos);
\r
112 // Move back one line in case deletion wrecked current line fold state
\r
113 if (lineCurrent > 0) {
\r
115 int newStartPos = styler.LineStart(lineCurrent);
\r
116 lengthDoc += startPos - newStartPos;
\r
117 startPos = newStartPos;
\r
119 if (startPos > 0) {
\r
120 initStyle = styler.StyleAt(startPos - 1);
\r
123 fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
\r
127 // Alternative historical name for Scintilla_LinkLexers
\r
128 int wxForceScintillaLexers(void) {
\r
129 return Scintilla_LinkLexers();
\r
132 // To add or remove a lexer, add or remove its file and run LexGen.py.
\r
134 // Force a reference to all of the Scintilla lexers so that the linker will
\r
135 // not remove the code of the lexers.
\r
136 int Scintilla_LinkLexers() {
\r
137 static int forcer = 0;
\r
139 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
\r
140 #define LINK_LEXER(lexer) extern LexerModule lexer; forcer += lexer.GetLanguage();
\r
142 //++Autogenerated -- run src/LexGen.py to regenerate
\r
143 //**\(\tLINK_LEXER(\*);\n\)
\r
144 LINK_LEXER(lmAbaqus);
\r
146 LINK_LEXER(lmAns1);
\r
147 LINK_LEXER(lmAPDL);
\r
153 LINK_LEXER(lmBaan);
\r
154 LINK_LEXER(lmBash);
\r
155 LINK_LEXER(lmBatch);
\r
156 LINK_LEXER(lmBlitzBasic);
\r
157 LINK_LEXER(lmBullant);
\r
158 LINK_LEXER(lmCaml);
\r
160 LINK_LEXER(lmClwNoCase);
\r
161 LINK_LEXER(lmCmake);
\r
162 LINK_LEXER(lmConf);
\r
164 LINK_LEXER(lmCPPNoCase);
\r
165 LINK_LEXER(lmCsound);
\r
168 LINK_LEXER(lmDiff);
\r
169 LINK_LEXER(lmEiffel);
\r
170 LINK_LEXER(lmEiffelkw);
\r
171 LINK_LEXER(lmErlang);
\r
172 LINK_LEXER(lmErrorList);
\r
173 LINK_LEXER(lmESCRIPT);
\r
175 LINK_LEXER(lmFlagShip);
\r
176 LINK_LEXER(lmForth);
\r
177 LINK_LEXER(lmFortran);
\r
178 LINK_LEXER(lmFreeBasic);
\r
180 LINK_LEXER(lmGui4Cli);
\r
181 LINK_LEXER(lmHaskell);
\r
182 LINK_LEXER(lmHTML);
\r
183 LINK_LEXER(lmInno);
\r
185 LINK_LEXER(lmLatex);
\r
186 LINK_LEXER(lmLISP);
\r
188 LINK_LEXER(lmLout);
\r
190 LINK_LEXER(lmMagikSF);
\r
191 LINK_LEXER(lmMake);
\r
192 LINK_LEXER(lmMatlab);
\r
193 LINK_LEXER(lmMETAPOST);
\r
194 LINK_LEXER(lmMMIXAL);
\r
195 LINK_LEXER(lmMSSQL);
\r
196 LINK_LEXER(lmMySQL);
\r
197 LINK_LEXER(lmNncrontab);
\r
198 LINK_LEXER(lmNsis);
\r
199 LINK_LEXER(lmNull);
\r
200 LINK_LEXER(lmOctave);
\r
201 LINK_LEXER(lmOpal);
\r
202 LINK_LEXER(lmPascal);
\r
204 LINK_LEXER(lmPerl);
\r
206 LINK_LEXER(lmPHPSCRIPT);
\r
210 LINK_LEXER(lmPowerShell);
\r
211 LINK_LEXER(lmProgress);
\r
212 LINK_LEXER(lmProps);
\r
214 LINK_LEXER(lmPureBasic);
\r
215 LINK_LEXER(lmPython);
\r
217 LINK_LEXER(lmREBOL);
\r
218 LINK_LEXER(lmRuby);
\r
219 LINK_LEXER(lmScriptol);
\r
220 LINK_LEXER(lmSmalltalk);
\r
221 LINK_LEXER(lmSpecman);
\r
222 LINK_LEXER(lmSpice);
\r
224 LINK_LEXER(lmTADS3);
\r
228 LINK_LEXER(lmVBScript);
\r
229 LINK_LEXER(lmVerilog);
\r
230 LINK_LEXER(lmVHDL);
\r
232 LINK_LEXER(lmYAML);
\r
234 //--Autogenerated -- end of automatically generated section
\r