]>
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.
16 // Each word contains at least one character - a empty word acts as sentinel at the end.
20 bool onlyLineEnds
; ///< Delimited by any white space or only line ends
23 WordList(bool onlyLineEnds_
= false) :
24 words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_
),
27 ~WordList() { Clear(); }
28 operator bool() { return len
? true : false; }
30 void Set(const char *s
);
31 bool InList(const char *s
);
32 bool InListAbbreviated(const char *s
, const char marker
);
35 typedef void (*LexerFunction
)(unsigned int startPos
, int lengthDoc
, int initStyle
,
36 WordList
*keywordlists
[], Accessor
&styler
);
39 * A LexerModule is responsible for lexing and folding a particular language.
40 * The class maintains a list of LexerModules which can be searched to find a
41 * module appropriate to a particular language.
45 const LexerModule
*next
;
47 LexerFunction fnLexer
;
48 LexerFunction fnFolder
;
49 const char * const * wordListDescriptions
;
52 static const LexerModule
*base
;
53 static int nextLanguage
;
56 const char *languageName
;
57 LexerModule(int language_
,
58 LexerFunction fnLexer_
,
59 const char *languageName_
=0,
60 LexerFunction fnFolder_
=0,
61 const char * const wordListDescriptions_
[] = NULL
,
63 virtual ~LexerModule() {
65 int GetLanguage() const { return language
; }
67 // -1 is returned if no WordList information is available
68 int GetNumWordLists() const;
69 const char *GetWordListDescription(int index
) const;
71 int GetStyleBitsNeeded() const;
73 virtual void Lex(unsigned int startPos
, int lengthDoc
, int initStyle
,
74 WordList
*keywordlists
[], Accessor
&styler
) const;
75 virtual void Fold(unsigned int startPos
, int lengthDoc
, int initStyle
,
76 WordList
*keywordlists
[], Accessor
&styler
) const;
77 static const LexerModule
*Find(int language
);
78 static const LexerModule
*Find(const char *languageName
);
86 * Check if a character is a space.
87 * This is ASCII specific but is safe with chars >= 0x80.
89 inline bool isspacechar(unsigned char ch
) {
90 return (ch
== ' ') || ((ch
>= 0x09) && (ch
<= 0x0d));
93 inline bool iswordchar(char ch
) {
94 return isascii(ch
) && (isalnum(ch
) || ch
== '.' || ch
== '_');
97 inline bool iswordstart(char ch
) {
98 return isascii(ch
) && (isalnum(ch
) || ch
== '_');
101 inline bool isoperator(char ch
) {
102 if (isascii(ch
) && isalnum(ch
))
104 // '.' left out as it is used to make up numbers
105 if (ch
== '%' || ch
== '^' || ch
== '&' || ch
== '*' ||
106 ch
== '(' || ch
== ')' || ch
== '-' || ch
== '+' ||
107 ch
== '=' || ch
== '|' || ch
== '{' || ch
== '}' ||
108 ch
== '[' || ch
== ']' || ch
== ':' || ch
== ';' ||
109 ch
== '<' || ch
== '>' || ch
== ',' || ch
== '/' ||
110 ch
== '?' || ch
== '!' || ch
== '.' || ch
== '~')