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.
19 #include "Scintilla.h"
22 #include "LexerModule.h"
23 #include "Catalogue.h"
26 using namespace Scintilla
;
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
) {
43 const LexerModule
*Catalogue::Find(const char *languageName
) {
44 Scintilla_LinkLexers();
46 for (std::vector
<LexerModule
*>::iterator it
=lexerCatalogue
.begin();
47 it
!= lexerCatalogue
.end(); ++it
) {
48 if ((*it
)->languageName
&& (0 == strcmp((*it
)->languageName
, languageName
))) {
56 void Catalogue::AddLexerModule(LexerModule
*plm
) {
57 if (plm
->GetLanguage() == SCLEX_AUTOMATIC
) {
58 plm
->language
= 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;
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\)
88 LINK_LEXER(lmCoffeeScript
);
96 LINK_LEXER(lmFortran
);
97 LINK_LEXER(lmFreeBasic
);
98 LINK_LEXER(lmHaskell
);
104 LINK_LEXER(lmMarkdown
);
105 // We use Octave instead of Matlab
108 LINK_LEXER(lmOctave
);
109 LINK_LEXER(lmPascal
);
111 LINK_LEXER(lmPHPSCRIPT
);
113 LINK_LEXER(lmPowerShell
);
115 LINK_LEXER(lmPython
);
121 LINK_LEXER(lmTxt2tags
);
122 LINK_LEXER(lmVerilog
);
127 //--Autogenerated -- end of automatically generated section