Merge branch 'master' of https://github.com/konsolebox/geany into konsolebox-master
[geany-mirror.git] / scintilla / src / Catalogue.cxx
blobe58f1ab2077b501ec2960fada0d7adca0e5ce832
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 <stdexcept>
16 #include <vector>
18 #include "ILexer.h"
19 #include "Scintilla.h"
20 #include "SciLexer.h"
22 #include "LexerModule.h"
23 #include "Catalogue.h"
25 #ifdef SCI_NAMESPACE
26 using namespace Scintilla;
27 #endif
29 static std::vector<LexerModule *> lexerCatalogue;
30 static int nextLanguage = SCLEX_AUTOMATIC+1;
32 const LexerModule *Catalogue::Find(int language) {
33 Scintilla_LinkLexers();
34 for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
35 it != lexerCatalogue.end(); ++it) {
36 if ((*it)->GetLanguage() == language) {
37 return *it;
40 return 0;
43 const LexerModule *Catalogue::Find(const char *languageName) {
44 Scintilla_LinkLexers();
45 if (languageName) {
46 for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
47 it != lexerCatalogue.end(); ++it) {
48 if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) {
49 return *it;
53 return 0;
56 void Catalogue::AddLexerModule(LexerModule *plm) {
57 if (plm->GetLanguage() == SCLEX_AUTOMATIC) {
58 plm->language = nextLanguage;
59 nextLanguage++;
61 lexerCatalogue.push_back(plm);
64 // To add or remove a lexer, add or remove its file and run LexGen.py.
66 // Force a reference to all of the Scintilla lexers so that the linker will
67 // not remove the code of the lexers.
68 int Scintilla_LinkLexers() {
70 static int initialised = 0;
71 if (initialised)
72 return 0;
73 initialised = 1;
75 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
76 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
78 //++Autogenerated -- run scripts/LexGen.py to regenerate
79 //**\(\tLINK_LEXER(\*);\n\)
80 LINK_LEXER(lmAbaqus);
81 LINK_LEXER(lmAda);
82 LINK_LEXER(lmAsm);
83 LINK_LEXER(lmBash);
84 LINK_LEXER(lmBatch);
85 LINK_LEXER(lmCaml);
86 LINK_LEXER(lmCmake);
87 LINK_LEXER(lmCOBOL);
88 LINK_LEXER(lmCoffeeScript);
89 LINK_LEXER(lmCPP);
90 LINK_LEXER(lmCss);
91 LINK_LEXER(lmD);
92 LINK_LEXER(lmDiff);
93 LINK_LEXER(lmErlang);
94 LINK_LEXER(lmF77);
95 LINK_LEXER(lmForth);
96 LINK_LEXER(lmFortran);
97 LINK_LEXER(lmFreeBasic);
98 LINK_LEXER(lmHaskell);
99 LINK_LEXER(lmHTML);
100 LINK_LEXER(lmLatex);
101 LINK_LEXER(lmLISP);
102 LINK_LEXER(lmLua);
103 LINK_LEXER(lmMake);
104 LINK_LEXER(lmMarkdown);
105 // We use Octave instead of Matlab
106 LINK_LEXER(lmNsis);
107 LINK_LEXER(lmNull);
108 LINK_LEXER(lmOctave);
109 LINK_LEXER(lmPascal);
110 LINK_LEXER(lmPerl);
111 LINK_LEXER(lmPHPSCRIPT);
112 LINK_LEXER(lmPO);
113 LINK_LEXER(lmPowerShell);
114 LINK_LEXER(lmProps);
115 LINK_LEXER(lmPython);
116 LINK_LEXER(lmR);
117 LINK_LEXER(lmRuby);
118 LINK_LEXER(lmRust);
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;