1 // Scintilla source code edit control
2 /** @file Catalogue.cxx
3 ** Colourise for particular languages.
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.
18 #include "Scintilla.h"
21 #include "LexerModule.h"
22 #include "Catalogue.h"
25 using namespace Scintilla
;
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
) {
42 const LexerModule
*Catalogue::Find(const char *languageName
) {
43 Scintilla_LinkLexers();
45 for (std::vector
<LexerModule
*>::iterator it
=lexerCatalogue
.begin();
46 it
!= lexerCatalogue
.end(); ++it
) {
47 if ((*it
)->languageName
&& (0 == strcmp((*it
)->languageName
, languageName
))) {
55 void Catalogue::AddLexerModule(LexerModule
*plm
) {
56 if (plm
->GetLanguage() == SCLEX_AUTOMATIC
) {
57 plm
->language
= 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;
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\)
94 LINK_LEXER(lmFortran
);
95 LINK_LEXER(lmFreeBasic
);
96 LINK_LEXER(lmHaskell
);
102 LINK_LEXER(lmMarkdown
);
103 // We use Octave instead of Matlab
106 LINK_LEXER(lmOctave
);
107 LINK_LEXER(lmPascal
);
110 LINK_LEXER(lmPowerShell
);
112 LINK_LEXER(lmPython
);
118 LINK_LEXER(lmTxt2tags
);
119 LINK_LEXER(lmVerilog
);
124 //--Autogenerated -- end of automatically generated section