]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/include/KeyWords.h
Cast to void* before casting to Node** to make the compiler do no strict-aliasing...
[wxWidgets.git] / contrib / src / stc / scintilla / include / KeyWords.h
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>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
9 WordList *keywordlists[], Accessor &styler);
10
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 */
16 class LexerModule {
17 protected:
18 const LexerModule *next;
19 int language;
20 LexerFunction fnLexer;
21 LexerFunction fnFolder;
22 const char * const * wordListDescriptions;
23
24 static const LexerModule *base;
25 static int nextLanguage;
26
27 public:
28 const char *languageName;
29 LexerModule(int language_, LexerFunction fnLexer_,
30 const char *languageName_=0, LexerFunction fnFolder_=0,
31 const char * const wordListDescriptions_[] = NULL);
32 int GetLanguage() const { return language; }
33
34 // -1 is returned if no WordList information is available
35 int GetNumWordLists() const;
36 const char *GetWordListDescription(int index) const;
37
38 virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
39 WordList *keywordlists[], Accessor &styler) const;
40 virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
41 WordList *keywordlists[], Accessor &styler) const;
42 static const LexerModule *Find(int language);
43 static const LexerModule *Find(const char *languageName);
44 };
45
46 /**
47 * Check if a character is a space.
48 * This is ASCII specific but is safe with chars >= 0x80.
49 */
50 inline bool isspacechar(unsigned char ch) {
51 return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
52 }
53
54 inline bool iswordchar(char ch) {
55 return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
56 }
57
58 inline bool iswordstart(char ch) {
59 return isascii(ch) && (isalnum(ch) || ch == '_');
60 }
61
62 inline bool isoperator(char ch) {
63 if (isascii(ch) && isalnum(ch))
64 return false;
65 // '.' left out as it is used to make up numbers
66 if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
67 ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
68 ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
69 ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
70 ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
71 ch == '?' || ch == '!' || ch == '.' || ch == '~')
72 return true;
73 return false;
74 }