Merge pull request #2212 from TwlyY29/bibtex-parser
[geany-mirror.git] / scintilla / lexlib / LexerModule.h
blobab338bec61855cf416faf85fa73166cc245d38a8
1 // Scintilla source code edit control
2 /** @file LexerModule.h
3 ** Colourise for particular languages.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef LEXERMODULE_H
9 #define LEXERMODULE_H
11 namespace Scintilla {
13 class Accessor;
14 class WordList;
15 struct LexicalClass;
17 typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
18 WordList *keywordlists[], Accessor &styler);
19 typedef ILexer *(*LexerFactoryFunction)();
21 /**
22 * A LexerModule is responsible for lexing and folding a particular language.
23 * The Catalogue class maintains a list of LexerModules which can be searched to find a
24 * module appropriate to a particular language.
25 * The ExternalLexerModule subclass holds lexers loaded from DLLs or shared libraries.
27 class LexerModule {
28 protected:
29 int language;
30 LexerFunction fnLexer;
31 LexerFunction fnFolder;
32 LexerFactoryFunction fnFactory;
33 const char * const * wordListDescriptions;
34 const LexicalClass *lexClasses;
35 size_t nClasses;
37 public:
38 const char *languageName;
39 LexerModule(
40 int language_,
41 LexerFunction fnLexer_,
42 const char *languageName_=nullptr,
43 LexerFunction fnFolder_= nullptr,
44 const char * const wordListDescriptions_[]=nullptr,
45 const LexicalClass *lexClasses_=nullptr,
46 size_t nClasses_=0);
47 LexerModule(
48 int language_,
49 LexerFactoryFunction fnFactory_,
50 const char *languageName_,
51 const char * const wordListDescriptions_[]=nullptr);
52 virtual ~LexerModule();
53 int GetLanguage() const;
55 // -1 is returned if no WordList information is available
56 int GetNumWordLists() const;
57 const char *GetWordListDescription(int index) const;
58 const LexicalClass *LexClasses() const;
59 size_t NamedStyles() const;
61 ILexer *Create() const;
63 virtual void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
64 WordList *keywordlists[], Accessor &styler) const;
65 virtual void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
66 WordList *keywordlists[], Accessor &styler) const;
68 friend class Catalogue;
71 inline int Maximum(int a, int b) {
72 return (a > b) ? a : b;
75 // Shut up annoying Visual C++ warnings:
76 #ifdef _MSC_VER
77 #pragma warning(disable: 4244 4456 4457)
78 #endif
80 // Turn off shadow warnings for lexers as may be maintained by others
81 #if defined(__GNUC__)
82 #pragma GCC diagnostic ignored "-Wshadow"
83 #endif
87 #endif