1 // Scintilla source code edit control
2 /** @file LexerModule.h
3 ** Colourise for particular languages.
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.
17 typedef void (*LexerFunction
)(Sci_PositionU startPos
, Sci_Position lengthDoc
, int initStyle
,
18 WordList
*keywordlists
[], Accessor
&styler
);
19 typedef ILexer
*(*LexerFactoryFunction
)();
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.
30 LexerFunction fnLexer
;
31 LexerFunction fnFolder
;
32 LexerFactoryFunction fnFactory
;
33 const char * const * wordListDescriptions
;
34 const LexicalClass
*lexClasses
;
38 const char *languageName
;
41 LexerFunction fnLexer_
,
42 const char *languageName_
=nullptr,
43 LexerFunction fnFolder_
= nullptr,
44 const char * const wordListDescriptions_
[]=nullptr,
45 const LexicalClass
*lexClasses_
=nullptr,
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:
77 #pragma warning(disable: 4244 4456 4457)
80 // Turn off shadow warnings for lexers as may be maintained by others
82 #pragma GCC diagnostic ignored "-Wshadow"