Update Scintilla to version 3.4.4
[geany-mirror.git] / scintilla / src / Catalogue.cxx
blobd158ab42f0cd1179e678f41d3b105998a44458ee
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 <stdlib.h>
9 #include <string.h>
10 #include <stdio.h>
11 #include <stdarg.h>
12 #include <assert.h>
13 #include <ctype.h>
15 #include <vector>
17 #include "ILexer.h"
18 #include "Scintilla.h"
19 #include "SciLexer.h"
21 #include "LexerModule.h"
22 #include "Catalogue.h"
24 #ifdef SCI_NAMESPACE
25 using namespace Scintilla;
26 #endif
28 static std::vector<LexerModule *> lexerCatalogue;
29 static int nextLanguage = SCLEX_AUTOMATIC+1;
31 const LexerModule *Catalogue::Find(int language) {
32 Scintilla_LinkLexers();
33 for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
34 it != lexerCatalogue.end(); ++it) {
35 if ((*it)->GetLanguage() == language) {
36 return *it;
39 return 0;
42 const LexerModule *Catalogue::Find(const char *languageName) {
43 Scintilla_LinkLexers();
44 if (languageName) {
45 for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
46 it != lexerCatalogue.end(); ++it) {
47 if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) {
48 return *it;
52 return 0;
55 void Catalogue::AddLexerModule(LexerModule *plm) {
56 if (plm->GetLanguage() == SCLEX_AUTOMATIC) {
57 plm->language = nextLanguage;
58 nextLanguage++;
60 lexerCatalogue.push_back(plm);
63 // To add or remove a lexer, add or remove its file and run LexGen.py.
65 // Force a reference to all of the Scintilla lexers so that the linker will
66 // not remove the code of the lexers.
67 int Scintilla_LinkLexers() {
69 static int initialised = 0;
70 if (initialised)
71 return 0;
72 initialised = 1;
74 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
75 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
77 //++Autogenerated -- run scripts/LexGen.py to regenerate
78 //**\(\tLINK_LEXER(\*);\n\)
79 LINK_LEXER(lmAbaqus);
80 LINK_LEXER(lmAda);
81 LINK_LEXER(lmAsm);
82 LINK_LEXER(lmBash);
83 LINK_LEXER(lmBatch);
84 LINK_LEXER(lmCaml);
85 LINK_LEXER(lmCmake);
86 LINK_LEXER(lmCOBOL);
87 LINK_LEXER(lmCPP);
88 LINK_LEXER(lmCss);
89 LINK_LEXER(lmD);
90 LINK_LEXER(lmDiff);
91 LINK_LEXER(lmErlang);
92 LINK_LEXER(lmF77);
93 LINK_LEXER(lmForth);
94 LINK_LEXER(lmFortran);
95 LINK_LEXER(lmFreeBasic);
96 LINK_LEXER(lmHaskell);
97 LINK_LEXER(lmHTML);
98 LINK_LEXER(lmLatex);
99 LINK_LEXER(lmLISP);
100 LINK_LEXER(lmLua);
101 LINK_LEXER(lmMake);
102 LINK_LEXER(lmMarkdown);
103 // We use Octave instead of Matlab
104 LINK_LEXER(lmNsis);
105 LINK_LEXER(lmNull);
106 LINK_LEXER(lmOctave);
107 LINK_LEXER(lmPascal);
108 LINK_LEXER(lmPerl);
109 LINK_LEXER(lmPO);
110 LINK_LEXER(lmPowerShell);
111 LINK_LEXER(lmProps);
112 LINK_LEXER(lmPython);
113 LINK_LEXER(lmR);
114 LINK_LEXER(lmRuby);
115 LINK_LEXER(lmRust);
116 LINK_LEXER(lmSQL);
117 LINK_LEXER(lmTCL);
118 LINK_LEXER(lmTxt2tags);
119 LINK_LEXER(lmVerilog);
120 LINK_LEXER(lmVHDL);
121 LINK_LEXER(lmXML);
122 LINK_LEXER(lmYAML);
124 //--Autogenerated -- end of automatically generated section
126 return 1;