notepad-plus-plus/lexilla/lexlib/LexerModule.h

93 lines
2.7 KiB
C
Raw Normal View History

// Scintilla source code edit control
/** @file LexerModule.h
** Colourise for particular languages.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef LEXERMODULE_H
#define LEXERMODULE_H
namespace Lexilla {
class Accessor;
class WordList;
struct LexicalClass;
typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
typedef Scintilla::ILexer5 *(*LexerFactoryFunction)();
/**
* A LexerModule is responsible for lexing and folding a particular language.
* The Catalogue class maintains a list of LexerModules which can be searched to find a
* module appropriate to a particular language.
* The ExternalLexerModule subclass holds lexers loaded from DLLs or shared libraries.
*/
class LexerModule {
protected:
int language;
LexerFunction fnLexer;
LexerFunction fnFolder;
LexerFactoryFunction fnFactory;
const char * const * wordListDescriptions;
const LexicalClass *lexClasses;
size_t nClasses;
public:
const char *languageName;
LexerModule(
int language_,
LexerFunction fnLexer_,
const char *languageName_=nullptr,
LexerFunction fnFolder_= nullptr,
const char * const wordListDescriptions_[]=nullptr,
const LexicalClass *lexClasses_=nullptr,
size_t nClasses_=0) noexcept;
LexerModule(
int language_,
LexerFactoryFunction fnFactory_,
const char *languageName_,
const char * const wordListDescriptions_[]=nullptr) noexcept;
int GetLanguage() const noexcept;
// -1 is returned if no WordList information is available
int GetNumWordLists() const noexcept;
const char *GetWordListDescription(int index) const noexcept;
const LexicalClass *LexClasses() const noexcept;
size_t NamedStyles() const noexcept;
Scintilla::ILexer5 *Create() const;
void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
friend class CatalogueModules;
};
constexpr int Maximum(int a, int b) noexcept {
return (a > b) ? a : b;
}
// Shut up annoying Visual C++ warnings:
Update to Scintilla 5.3.3 and Lexilla 5.2.2 update to https://www.scintilla.org/scintilla533.zip with: 1. Released 8 February 2023. 2. Fix SCI_LINESJOIN bug where carriage returns were incorrectly retained. Bug #2372. 3. Fix SCI_VERTICALCENTRECARET to update the vertical scroll position. 4. When an autocompletion list is shown in response to SCN_CHARADDED, do not process character as fill-up or stop. This avoids closing immediately when a character may both trigger and finish autocompletion. 5. On Cocoa fix character input bug where dotless 'i' and some other extended Latin characters could not be entered. The change also stops SCI_ASSIGNCMDKEY from working with these characters on Cocoa. Bug #2374. 6. On GTK, support IME context. Feature #1476. 7. On GTK on Win32, fix scrolling speed to not be too fast. Bug #2375. 8. On Qt, fix indicator drawing past left of text pane over margin. Bug #2373, Bug #1956. 9. On Qt, allow scrolling with mouse wheel when scroll bar hidden. and https://www.scintilla.org/lexilla522.zip with 1. Released 8 February 2023. 2. C++: Fix keywords that start with non-ASCII. Also affects other lexers. Issue #130. 3. Matlab: Include more prefix and suffix characters in numeric literals. Issue #120. 4. Matlab: More accurate treatment of line ends inside strings. Matlab and Octave are different here. Issue #18. 5. Modula-3: Don't treat identifier suffix that matches keyword as keyword. Issue #129. 6. Modula-3: Fix endless loop in folder. Issue #128. 7. Modula-3: Fix access to lines beyond document end in folder. Issue #131. 8. Python: Don't highlight match and case as keywords in contexts where they probably aren't used as keywords. Pull request #122. 9. X12: Support empty envelopes. Bug #2369. update CMakeLists.txt to latest changes within vcxproj file Close #13082
2023-02-09 16:57:24 +00:00
#if defined(_MSC_VER)
#pragma warning(disable: 4244 4456 4457)
#endif
// Turn off shadow warnings for lexers as may be maintained by others
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wshadow"
#endif
// Clang doesn't like omitting braces in array initialization but they just add
// noise to LexicalClass arrays in lexers
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
}
#endif