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(lmCIL); 94 LINK_LEXER(lmClw); 95 LINK_LEXER(lmClwNoCase); 96 LINK_LEXER(lmCmake); 97 LINK_LEXER(lmCOBOL); 98 LINK_LEXER(lmCoffeeScript); 99 LINK_LEXER(lmConf); 100 LINK_LEXER(lmCPP); 101 LINK_LEXER(lmCPPNoCase); 102 LINK_LEXER(lmCsound); 103 LINK_LEXER(lmCss); 104 LINK_LEXER(lmD); 105 LINK_LEXER(lmDataflex); 106 LINK_LEXER(lmDiff); 107 LINK_LEXER(lmDMAP); 108 LINK_LEXER(lmDMIS); 109 LINK_LEXER(lmECL); 110 LINK_LEXER(lmEDIFACT); 111 LINK_LEXER(lmEiffel); 112 LINK_LEXER(lmEiffelkw); 113 LINK_LEXER(lmErlang); 114 LINK_LEXER(lmErrorList); 115 LINK_LEXER(lmESCRIPT); 116 LINK_LEXER(lmF77); 117 LINK_LEXER(lmFlagShip); 118 LINK_LEXER(lmForth); 119 LINK_LEXER(lmFortran); 120 LINK_LEXER(lmFreeBasic); 121 LINK_LEXER(lmGAP); 122 LINK_LEXER(lmGui4Cli); 123 LINK_LEXER(lmHaskell); 124 LINK_LEXER(lmHollywood); 125 LINK_LEXER(lmHTML); 126 LINK_LEXER(lmIHex); 127 LINK_LEXER(lmIndent); 128 LINK_LEXER(lmInno); 129 LINK_LEXER(lmJSON); 130 LINK_LEXER(lmKix); 131 LINK_LEXER(lmKVIrc); 132 LINK_LEXER(lmLatex); 133 LINK_LEXER(lmLISP); 134 LINK_LEXER(lmLiterateHaskell); 135 LINK_LEXER(lmLot); 136 LINK_LEXER(lmLout); 137 LINK_LEXER(lmLPeg); 138 LINK_LEXER(lmLua); 139 LINK_LEXER(lmMagikSF); 140 LINK_LEXER(lmMake); 141 LINK_LEXER(lmMarkdown); 142 LINK_LEXER(lmMatlab); 143 LINK_LEXER(lmMaxima); 144 LINK_LEXER(lmMETAPOST); 145 LINK_LEXER(lmMMIXAL); 146 LINK_LEXER(lmModula); 147 LINK_LEXER(lmMSSQL); 148 LINK_LEXER(lmMySQL); 149 LINK_LEXER(lmNim); 150 LINK_LEXER(lmNimrod); 151 LINK_LEXER(lmNncrontab); 152 LINK_LEXER(lmNsis); 153 LINK_LEXER(lmNull); 154 LINK_LEXER(lmOctave); 155 LINK_LEXER(lmOpal); 156 LINK_LEXER(lmOScript); 157 LINK_LEXER(lmPascal); 158 LINK_LEXER(lmPB); 159 LINK_LEXER(lmPerl); 160 LINK_LEXER(lmPHPSCRIPT); 161 LINK_LEXER(lmPLM); 162 LINK_LEXER(lmPO); 163 LINK_LEXER(lmPOV); 164 LINK_LEXER(lmPowerPro); 165 LINK_LEXER(lmPowerShell); 166 LINK_LEXER(lmProgress); 167 LINK_LEXER(lmProps); 168 LINK_LEXER(lmPS); 169 LINK_LEXER(lmPureBasic); 170 LINK_LEXER(lmPython); 171 LINK_LEXER(lmR); 172 LINK_LEXER(lmREBOL); 173 LINK_LEXER(lmRegistry); 174 LINK_LEXER(lmRuby); 175 LINK_LEXER(lmRust); 176 LINK_LEXER(lmSAS); 177 LINK_LEXER(lmScriptol); 178 LINK_LEXER(lmSmalltalk); 179 LINK_LEXER(lmSML); 180 LINK_LEXER(lmSorc); 181 LINK_LEXER(lmSpecman); 182 LINK_LEXER(lmSpice); 183 LINK_LEXER(lmSQL); 184 LINK_LEXER(lmSrec); 185 LINK_LEXER(lmStata); 186 LINK_LEXER(lmSTTXT); 187 LINK_LEXER(lmTACL); 188 LINK_LEXER(lmTADS3); 189 LINK_LEXER(lmTAL); 190 LINK_LEXER(lmTCL); 191 LINK_LEXER(lmTCMD); 192 LINK_LEXER(lmTEHex); 193 LINK_LEXER(lmTeX); 194 LINK_LEXER(lmTxt2tags); 195 LINK_LEXER(lmVB); 196 LINK_LEXER(lmVBScript); 197 LINK_LEXER(lmVerilog); 198 LINK_LEXER(lmVHDL); 199 LINK_LEXER(lmVisualProlog); 200 LINK_LEXER(lmX12); 201 LINK_LEXER(lmXML); 202 LINK_LEXER(lmYAML); 203 204 //--Autogenerated -- end of automatically generated section 205 206 return 1; 207 } 208