1 // Scintilla source code edit control 2 /** @file Catalogue.cxx 3 ** Lexer infrastructure. 4 ** Contains a list of LexerModules which can be searched to find a module appropriate for a 5 ** particular language. 6 **/ 7 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org> 8 // The License.txt file describes the conditions under which this software may be distributed. 9 10 #include <cstdlib> 11 #include <cassert> 12 #include <cstring> 13 14 #include <stdexcept> 15 #include <vector> 16 17 #include "ILexer.h" 18 #include "Scintilla.h" 19 #include "SciLexer.h" 20 21 #include "LexerModule.h" 22 #include "Catalogue.h" 23 24 using namespace Scintilla; 25 26 static std::vector<LexerModule *> lexerCatalogue; 27 static int nextLanguage = SCLEX_AUTOMATIC+1; 28 Find(int language)29const LexerModule *Catalogue::Find(int language) { 30 Scintilla_LinkLexers(); 31 for (const LexerModule *lm : lexerCatalogue) { 32 if (lm->GetLanguage() == language) { 33 return lm; 34 } 35 } 36 return nullptr; 37 } 38 Find(const char * languageName)39const LexerModule *Catalogue::Find(const char *languageName) { 40 Scintilla_LinkLexers(); 41 if (languageName) { 42 for (const LexerModule *lm : lexerCatalogue) { 43 if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) { 44 return lm; 45 } 46 } 47 } 48 return nullptr; 49 } 50 AddLexerModule(LexerModule * plm)51void Catalogue::AddLexerModule(LexerModule *plm) { 52 if (plm->GetLanguage() == SCLEX_AUTOMATIC) { 53 plm->language = nextLanguage; 54 nextLanguage++; 55 } 56 lexerCatalogue.push_back(plm); 57 } 58 59 // To add or remove a lexer, add or remove its file and run LexGen.py. 60 61 // Force a reference to all of the Scintilla lexers so that the linker will 62 // not remove the code of the lexers. Scintilla_LinkLexers()63int Scintilla_LinkLexers() { 64 65 static int initialised = 0; 66 if (initialised) 67 return 0; 68 initialised = 1; 69 70 // Shorten the code that declares a lexer and ensures it is linked in by calling a method. 71 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer); 72 73 //++Autogenerated -- run scripts/LexGen.py to regenerate 74 //**\(\tLINK_LEXER(\*);\n\) 75 LINK_LEXER(lmA68k); 76 LINK_LEXER(lmAbaqus); 77 LINK_LEXER(lmAda); 78 LINK_LEXER(lmAPDL); 79 LINK_LEXER(lmAs); 80 LINK_LEXER(lmAsm); 81 LINK_LEXER(lmAsn1); 82 LINK_LEXER(lmASY); 83 LINK_LEXER(lmAU3); 84 LINK_LEXER(lmAVE); 85 LINK_LEXER(lmAVS); 86 LINK_LEXER(lmBaan); 87 LINK_LEXER(lmBash); 88 LINK_LEXER(lmBatch); 89 LINK_LEXER(lmBibTeX); 90 LINK_LEXER(lmBlitzBasic); 91 LINK_LEXER(lmBullant); 92 LINK_LEXER(lmCaml); 93 LINK_LEXER(lmClw); 94 LINK_LEXER(lmClwNoCase); 95 LINK_LEXER(lmCmake); 96 LINK_LEXER(lmCOBOL); 97 LINK_LEXER(lmCoffeeScript); 98 LINK_LEXER(lmConf); 99 LINK_LEXER(lmCPP); 100 LINK_LEXER(lmCPPNoCase); 101 LINK_LEXER(lmCsound); 102 LINK_LEXER(lmCss); 103 LINK_LEXER(lmD); 104 LINK_LEXER(lmDiff); 105 LINK_LEXER(lmDMAP); 106 LINK_LEXER(lmDMIS); 107 LINK_LEXER(lmECL); 108 LINK_LEXER(lmEDIFACT); 109 LINK_LEXER(lmEiffel); 110 LINK_LEXER(lmEiffelkw); 111 LINK_LEXER(lmErlang); 112 LINK_LEXER(lmErrorList); 113 LINK_LEXER(lmESCRIPT); 114 LINK_LEXER(lmF77); 115 LINK_LEXER(lmFlagShip); 116 LINK_LEXER(lmForth); 117 LINK_LEXER(lmFortran); 118 LINK_LEXER(lmFreeBasic); 119 LINK_LEXER(lmGAP); 120 LINK_LEXER(lmGui4Cli); 121 LINK_LEXER(lmHaskell); 122 LINK_LEXER(lmHTML); 123 LINK_LEXER(lmIHex); 124 LINK_LEXER(lmIndent); 125 LINK_LEXER(lmInno); 126 LINK_LEXER(lmJSON); 127 LINK_LEXER(lmKix); 128 LINK_LEXER(lmKVIrc); 129 LINK_LEXER(lmLatex); 130 LINK_LEXER(lmLISP); 131 LINK_LEXER(lmLiterateHaskell); 132 LINK_LEXER(lmLot); 133 LINK_LEXER(lmLout); 134 #if !defined(SCINTILLA_QT) 135 LINK_LEXER(lmLPeg); 136 #endif 137 LINK_LEXER(lmLua); 138 LINK_LEXER(lmMagikSF); 139 LINK_LEXER(lmMake); 140 LINK_LEXER(lmMarkdown); 141 LINK_LEXER(lmMatlab); 142 LINK_LEXER(lmMaxima); 143 LINK_LEXER(lmMETAPOST); 144 LINK_LEXER(lmMMIXAL); 145 LINK_LEXER(lmModula); 146 LINK_LEXER(lmMSSQL); 147 LINK_LEXER(lmMySQL); 148 LINK_LEXER(lmNimrod); 149 LINK_LEXER(lmNncrontab); 150 LINK_LEXER(lmNsis); 151 LINK_LEXER(lmNull); 152 LINK_LEXER(lmOctave); 153 LINK_LEXER(lmOpal); 154 LINK_LEXER(lmOScript); 155 LINK_LEXER(lmPascal); 156 LINK_LEXER(lmPB); 157 LINK_LEXER(lmPerl); 158 LINK_LEXER(lmPHPSCRIPT); 159 LINK_LEXER(lmPLM); 160 LINK_LEXER(lmPO); 161 LINK_LEXER(lmPOV); 162 LINK_LEXER(lmPowerPro); 163 LINK_LEXER(lmPowerShell); 164 LINK_LEXER(lmProgress); 165 LINK_LEXER(lmProps); 166 LINK_LEXER(lmPS); 167 LINK_LEXER(lmPureBasic); 168 LINK_LEXER(lmPython); 169 LINK_LEXER(lmR); 170 LINK_LEXER(lmREBOL); 171 LINK_LEXER(lmRegistry); 172 LINK_LEXER(lmRuby); 173 LINK_LEXER(lmRust); 174 LINK_LEXER(lmSAS); 175 LINK_LEXER(lmScriptol); 176 LINK_LEXER(lmSmalltalk); 177 LINK_LEXER(lmSML); 178 LINK_LEXER(lmSorc); 179 LINK_LEXER(lmSpecman); 180 LINK_LEXER(lmSpice); 181 LINK_LEXER(lmSQL); 182 LINK_LEXER(lmSrec); 183 LINK_LEXER(lmStata); 184 LINK_LEXER(lmSTTXT); 185 LINK_LEXER(lmTACL); 186 LINK_LEXER(lmTADS3); 187 LINK_LEXER(lmTAL); 188 LINK_LEXER(lmTCL); 189 LINK_LEXER(lmTCMD); 190 LINK_LEXER(lmTEHex); 191 LINK_LEXER(lmTeX); 192 LINK_LEXER(lmTxt2tags); 193 LINK_LEXER(lmVB); 194 LINK_LEXER(lmVBScript); 195 LINK_LEXER(lmVerilog); 196 LINK_LEXER(lmVHDL); 197 LINK_LEXER(lmVisualProlog); 198 LINK_LEXER(lmXML); 199 LINK_LEXER(lmYAML); 200 201 //--Autogenerated -- end of automatically generated section 202 203 return 1; 204 } 205