]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/KeyWords.h
1 // Scintilla source code edit control
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.
12 typedef void (*LexerFunction
)(unsigned int startPos
, int lengthDoc
, int initStyle
,
13 WordList
*keywordlists
[], Accessor
&styler
);
16 * A LexerModule is responsible for lexing and folding a particular language.
17 * The class maintains a list of LexerModules which can be searched to find a
18 * module appropriate to a particular language.
22 const LexerModule
*next
;
24 LexerFunction fnLexer
;
25 LexerFunction fnFolder
;
26 const char * const * wordListDescriptions
;
29 static const LexerModule
*base
;
30 static int nextLanguage
;
33 const char *languageName
;
34 LexerModule(int language_
,
35 LexerFunction fnLexer_
,
36 const char *languageName_
=0,
37 LexerFunction fnFolder_
=0,
38 const char * const wordListDescriptions_
[] = NULL
,
40 virtual ~LexerModule() {
42 int GetLanguage() const { return language
; }
44 // -1 is returned if no WordList information is available
45 int GetNumWordLists() const;
46 const char *GetWordListDescription(int index
) const;
48 int GetStyleBitsNeeded() const;
50 virtual void Lex(unsigned int startPos
, int lengthDoc
, int initStyle
,
51 WordList
*keywordlists
[], Accessor
&styler
) const;
52 virtual void Fold(unsigned int startPos
, int lengthDoc
, int initStyle
,
53 WordList
*keywordlists
[], Accessor
&styler
) const;
54 static const LexerModule
*Find(int language
);
55 static const LexerModule
*Find(const char *languageName
);
63 * Check if a character is a space.
64 * This is ASCII specific but is safe with chars >= 0x80.
66 inline bool isspacechar(unsigned char ch
) {
67 return (ch
== ' ') || ((ch
>= 0x09) && (ch
<= 0x0d));
70 inline bool iswordchar(char ch
) {
71 return isascii(ch
) && (isalnum(ch
) || ch
== '.' || ch
== '_');
74 inline bool iswordstart(char ch
) {
75 return isascii(ch
) && (isalnum(ch
) || ch
== '_');
78 inline bool isoperator(char ch
) {
79 if (isascii(ch
) && isalnum(ch
))
81 // '.' left out as it is used to make up numbers
82 if (ch
== '%' || ch
== '^' || ch
== '&' || ch
== '*' ||
83 ch
== '(' || ch
== ')' || ch
== '-' || ch
== '+' ||
84 ch
== '=' || ch
== '|' || ch
== '{' || ch
== '}' ||
85 ch
== '[' || ch
== ']' || ch
== ':' || ch
== ';' ||
86 ch
== '<' || ch
== '>' || ch
== ',' || ch
== '/' ||
87 ch
== '?' || ch
== '!' || ch
== '.' || ch
== '~')