]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/KeyWords.cxx
def79f6ecdce17cfe32c1801e71064bbfb300a65
1 // Scintilla source code edit control
3 ** Colourise for particular languages.
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
19 #include "Scintilla.h"
22 const LexerModule
*LexerModule::base
= 0;
23 int LexerModule::nextLanguage
= SCLEX_AUTOMATIC
+1;
25 LexerModule::LexerModule(int language_
, LexerFunction fnLexer_
,
26 const char *languageName_
, LexerFunction fnFolder_
,
27 const char * const wordListDescriptions_
[]) :
31 wordListDescriptions(wordListDescriptions_
),
32 languageName(languageName_
) {
35 if (language
== SCLEX_AUTOMATIC
) {
36 language
= nextLanguage
;
41 int LexerModule::GetNumWordLists() const {
42 if (wordListDescriptions
== NULL
) {
47 while (wordListDescriptions
[numWordLists
]) {
55 const char * LexerModule::GetWordListDescription(int index
) const {
56 static const char *emptyStr
= "";
58 PLATFORM_ASSERT(index
< GetNumWordLists());
59 if (index
>= GetNumWordLists()) {
62 return wordListDescriptions
[index
];
66 const LexerModule
*LexerModule::Find(int language
) {
67 const LexerModule
*lm
= base
;
69 if (lm
->language
== language
) {
77 const LexerModule
*LexerModule::Find(const char *languageName
) {
79 const LexerModule
*lm
= base
;
81 if (lm
->languageName
&& 0 == strcmp(lm
->languageName
, languageName
)) {
90 void LexerModule::Lex(unsigned int startPos
, int lengthDoc
, int initStyle
,
91 WordList
*keywordlists
[], Accessor
&styler
) const {
93 fnLexer(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
96 void LexerModule::Fold(unsigned int startPos
, int lengthDoc
, int initStyle
,
97 WordList
*keywordlists
[], Accessor
&styler
) const {
99 int lineCurrent
= styler
.GetLine(startPos
);
100 // Move back one line in case deletion wrecked current line fold state
101 if (lineCurrent
> 0) {
103 int newStartPos
= styler
.LineStart(lineCurrent
);
104 lengthDoc
+= startPos
- newStartPos
;
105 startPos
= newStartPos
;
108 initStyle
= styler
.StyleAt(startPos
- 1);
111 fnFolder(startPos
, lengthDoc
, initStyle
, keywordlists
, styler
);
115 // Alternative historical name for Scintilla_LinkLexers
116 int wxForceScintillaLexers(void) {
117 return Scintilla_LinkLexers();
120 // To add or remove a lexer, add or remove its file and run LexGen.py.
122 // Force a reference to all of the Scintilla lexers so that the linker will
123 // not remove the code of the lexers.
124 int Scintilla_LinkLexers() {
125 static int forcer
= 0;
127 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
128 #define LINK_LEXER(lexer) extern LexerModule lexer; forcer += lexer.GetLanguage();
130 //++Autogenerated -- run src/LexGen.py to regenerate
131 //**\(\tLINK_LEXER(\*);\n\)
139 LINK_LEXER(lmBullant
);
141 LINK_LEXER(lmClwNoCase
);
144 LINK_LEXER(lmCPPNoCase
);
146 LINK_LEXER(lmNncrontab
);
148 LINK_LEXER(lmEiffel
);
149 LINK_LEXER(lmEiffelkw
);
150 LINK_LEXER(lmErlang
);
151 LINK_LEXER(lmESCRIPT
);
153 LINK_LEXER(lmFortran
);
155 LINK_LEXER(lmGui4Cli
);
164 LINK_LEXER(lmMatlab
);
165 LINK_LEXER(lmOctave
);
166 LINK_LEXER(lmMETAPOST
);
167 LINK_LEXER(lmMMIXAL
);
175 LINK_LEXER(lmErrorList
);
178 LINK_LEXER(lmPascal
);
183 LINK_LEXER(lmPython
);
185 LINK_LEXER(lmScriptol
);
186 LINK_LEXER(lmSpecman
);
190 LINK_LEXER(lmVBScript
);
191 LINK_LEXER(lmVerilog
);
194 //--Autogenerated -- end of automatically generated section