]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/include/KeyWords.h
clean up of memory debugging macros and chanegs to compile with CW7 (patch 548408)
[wxWidgets.git] / src / stc / scintilla / include / KeyWords.h
CommitLineData
65ec6247
RD
1// Scintilla source code edit control
2/** @file KeyWords.h
3 ** Colourise for particular languages.
4 **/
5// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
9ce192d4
RD
6// The License.txt file describes the conditions under which this software may be distributed.
7
f6bcfd97
BP
8typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
9 WordList *keywordlists[], Accessor &styler);
10
65ec6247
RD
11/**
12 * A LexerModule is responsible for lexing and folding a particular language.
13 * The class maintains a list of LexerModules which can be searched to find a
14 * module appropriate to a particular language.
15 */
f6bcfd97 16class LexerModule {
65ec6247 17protected:
1a2fb4cd 18 const LexerModule *next;
f6bcfd97 19 int language;
65ec6247
RD
20 LexerFunction fnLexer;
21 LexerFunction fnFolder;
22
1a2fb4cd 23 static const LexerModule *base;
65ec6247
RD
24 static int nextLanguage;
25
f6bcfd97 26public:
1a2fb4cd 27 const char *languageName;
65ec6247
RD
28 LexerModule(int language_, LexerFunction fnLexer_,
29 const char *languageName_=0, LexerFunction fnFolder_=0);
1a2fb4cd 30 int GetLanguage() const { return language; }
65ec6247 31 virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
1a2fb4cd 32 WordList *keywordlists[], Accessor &styler) const;
65ec6247 33 virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
1a2fb4cd
RD
34 WordList *keywordlists[], Accessor &styler) const;
35 static const LexerModule *Find(int language);
36 static const LexerModule *Find(const char *languageName);
f6bcfd97
BP
37};
38
65ec6247
RD
39/**
40 * Check if a character is a space.
41 * This is ASCII specific but is safe with chars >= 0x80.
42 */
43inline bool isspacechar(unsigned char ch) {
44 return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
45}
46
f6bcfd97 47inline bool iswordchar(char ch) {
65ec6247 48 return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
f6bcfd97
BP
49}
50
51inline bool iswordstart(char ch) {
65ec6247 52 return isascii(ch) && (isalnum(ch) || ch == '_');
f6bcfd97
BP
53}
54
55inline bool isoperator(char ch) {
65ec6247 56 if (isascii(ch) && isalnum(ch))
f6bcfd97
BP
57 return false;
58 // '.' left out as it is used to make up numbers
59 if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
60 ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
61 ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
62 ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
63 ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
64 ch == '?' || ch == '!' || ch == '.' || ch == '~')
65 return true;
66 return false;
67}