Add support for DOS, OS/2 and Windows batch files
[geany-mirror.git] / scintilla / src / Catalogue.cxx
blobf1f3e5ab07b9289328e327f6fa7569e8da8f38f6
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>
13 #include <assert.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 // Alternative historical name for Scintilla_LinkLexers
64 int wxForceScintillaLexers(void) {
65 return Scintilla_LinkLexers();
68 // To add or remove a lexer, add or remove its file and run LexGen.py.
70 // Force a reference to all of the Scintilla lexers so that the linker will
71 // not remove the code of the lexers.
72 int Scintilla_LinkLexers() {
74 static int initialised = 0;
75 if (initialised)
76 return 0;
77 initialised = 1;
79 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
80 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
82 //++Autogenerated -- run src/LexGen.py to regenerate
83 //**\(\tLINK_LEXER(\*);\n\)
84 LINK_LEXER(lmAbaqus);
85 LINK_LEXER(lmAda);
86 LINK_LEXER(lmAsm);
87 LINK_LEXER(lmBash);
88 LINK_LEXER(lmBatch);
89 LINK_LEXER(lmCaml);
90 LINK_LEXER(lmCmake);
91 LINK_LEXER(lmCOBOL);
92 LINK_LEXER(lmCPP);
93 LINK_LEXER(lmCss);
94 LINK_LEXER(lmD);
95 LINK_LEXER(lmDiff);
96 LINK_LEXER(lmErlang);
97 LINK_LEXER(lmF77);
98 LINK_LEXER(lmForth);
99 LINK_LEXER(lmFortran);
100 LINK_LEXER(lmFreeBasic);
101 LINK_LEXER(lmHaskell);
102 LINK_LEXER(lmHTML);
103 LINK_LEXER(lmLatex);
104 LINK_LEXER(lmLISP);
105 LINK_LEXER(lmLua);
106 LINK_LEXER(lmMake);
107 LINK_LEXER(lmMarkdown);
108 // We use Octave instead of Matlab
109 LINK_LEXER(lmNsis);
110 LINK_LEXER(lmNull);
111 LINK_LEXER(lmOctave);
112 LINK_LEXER(lmPascal);
113 LINK_LEXER(lmPerl);
114 LINK_LEXER(lmPO);
115 LINK_LEXER(lmProps);
116 LINK_LEXER(lmPython);
117 LINK_LEXER(lmR);
118 LINK_LEXER(lmRuby);
119 LINK_LEXER(lmSQL);
120 LINK_LEXER(lmTCL);
121 LINK_LEXER(lmTxt2tags);
122 LINK_LEXER(lmVerilog);
123 LINK_LEXER(lmVHDL);
124 LINK_LEXER(lmXML);
125 LINK_LEXER(lmYAML);
127 //--Autogenerated -- end of automatically generated section
129 return 1;