*** empty log message ***
[anjuta-git-plugin.git] / scintilla / KeyWords.cxx
blob66e82094c678344e528d4bc7808dee27f046cfc1
1 // Scintilla source code edit control
2 /** @file KeyWords.cxx
3 ** Colourise for particular languages.
4 **/
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11 #include <stdio.h>
12 #include <stdarg.h>
14 #include "Platform.h"
16 #include "PropSet.h"
17 #include "Accessor.h"
18 #include "KeyWords.h"
19 #include "Scintilla.h"
20 #include "SciLexer.h"
22 const LexerModule *LexerModule::base = 0;
23 int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
25 LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
26 const char *languageName_, LexerFunction fnFolder_,
27 const char * const wordListDescriptions_[]) :
28 language(language_),
29 fnLexer(fnLexer_),
30 fnFolder(fnFolder_),
31 wordListDescriptions(wordListDescriptions_),
32 languageName(languageName_) {
33 next = base;
34 base = this;
35 if (language == SCLEX_AUTOMATIC) {
36 language = nextLanguage;
37 nextLanguage++;
41 int LexerModule::GetNumWordLists() const {
42 if (wordListDescriptions == NULL) {
43 return -1;
44 } else {
45 int numWordLists = 0;
47 while (wordListDescriptions[numWordLists]) {
48 ++numWordLists;
51 return numWordLists;
55 const char * LexerModule::GetWordListDescription(int index) const {
56 static const char *emptyStr = "";
58 PLATFORM_ASSERT(index < GetNumWordLists());
59 if (index >= GetNumWordLists()) {
60 return emptyStr;
61 } else {
62 return wordListDescriptions[index];
66 const LexerModule *LexerModule::Find(int language) {
67 const LexerModule *lm = base;
68 while (lm) {
69 if (lm->language == language) {
70 return lm;
72 lm = lm->next;
74 return 0;
77 const LexerModule *LexerModule::Find(const char *languageName) {
78 if (languageName) {
79 const LexerModule *lm = base;
80 while (lm) {
81 if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
82 return lm;
84 lm = lm->next;
87 return 0;
90 void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
91 WordList *keywordlists[], Accessor &styler) const {
92 if (fnLexer)
93 fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
96 void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
97 WordList *keywordlists[], Accessor &styler) const {
98 if (fnFolder) {
99 int lineCurrent = styler.GetLine(startPos);
100 // Move back one line in case deletion wrecked current line fold state
101 if (lineCurrent > 0) {
102 lineCurrent--;
103 int newStartPos = styler.LineStart(lineCurrent);
104 lengthDoc += startPos - newStartPos;
105 startPos = newStartPos;
106 initStyle = 0;
107 if (startPos > 0) {
108 initStyle = styler.StyleAt(startPos - 1);
111 fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
115 // Alternative historical name for Scintilla_LinkLexers
116 int wxForceScintillaLexers(void) {
117 return Scintilla_LinkLexers();
120 // To add or remove a lexer, add or remove its file and run LexGen.py.
122 // Force a reference to all of the Scintilla lexers so that the linker will
123 // not remove the code of the lexers.
124 int Scintilla_LinkLexers() {
125 static int forcer = 0;
127 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
128 #define LINK_LEXER(lexer) extern LexerModule lexer; forcer += lexer.GetLanguage();
130 //++Autogenerated -- run src/LexGen.py to regenerate
131 //**\(\tLINK_LEXER(\*);\n\)
132 LINK_LEXER(lmAda);
133 LINK_LEXER(lmAPDL);
134 LINK_LEXER(lmAsm);
135 LINK_LEXER(lmAns1);
136 LINK_LEXER(lmAU3);
137 LINK_LEXER(lmAVE);
138 LINK_LEXER(lmBaan);
139 LINK_LEXER(lmBash);
140 LINK_LEXER(lmBullant);
141 LINK_LEXER(lmClw);
142 LINK_LEXER(lmClwNoCase);
143 LINK_LEXER(lmConf);
144 LINK_LEXER(lmCPP);
145 LINK_LEXER(lmCPPNoCase);
146 LINK_LEXER(lmTCL);
147 LINK_LEXER(lmNncrontab);
148 LINK_LEXER(lmCss);
149 LINK_LEXER(lmEiffel);
150 LINK_LEXER(lmEiffelkw);
151 LINK_LEXER(lmErlang);
152 LINK_LEXER(lmESCRIPT);
153 LINK_LEXER(lmForth);
154 LINK_LEXER(lmFortran);
155 LINK_LEXER(lmF77);
156 LINK_LEXER(lmGui4Cli);
157 LINK_LEXER(lmHTML);
158 LINK_LEXER(lmXML);
159 LINK_LEXER(lmASP);
160 LINK_LEXER(lmPHP);
161 LINK_LEXER(lmKix);
162 LINK_LEXER(lmLISP);
163 LINK_LEXER(lmLout);
164 LINK_LEXER(lmLua);
165 LINK_LEXER(lmMatlab);
166 LINK_LEXER(lmOctave);
167 LINK_LEXER(lmMETAPOST);
168 LINK_LEXER(lmMMIXAL);
169 LINK_LEXER(lmLot);
170 LINK_LEXER(lmMSSQL);
171 LINK_LEXER(lmNsis);
172 LINK_LEXER(lmBatch);
173 LINK_LEXER(lmDiff);
174 LINK_LEXER(lmProps);
175 LINK_LEXER(lmMake);
176 LINK_LEXER(lmErrorList);
177 LINK_LEXER(lmLatex);
178 LINK_LEXER(lmNull);
179 LINK_LEXER(lmPascal);
180 LINK_LEXER(lmPB);
181 LINK_LEXER(lmPerl);
182 LINK_LEXER(lmPOV);
183 LINK_LEXER(lmPS);
184 LINK_LEXER(lmPython);
185 LINK_LEXER(lmRuby);
186 LINK_LEXER(lmScriptol);
187 LINK_LEXER(lmSpecman);
188 LINK_LEXER(lmSQL);
189 LINK_LEXER(lmTeX);
190 LINK_LEXER(lmVB);
191 LINK_LEXER(lmVBScript);
192 LINK_LEXER(lmVerilog);
193 LINK_LEXER(lmVHDL);
194 LINK_LEXER(lmYAML);
196 //--Autogenerated -- end of automatically generated section
198 return 1;