Debian Codegraph @

scintilla/lexilla/src/Lexilla.cxx

raw
1 // Lexilla lexer library
2 /** @file Lexilla.cxx
3 ** Lexer infrastructure.
4 ** Provides entry points to shared library.
5 **/
6 // Copyright 2019 by Neil Hodgson <[email protected]>
7 // The License.txt file describes the conditions under which this software may be distributed.
8
9 #include <cstring>
10
11 #include <vector>
12 #include <initializer_list>
13
14 #if defined(_WIN32)
15 #define EXPORT_FUNCTION __declspec(dllexport)
16 #define CALLING_CONVENTION __stdcall
17 #else
18 #define EXPORT_FUNCTION __attribute__((visibility("default")))
19 #define CALLING_CONVENTION
20 #endif
21
22 #include "ILexer.h"
23
24 #include "LexerModule.h"
25 #include "CatalogueModules.h"
26
27 using namespace Lexilla;
28
29 //++Autogenerated -- run lexilla/scripts/LexillaGen.py to regenerate
30 //**\(extern const LexerModule \*;\n\)
31 extern const LexerModule lmA68k;
32 extern const LexerModule lmAbaqus;
33 extern const LexerModule lmAda;
34 extern const LexerModule lmAPDL;
35 extern const LexerModule lmAs;
36 extern const LexerModule lmAsciidoc;
37 extern const LexerModule lmAsm;
38 extern const LexerModule lmAsn1;
39 extern const LexerModule lmASY;
40 extern const LexerModule lmAU3;
41 extern const LexerModule lmAVE;
42 extern const LexerModule lmAVS;
43 extern const LexerModule lmBaan;
44 extern const LexerModule lmBash;
45 extern const LexerModule lmBatch;
46 extern const LexerModule lmBibTeX;
47 extern const LexerModule lmBlitzBasic;
48 extern const LexerModule lmBullant;
49 extern const LexerModule lmCaml;
50 extern const LexerModule lmCIL;
51 extern const LexerModule lmClw;
52 extern const LexerModule lmClwNoCase;
53 extern const LexerModule lmCmake;
54 extern const LexerModule lmCOBOL;
55 extern const LexerModule lmCoffeeScript;
56 extern const LexerModule lmConf;
57 extern const LexerModule lmCPP;
58 extern const LexerModule lmCPPNoCase;
59 extern const LexerModule lmCsound;
60 extern const LexerModule lmCss;
61 extern const LexerModule lmD;
62 extern const LexerModule lmDart;
63 extern const LexerModule lmDataflex;
64 extern const LexerModule lmDiff;
65 extern const LexerModule lmDMAP;
66 extern const LexerModule lmDMIS;
67 extern const LexerModule lmECL;
68 extern const LexerModule lmEDIFACT;
69 extern const LexerModule lmEiffel;
70 extern const LexerModule lmEiffelkw;
71 extern const LexerModule lmErlang;
72 extern const LexerModule lmErrorList;
73 extern const LexerModule lmESCRIPT;
74 extern const LexerModule lmF77;
75 extern const LexerModule lmFlagShip;
76 extern const LexerModule lmForth;
77 extern const LexerModule lmFortran;
78 extern const LexerModule lmFreeBasic;
79 extern const LexerModule lmFSharp;
80 extern const LexerModule lmGAP;
81 extern const LexerModule lmGDScript;
82 extern const LexerModule lmGui4Cli;
83 extern const LexerModule lmHaskell;
84 extern const LexerModule lmHollywood;
85 extern const LexerModule lmHTML;
86 extern const LexerModule lmIHex;
87 extern const LexerModule lmIndent;
88 extern const LexerModule lmInno;
89 extern const LexerModule lmJSON;
90 extern const LexerModule lmJulia;
91 extern const LexerModule lmKix;
92 extern const LexerModule lmKVIrc;
93 extern const LexerModule lmLatex;
94 extern const LexerModule lmLISP;
95 extern const LexerModule lmLiterateHaskell;
96 extern const LexerModule lmLot;
97 extern const LexerModule lmLout;
98 extern const LexerModule lmLua;
99 extern const LexerModule lmMagikSF;
100 extern const LexerModule lmMake;
101 extern const LexerModule lmMarkdown;
102 extern const LexerModule lmMatlab;
103 extern const LexerModule lmMaxima;
104 extern const LexerModule lmMETAPOST;
105 extern const LexerModule lmMMIXAL;
106 extern const LexerModule lmModula;
107 extern const LexerModule lmMSSQL;
108 extern const LexerModule lmMySQL;
109 extern const LexerModule lmNim;
110 extern const LexerModule lmNimrod;
111 extern const LexerModule lmNix;
112 extern const LexerModule lmNncrontab;
113 extern const LexerModule lmNsis;
114 extern const LexerModule lmNull;
115 extern const LexerModule lmOctave;
116 extern const LexerModule lmOpal;
117 extern const LexerModule lmOScript;
118 extern const LexerModule lmPascal;
119 extern const LexerModule lmPB;
120 extern const LexerModule lmPerl;
121 extern const LexerModule lmPHPSCRIPT;
122 extern const LexerModule lmPLM;
123 extern const LexerModule lmPO;
124 extern const LexerModule lmPOV;
125 extern const LexerModule lmPowerPro;
126 extern const LexerModule lmPowerShell;
127 extern const LexerModule lmProgress;
128 extern const LexerModule lmProps;
129 extern const LexerModule lmPS;
130 extern const LexerModule lmPureBasic;
131 extern const LexerModule lmPython;
132 extern const LexerModule lmR;
133 extern const LexerModule lmRaku;
134 extern const LexerModule lmREBOL;
135 extern const LexerModule lmRegistry;
136 extern const LexerModule lmRuby;
137 extern const LexerModule lmRust;
138 extern const LexerModule lmSAS;
139 extern const LexerModule lmScriptol;
140 extern const LexerModule lmSmalltalk;
141 extern const LexerModule lmSML;
142 extern const LexerModule lmSorc;
143 extern const LexerModule lmSpecman;
144 extern const LexerModule lmSpice;
145 extern const LexerModule lmSQL;
146 extern const LexerModule lmSrec;
147 extern const LexerModule lmStata;
148 extern const LexerModule lmSTTXT;
149 extern const LexerModule lmTACL;
150 extern const LexerModule lmTADS3;
151 extern const LexerModule lmTAL;
152 extern const LexerModule lmTCL;
153 extern const LexerModule lmTCMD;
154 extern const LexerModule lmTEHex;
155 extern const LexerModule lmTeX;
156 extern const LexerModule lmTOML;
157 extern const LexerModule lmTroff;
158 extern const LexerModule lmTxt2tags;
159 extern const LexerModule lmVB;
160 extern const LexerModule lmVBScript;
161 extern const LexerModule lmVerilog;
162 extern const LexerModule lmVHDL;
163 extern const LexerModule lmVisualProlog;
164 extern const LexerModule lmX12;
165 extern const LexerModule lmXML;
166 extern const LexerModule lmYAML;
167 extern const LexerModule lmZig;
168
169 //--Autogenerated -- end of automatically generated section
170
171 namespace {
172
173 CatalogueModules catalogueLexilla;
174
175 static void AddGeanyLexers()
176 {
177 catalogueLexilla.AddLexerModules({
178 &lmAbaqus,
179 &lmAda,
180 &lmAsciidoc,
181 &lmAsm,
182 &lmAU3,
183 &lmBash,
184 &lmBatch,
185 &lmCaml,
186 &lmCIL,
187 &lmCmake,
188 &lmCOBOL,
189 &lmCoffeeScript,
190 &lmCPP,
191 &lmCss,
192 &lmD,
193 &lmDart,
194 &lmDiff,
195 &lmErlang,
196 &lmF77,
197 &lmForth,
198 &lmFortran,
199 &lmFreeBasic,
200 &lmGDScript,
201 &lmHaskell,
202 &lmHTML,
203 &lmJulia,
204 &lmLatex,
205 &lmLISP,
206 &lmLua,
207 &lmMake,
208 &lmMarkdown,
209 &lmNim,
210 &lmNix,
211 &lmNsis,
212 &lmNull,
213 &lmOctave,
214 &lmPascal,
215 &lmPerl,
216 &lmPHPSCRIPT,
217 &lmPO,
218 &lmPowerShell,
219 &lmProps,
220 &lmPython,
221 &lmR,
222 &lmRaku,
223 &lmRuby,
224 &lmRust,
225 &lmSmalltalk,
226 &lmSQL,
227 &lmTCL,
228 &lmTOML,
229 &lmTxt2tags,
230 &lmVerilog,
231 &lmVHDL,
232 &lmVisualProlog,
233 &lmXML,
234 &lmYAML,
235 &lmZig,
236 });
237 }
238
239
240 void AddEachLexer() {
241
242 AddGeanyLexers();
243 return;
244
245 if (catalogueLexilla.Count() > 0) {
246 return;
247 }
248
249 catalogueLexilla.AddLexerModules({
250 //++Autogenerated -- run scripts/LexillaGen.py to regenerate
251 //**\(\t\t&\*,\n\)
252 &lmA68k,
253 &lmAbaqus,
254 &lmAda,
255 &lmAPDL,
256 &lmAs,
257 &lmAsciidoc,
258 &lmAsm,
259 &lmAsn1,
260 &lmASY,
261 &lmAU3,
262 &lmAVE,
263 &lmAVS,
264 &lmBaan,
265 &lmBash,
266 &lmBatch,
267 &lmBibTeX,
268 &lmBlitzBasic,
269 &lmBullant,
270 &lmCaml,
271 &lmCIL,
272 &lmClw,
273 &lmClwNoCase,
274 &lmCmake,
275 &lmCOBOL,
276 &lmCoffeeScript,
277 &lmConf,
278 &lmCPP,
279 &lmCPPNoCase,
280 &lmCsound,
281 &lmCss,
282 &lmD,
283 &lmDart,
284 &lmDataflex,
285 &lmDiff,
286 &lmDMAP,
287 &lmDMIS,
288 &lmECL,
289 &lmEDIFACT,
290 &lmEiffel,
291 &lmEiffelkw,
292 &lmErlang,
293 &lmErrorList,
294 &lmESCRIPT,
295 &lmF77,
296 &lmFlagShip,
297 &lmForth,
298 &lmFortran,
299 &lmFreeBasic,
300 &lmFSharp,
301 &lmGAP,
302 &lmGDScript,
303 &lmGui4Cli,
304 &lmHaskell,
305 &lmHollywood,
306 &lmHTML,
307 &lmIHex,
308 &lmIndent,
309 &lmInno,
310 &lmJSON,
311 &lmJulia,
312 &lmKix,
313 &lmKVIrc,
314 &lmLatex,
315 &lmLISP,
316 &lmLiterateHaskell,
317 &lmLot,
318 &lmLout,
319 &lmLua,
320 &lmMagikSF,
321 &lmMake,
322 &lmMarkdown,
323 &lmMatlab,
324 &lmMaxima,
325 &lmMETAPOST,
326 &lmMMIXAL,
327 &lmModula,
328 &lmMSSQL,
329 &lmMySQL,
330 &lmNim,
331 &lmNimrod,
332 &lmNix,
333 &lmNncrontab,
334 &lmNsis,
335 &lmNull,
336 &lmOctave,
337 &lmOpal,
338 &lmOScript,
339 &lmPascal,
340 &lmPB,
341 &lmPerl,
342 &lmPHPSCRIPT,
343 &lmPLM,
344 &lmPO,
345 &lmPOV,
346 &lmPowerPro,
347 &lmPowerShell,
348 &lmProgress,
349 &lmProps,
350 &lmPS,
351 &lmPureBasic,
352 &lmPython,
353 &lmR,
354 &lmRaku,
355 &lmREBOL,
356 &lmRegistry,
357 &lmRuby,
358 &lmRust,
359 &lmSAS,
360 &lmScriptol,
361 &lmSmalltalk,
362 &lmSML,
363 &lmSorc,
364 &lmSpecman,
365 &lmSpice,
366 &lmSQL,
367 &lmSrec,
368 &lmStata,
369 &lmSTTXT,
370 &lmTACL,
371 &lmTADS3,
372 &lmTAL,
373 &lmTCL,
374 &lmTCMD,
375 &lmTEHex,
376 &lmTeX,
377 &lmTOML,
378 &lmTroff,
379 &lmTxt2tags,
380 &lmVB,
381 &lmVBScript,
382 &lmVerilog,
383 &lmVHDL,
384 &lmVisualProlog,
385 &lmX12,
386 &lmXML,
387 &lmYAML,
388 &lmZig,
389
390 //--Autogenerated -- end of automatically generated section
391 });
392
393 }
394
395 }
396
397 extern "C" {
398
399 EXPORT_FUNCTION int CALLING_CONVENTION GetLexerCount() {
400 AddEachLexer();
401 return static_cast<int>(catalogueLexilla.Count());
402 }
403
404 EXPORT_FUNCTION void CALLING_CONVENTION GetLexerName(unsigned int index, char *name, int buflength) {
405 AddEachLexer();
406 *name = 0;
407 const char *lexerName = catalogueLexilla.Name(index);
408 if (static_cast<size_t>(buflength) > strlen(lexerName)) {
409 strcpy(name, lexerName);
410 }
411 }
412
413 EXPORT_FUNCTION LexerFactoryFunction CALLING_CONVENTION GetLexerFactory(unsigned int index) {
414 AddEachLexer();
415 return catalogueLexilla.Factory(index);
416 }
417
418 EXPORT_FUNCTION Scintilla::ILexer5 * CALLING_CONVENTION CreateLexer(const char *name) {
419 AddEachLexer();
420 for (size_t i = 0; i < catalogueLexilla.Count(); i++) {
421 const char *lexerName = catalogueLexilla.Name(i);
422 if (0 == strcmp(lexerName, name)) {
423 return catalogueLexilla.Create(i);
424 }
425 }
426 return nullptr;
427 }
428
429 EXPORT_FUNCTION const char * CALLING_CONVENTION LexerNameFromID(int identifier) {
430 AddEachLexer();
431 const LexerModule *pModule = catalogueLexilla.Find(identifier);
432 if (pModule) {
433 return pModule->languageName;
434 }
435 return nullptr;
436 }
437
438 EXPORT_FUNCTION const char * CALLING_CONVENTION GetLibraryPropertyNames() {
439 return "";
440 }
441
442 EXPORT_FUNCTION void CALLING_CONVENTION SetLibraryProperty(const char *, const char *) {
443 // Null implementation
444 }
445
446 EXPORT_FUNCTION const char * CALLING_CONVENTION GetNameSpace() {
447 return "lexilla";
448 }
449
450 }
451
452 // Not exported from binary as LexerModule must be built exactly the same as
453 // modules listed above
454 void AddStaticLexerModule(const LexerModule *plm) {
455 AddEachLexer();
456 catalogueLexilla.AddLexerModule(plm);
457 }