Scintilla 4.0.3
[TortoiseGit.git] / ext / scintilla / src / Catalogue.cxx
blobef95794dccaf0249cca43cbda80d59fa7aba2996
1 // Scintilla source code edit control
2 /** @file Catalogue.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 <cstdlib>
9 #include <cassert>
10 #include <cstring>
12 #include <stdexcept>
13 #include <vector>
15 #include "ILexer.h"
16 #include "Scintilla.h"
17 #include "SciLexer.h"
19 #include "LexerModule.h"
20 #include "Catalogue.h"
22 using namespace Scintilla;
24 static std::vector<LexerModule *> lexerCatalogue;
25 static int nextLanguage = SCLEX_AUTOMATIC+1;
27 const LexerModule *Catalogue::Find(int language) {
28 Scintilla_LinkLexers();
29 for (const LexerModule *lm : lexerCatalogue) {
30 if (lm->GetLanguage() == language) {
31 return lm;
34 return 0;
37 const LexerModule *Catalogue::Find(const char *languageName) {
38 Scintilla_LinkLexers();
39 if (languageName) {
40 for (const LexerModule *lm : lexerCatalogue) {
41 if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) {
42 return lm;
46 return 0;
49 void Catalogue::AddLexerModule(LexerModule *plm) {
50 if (plm->GetLanguage() == SCLEX_AUTOMATIC) {
51 plm->language = nextLanguage;
52 nextLanguage++;
54 lexerCatalogue.push_back(plm);
57 // To add or remove a lexer, add or remove its file and run LexGen.py.
59 // Force a reference to all of the Scintilla lexers so that the linker will
60 // not remove the code of the lexers.
61 int Scintilla_LinkLexers() {
63 static int initialised = 0;
64 if (initialised)
65 return 0;
66 initialised = 1;
68 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
69 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
71 //++Autogenerated -- run scripts/LexGen.py to regenerate
72 //**\(\tLINK_LEXER(\*);\n\)
73 LINK_LEXER(lmA68k);
74 LINK_LEXER(lmAbaqus);
75 LINK_LEXER(lmAda);
76 LINK_LEXER(lmAPDL);
77 LINK_LEXER(lmAs);
78 LINK_LEXER(lmAsm);
79 LINK_LEXER(lmAsn1);
80 LINK_LEXER(lmASY);
81 LINK_LEXER(lmAU3);
82 LINK_LEXER(lmAVE);
83 LINK_LEXER(lmAVS);
84 LINK_LEXER(lmBaan);
85 LINK_LEXER(lmBash);
86 LINK_LEXER(lmBatch);
87 LINK_LEXER(lmBibTeX);
88 LINK_LEXER(lmBlitzBasic);
89 LINK_LEXER(lmBullant);
90 LINK_LEXER(lmCaml);
91 LINK_LEXER(lmClw);
92 LINK_LEXER(lmClwNoCase);
93 LINK_LEXER(lmCmake);
94 LINK_LEXER(lmCOBOL);
95 LINK_LEXER(lmCoffeeScript);
96 LINK_LEXER(lmConf);
97 LINK_LEXER(lmCPP);
98 LINK_LEXER(lmCPPNoCase);
99 LINK_LEXER(lmCsound);
100 LINK_LEXER(lmCss);
101 LINK_LEXER(lmD);
102 LINK_LEXER(lmDiff);
103 LINK_LEXER(lmDMAP);
104 LINK_LEXER(lmDMIS);
105 LINK_LEXER(lmECL);
106 LINK_LEXER(lmEDIFACT);
107 LINK_LEXER(lmEiffel);
108 LINK_LEXER(lmEiffelkw);
109 LINK_LEXER(lmErlang);
110 LINK_LEXER(lmErrorList);
111 LINK_LEXER(lmESCRIPT);
112 LINK_LEXER(lmF77);
113 LINK_LEXER(lmFlagShip);
114 LINK_LEXER(lmForth);
115 LINK_LEXER(lmFortran);
116 LINK_LEXER(lmFreeBasic);
117 LINK_LEXER(lmGAP);
118 LINK_LEXER(lmGui4Cli);
119 LINK_LEXER(lmHaskell);
120 LINK_LEXER(lmHTML);
121 LINK_LEXER(lmIHex);
122 LINK_LEXER(lmIndent);
123 LINK_LEXER(lmInno);
124 LINK_LEXER(lmJSON);
125 LINK_LEXER(lmKix);
126 LINK_LEXER(lmKVIrc);
127 LINK_LEXER(lmLatex);
128 LINK_LEXER(lmLISP);
129 LINK_LEXER(lmLiterateHaskell);
130 LINK_LEXER(lmLot);
131 LINK_LEXER(lmLout);
132 LINK_LEXER(lmLua);
133 LINK_LEXER(lmMagikSF);
134 LINK_LEXER(lmMake);
135 LINK_LEXER(lmMarkdown);
136 LINK_LEXER(lmMatlab);
137 LINK_LEXER(lmMETAPOST);
138 LINK_LEXER(lmMMIXAL);
139 LINK_LEXER(lmModula);
140 LINK_LEXER(lmMSSQL);
141 LINK_LEXER(lmMySQL);
142 LINK_LEXER(lmNimrod);
143 LINK_LEXER(lmNncrontab);
144 LINK_LEXER(lmNsis);
145 LINK_LEXER(lmNull);
146 LINK_LEXER(lmOctave);
147 LINK_LEXER(lmOpal);
148 LINK_LEXER(lmOScript);
149 LINK_LEXER(lmPascal);
150 LINK_LEXER(lmPB);
151 LINK_LEXER(lmPerl);
152 LINK_LEXER(lmPHPSCRIPT);
153 LINK_LEXER(lmPLM);
154 LINK_LEXER(lmPO);
155 LINK_LEXER(lmPOV);
156 LINK_LEXER(lmPowerPro);
157 LINK_LEXER(lmPowerShell);
158 LINK_LEXER(lmProgress);
159 LINK_LEXER(lmProps);
160 LINK_LEXER(lmPS);
161 LINK_LEXER(lmPureBasic);
162 LINK_LEXER(lmPython);
163 LINK_LEXER(lmR);
164 LINK_LEXER(lmREBOL);
165 LINK_LEXER(lmRegistry);
166 LINK_LEXER(lmRuby);
167 LINK_LEXER(lmRust);
168 LINK_LEXER(lmScriptol);
169 LINK_LEXER(lmSmalltalk);
170 LINK_LEXER(lmSML);
171 LINK_LEXER(lmSorc);
172 LINK_LEXER(lmSpecman);
173 LINK_LEXER(lmSpice);
174 LINK_LEXER(lmSQL);
175 LINK_LEXER(lmSrec);
176 LINK_LEXER(lmSTTXT);
177 LINK_LEXER(lmTACL);
178 LINK_LEXER(lmTADS3);
179 LINK_LEXER(lmTAL);
180 LINK_LEXER(lmTCL);
181 LINK_LEXER(lmTCMD);
182 LINK_LEXER(lmTEHex);
183 LINK_LEXER(lmTeX);
184 LINK_LEXER(lmTxt2tags);
185 LINK_LEXER(lmVB);
186 LINK_LEXER(lmVBScript);
187 LINK_LEXER(lmVerilog);
188 LINK_LEXER(lmVHDL);
189 LINK_LEXER(lmVisualProlog);
190 LINK_LEXER(lmXML);
191 LINK_LEXER(lmYAML);
193 //--Autogenerated -- end of automatically generated section
195 return 1;