]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/LexOthers.cxx
6d537c9b6c2294e3200158f56738a9e2e35b58df
[wxWidgets.git] / src / stc / scintilla / src / LexOthers.cxx
1 // Scintilla source code edit control
2 /** @file LexOthers.cxx
3 ** Lexers for batch files, diff results, properties files, make files and error lists.
4 ** Also lexer for LaTeX documents.
5 **/
6 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
7 // The License.txt file describes the conditions under which this software may be distributed.
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <stdio.h>
13 #include <stdarg.h>
14
15 #include "Platform.h"
16
17 #include "PropSet.h"
18 #include "Accessor.h"
19 #include "KeyWords.h"
20 #include "Scintilla.h"
21 #include "SciLexer.h"
22
23 static bool Is0To9(char ch) {
24 return (ch >= '0') && (ch <= '9');
25 }
26
27 static bool Is1To9(char ch) {
28 return (ch >= '1') && (ch <= '9');
29 }
30
31 static inline bool AtEOL(Accessor &styler, unsigned int i) {
32 return (styler[i] == '\n') ||
33 ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
34 }
35
36 static void ColouriseBatchLine(
37 char *lineBuffer,
38 unsigned int lengthLine,
39 unsigned int startLine,
40 unsigned int endPos,
41 WordList &keywords,
42 Accessor &styler) {
43
44 unsigned int i = 0;
45 unsigned int state = SCE_BAT_DEFAULT;
46
47 while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
48 i++;
49 }
50 if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
51 styler.ColourTo(startLine + i, SCE_BAT_HIDE);
52 i++;
53 while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
54 i++;
55 }
56 }
57 if (lineBuffer[i] == ':') {
58 // Label
59 if (lineBuffer[i + 1] == ':') {
60 // :: is a fake label, similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm
61 styler.ColourTo(endPos, SCE_BAT_COMMENT);
62 } else { // Real label
63 styler.ColourTo(endPos, SCE_BAT_LABEL);
64 }
65 } else {
66 // Check if initial word is a keyword
67 char wordBuffer[21];
68 unsigned int wbl = 0, offset = i;
69 // Copy word in buffer
70 for (; offset < lengthLine && wbl < 20 &&
71 !isspacechar(lineBuffer[offset]); wbl++, offset++) {
72 wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
73 }
74 wordBuffer[wbl] = '\0';
75 // Check if it is a comment
76 if (CompareCaseInsensitive(wordBuffer, "rem") == 0) {
77 styler.ColourTo(endPos, SCE_BAT_COMMENT);
78 return ;
79 }
80 // Check if it is in the list
81 if (keywords.InList(wordBuffer)) {
82 styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); // Regular keyword
83 } else {
84 // Search end of word (can be a long path)
85 while (offset < lengthLine &&
86 !isspacechar(lineBuffer[offset])) {
87 offset++;
88 }
89 styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); // External command / program
90 }
91 // Remainder of the line: colourise the variables.
92
93 while (offset < lengthLine) {
94 if (state == SCE_BAT_DEFAULT && lineBuffer[offset] == '%') {
95 styler.ColourTo(startLine + offset - 1, state);
96 if (Is0To9(lineBuffer[offset + 1])) {
97 styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
98 offset += 2;
99 } else if (lineBuffer[offset + 1] == '%' &&
100 !isspacechar(lineBuffer[offset + 2])) {
101 // Should be safe, as there is CRLF at the end of the line...
102 styler.ColourTo(startLine + offset + 2, SCE_BAT_IDENTIFIER);
103 offset += 3;
104 } else {
105 state = SCE_BAT_IDENTIFIER;
106 }
107 } else if (state == SCE_BAT_IDENTIFIER && lineBuffer[offset] == '%') {
108 styler.ColourTo(startLine + offset, state);
109 state = SCE_BAT_DEFAULT;
110 } else if (state == SCE_BAT_DEFAULT &&
111 (lineBuffer[offset] == '*' ||
112 lineBuffer[offset] == '?' ||
113 lineBuffer[offset] == '=' ||
114 lineBuffer[offset] == '<' ||
115 lineBuffer[offset] == '>' ||
116 lineBuffer[offset] == '|')) {
117 styler.ColourTo(startLine + offset - 1, state);
118 styler.ColourTo(startLine + offset, SCE_BAT_OPERATOR);
119 }
120 offset++;
121 }
122 // if (endPos > startLine + offset - 1) {
123 styler.ColourTo(endPos, SCE_BAT_DEFAULT); // Remainder of line, currently not lexed
124 // }
125 }
126
127 }
128 // ToDo: (not necessarily at beginning of line) GOTO, [IF] NOT, ERRORLEVEL
129 // IF [NO] (test) (command) -- test is EXIST (filename) | (string1)==(string2) | ERRORLEVEL (number)
130 // FOR %%(variable) IN (set) DO (command) -- variable is [a-zA-Z] -- eg for %%X in (*.txt) do type %%X
131 // ToDo: %n (parameters), %EnvironmentVariable% colourising
132 // ToDo: Colourise = > >> < | "
133
134 static void ColouriseBatchDoc(
135 unsigned int startPos,
136 int length,
137 int /*initStyle*/,
138 WordList *keywordlists[],
139 Accessor &styler) {
140
141 char lineBuffer[1024];
142 WordList &keywords = *keywordlists[0];
143
144 styler.StartAt(startPos);
145 styler.StartSegment(startPos);
146 unsigned int linePos = 0;
147 unsigned int startLine = startPos;
148 for (unsigned int i = startPos; i < startPos + length; i++) {
149 lineBuffer[linePos++] = styler[i];
150 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
151 // End of line (or of line buffer) met, colourise it
152 lineBuffer[linePos] = '\0';
153 ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
154 linePos = 0;
155 startLine = i + 1;
156 }
157 }
158 if (linePos > 0) { // Last line does not have ending characters
159 ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
160 keywords, styler);
161 }
162 }
163
164 static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
165 // It is needed to remember the current state to recognize starting
166 // comment lines before the first "diff " or "--- ". If a real
167 // difference starts then each line starting with ' ' is a whitespace
168 // otherwise it is considered a comment (Only in..., Binary file...)
169 if (0 == strncmp(lineBuffer, "diff ", 3)) {
170 styler.ColourTo(endLine, SCE_DIFF_COMMAND);
171 } else if (0 == strncmp(lineBuffer, "--- ", 3)) {
172 styler.ColourTo(endLine, SCE_DIFF_HEADER);
173 } else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
174 styler.ColourTo(endLine, SCE_DIFF_HEADER);
175 } else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff
176 styler.ColourTo(endLine, SCE_DIFF_HEADER);
177 } else if (0 == strncmp(lineBuffer, "***", 3)) {
178 styler.ColourTo(endLine, SCE_DIFF_HEADER);
179 } else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib
180 styler.ColourTo(endLine, SCE_DIFF_HEADER);
181 } else if (lineBuffer[0] == '@') {
182 styler.ColourTo(endLine, SCE_DIFF_POSITION);
183 } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
184 styler.ColourTo(endLine, SCE_DIFF_DELETED);
185 } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
186 styler.ColourTo(endLine, SCE_DIFF_ADDED);
187 } else if (lineBuffer[0] != ' ') {
188 styler.ColourTo(endLine, SCE_DIFF_COMMENT);
189 } else {
190 styler.ColourTo(endLine, SCE_DIFF_DEFAULT);
191 }
192 }
193
194 static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
195 char lineBuffer[1024];
196 styler.StartAt(startPos);
197 styler.StartSegment(startPos);
198 unsigned int linePos = 0;
199 for (unsigned int i = startPos; i < startPos + length; i++) {
200 lineBuffer[linePos++] = styler[i];
201 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
202 // End of line (or of line buffer) met, colourise it
203 lineBuffer[linePos] = '\0';
204 ColouriseDiffLine(lineBuffer, i, styler);
205 linePos = 0;
206 }
207 }
208 if (linePos > 0) { // Last line does not have ending characters
209 ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
210 }
211 }
212
213 static void ColourisePropsLine(
214 char *lineBuffer,
215 unsigned int lengthLine,
216 unsigned int startLine,
217 unsigned int endPos,
218 Accessor &styler) {
219
220 unsigned int i = 0;
221 while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
222 i++;
223 if (i < lengthLine) {
224 if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
225 styler.ColourTo(endPos, SCE_PROPS_COMMENT);
226 } else if (lineBuffer[i] == '[') {
227 styler.ColourTo(endPos, SCE_PROPS_SECTION);
228 } else if (lineBuffer[i] == '@') {
229 styler.ColourTo(startLine + i, SCE_PROPS_DEFVAL);
230 if (lineBuffer[++i] == '=')
231 styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
232 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
233 } else {
234 // Search for the '=' character
235 while ((i < lengthLine) && (lineBuffer[i] != '='))
236 i++;
237 if ((i < lengthLine) && (lineBuffer[i] == '=')) {
238 styler.ColourTo(startLine + i - 1, SCE_PROPS_DEFAULT);
239 styler.ColourTo(startLine + i, 3);
240 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
241 } else {
242 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
243 }
244 }
245 } else {
246 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
247 }
248 }
249
250 static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
251 char lineBuffer[1024];
252 styler.StartAt(startPos);
253 styler.StartSegment(startPos);
254 unsigned int linePos = 0;
255 unsigned int startLine = startPos;
256 for (unsigned int i = startPos; i < startPos + length; i++) {
257 lineBuffer[linePos++] = styler[i];
258 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
259 // End of line (or of line buffer) met, colourise it
260 lineBuffer[linePos] = '\0';
261 ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
262 linePos = 0;
263 startLine = i + 1;
264 }
265 }
266 if (linePos > 0) { // Last line does not have ending characters
267 ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
268 }
269 }
270
271 static void ColouriseMakeLine(
272 char *lineBuffer,
273 unsigned int lengthLine,
274 unsigned int startLine,
275 unsigned int endPos,
276 Accessor &styler) {
277
278 unsigned int i = 0;
279 int lastNonSpace = -1;
280 unsigned int state = SCE_MAKE_DEFAULT;
281 bool bSpecial = false;
282 // Skip initial spaces
283 while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
284 i++;
285 }
286 if (lineBuffer[i] == '#') { // Comment
287 styler.ColourTo(endPos, SCE_MAKE_COMMENT);
288 return;
289 }
290 if (lineBuffer[i] == '!') { // Special directive
291 styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
292 return;
293 }
294 while (i < lengthLine) {
295 if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
296 styler.ColourTo(startLine + i - 1, state);
297 state = SCE_MAKE_IDENTIFIER;
298 } else if (state == SCE_MAKE_IDENTIFIER && lineBuffer[i] == ')') {
299 styler.ColourTo(startLine + i, state);
300 state = SCE_MAKE_DEFAULT;
301 }
302 if (!bSpecial) {
303 if (lineBuffer[i] == ':') {
304 // We should check that no colouring was made since the beginning of the line,
305 // to avoid colouring stuff like /OUT:file
306 if (lastNonSpace >= 0)
307 styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
308 styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
309 styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
310 bSpecial = true; // Only react to the first ':' of the line
311 state = SCE_MAKE_DEFAULT;
312 } else if (lineBuffer[i] == '=') {
313 if (lastNonSpace >= 0)
314 styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
315 styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
316 styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
317 bSpecial = true; // Only react to the first '=' of the line
318 state = SCE_MAKE_DEFAULT;
319 }
320 }
321 if (!isspacechar(lineBuffer[i])) {
322 lastNonSpace = i;
323 }
324 i++;
325 }
326 if (state == SCE_MAKE_IDENTIFIER) {
327 styler.ColourTo(endPos, SCE_MAKE_IDEOL); // Error, variable reference not ended
328 } else {
329 styler.ColourTo(endPos, SCE_MAKE_DEFAULT);
330 }
331 }
332
333 static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
334 char lineBuffer[1024];
335 styler.StartAt(startPos);
336 styler.StartSegment(startPos);
337 unsigned int linePos = 0;
338 unsigned int startLine = startPos;
339 for (unsigned int i = startPos; i < startPos + length; i++) {
340 lineBuffer[linePos++] = styler[i];
341 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
342 // End of line (or of line buffer) met, colourise it
343 lineBuffer[linePos] = '\0';
344 ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
345 linePos = 0;
346 startLine = i + 1;
347 }
348 }
349 if (linePos > 0) { // Last line does not have ending characters
350 ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
351 }
352 }
353
354 static bool strstart(char *haystack, char *needle) {
355 return strncmp(haystack, needle, strlen(needle)) == 0;
356 }
357
358 static void ColouriseErrorListLine(
359 char *lineBuffer,
360 unsigned int lengthLine,
361 // unsigned int startLine,
362 unsigned int endPos,
363 Accessor &styler) {
364 const int unRecognized = 99;
365 if (lineBuffer[0] == '>') {
366 // Command or return status
367 styler.ColourTo(endPos, SCE_ERR_CMD);
368 } else if (lineBuffer[0] == '<') {
369 // Diff removal, but not interested. Trapped to avoid hitting CTAG cases.
370 styler.ColourTo(endPos, SCE_ERR_DEFAULT);
371 } else if (lineBuffer[0] == '!') {
372 styler.ColourTo(endPos, SCE_ERR_DIFF_CHANGED);
373 } else if (lineBuffer[0] == '+') {
374 styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION);
375 } else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') {
376 styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE);
377 } else if (lineBuffer[0] == '-') {
378 styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
379 } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
380 styler.ColourTo(endPos, SCE_ERR_PYTHON);
381 } else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) {
382 styler.ColourTo(endPos, SCE_ERR_PHP);
383 } else if ((strstart(lineBuffer, "Error ") ||
384 strstart(lineBuffer, "Warning ")) &&
385 strstr(lineBuffer, " at (") &&
386 strstr(lineBuffer, ") : ") &&
387 (strstr(lineBuffer, " at (") < strstr(lineBuffer, ") : "))) {
388 // Intel Fortran Compiler error/warning message
389 styler.ColourTo(endPos, SCE_ERR_IFC);
390 } else if (strstart(lineBuffer, "Error ")) {
391 // Borland error message
392 styler.ColourTo(endPos, SCE_ERR_BORLAND);
393 } else if (strstart(lineBuffer, "Warning ")) {
394 // Borland warning message
395 styler.ColourTo(endPos, SCE_ERR_BORLAND);
396 } else if (strstr(lineBuffer, "at line " ) &&
397 (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
398 strstr(lineBuffer, "file ") &&
399 (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
400 // Lua error message
401 styler.ColourTo(endPos, SCE_ERR_LUA);
402 } else if (strstr(lineBuffer, " at " ) &&
403 (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
404 strstr(lineBuffer, " line ") &&
405 (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) &&
406 (strstr(lineBuffer, " at " ) < (strstr(lineBuffer, " line ")))) {
407 // perl error message
408 styler.ColourTo(endPos, SCE_ERR_PERL);
409 } else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
410 strstr(lineBuffer, ":line ")) {
411 // A .NET traceback
412 styler.ColourTo(endPos, SCE_ERR_NET);
413 } else if (strstart(lineBuffer, "Line ") &&
414 strstr(lineBuffer, ", file ")) {
415 // Essential Lahey Fortran error message
416 styler.ColourTo(endPos, SCE_ERR_ELF);
417 } else {
418 // Look for GCC <filename>:<line>:message
419 // Look for Microsoft <filename>(line) :message
420 // Look for Microsoft <filename>(line,pos)message
421 // Look for CTags \tmessage
422 int state = 0;
423 for (unsigned int i = 0; i < lengthLine; i++) {
424 char ch = lineBuffer[i];
425 char chNext = ' ';
426 if ((i+1) < lengthLine)
427 chNext = lineBuffer[i+1];
428 if (state == 0) {
429 if (ch == ':') {
430 // May be GCC
431 if ((chNext != '\\') && (chNext != '/')) {
432 // This check is not completely accurate as may be on
433 // GTK+ with a file name that includes ':'.
434 state = 1;
435 }
436 } else if ((ch == '(') && Is1To9(chNext)) {
437 // May be Microsoft
438 // Check againt '0' often removes phone numbers
439 state = 10;
440 } else if (ch == '\t') {
441 // May be CTags
442 state = 20;
443 }
444 } else if (state == 1) {
445 state = Is1To9(ch) ? 2 : unRecognized;
446 } else if (state == 2) {
447 if (ch == ':') {
448 state = 3; // :9.*: is GCC
449 break;
450 } else if (!Is0To9(ch)) {
451 state = unRecognized;
452 }
453 } else if (state == 10) {
454 state = Is0To9(ch) ? 11 : unRecognized;
455 } else if (state == 11) {
456 if (ch == ',') {
457 state = 14;
458 } else if (ch == ')') {
459 state = 12;
460 } else if ((ch != ' ') && !Is0To9(ch)) {
461 state = unRecognized;
462 }
463 } else if (state == 12) {
464 if ((ch == ' ') && (chNext == ':'))
465 state = 13;
466 else
467 state = unRecognized;
468 } else if (state == 14) {
469 if (ch == ')') {
470 state = 15;
471 break;
472 } else if ((ch != ' ') && !Is0To9(ch)) {
473 state = unRecognized;
474 }
475 } else if (state == 20) {
476 if ((lineBuffer[i-1] == '\t') &&
477 ((ch == '/' && lineBuffer[i+1] == '^') || Is0To9(ch))) {
478 state = 24;
479 break;
480 } else if ((ch == '/') && (lineBuffer[i+1] == '^')) {
481 state = 21;
482 }
483 } else if ((state == 21) && ((lineBuffer[i] == '$') && (lineBuffer[i+1] == '/'))) {
484 state = 22;
485 break;
486 }
487 }
488 if (state == 3) {
489 styler.ColourTo(endPos, SCE_ERR_GCC);
490 } else if ((state == 13) || (state == 14) || (state == 15)) {
491 styler.ColourTo(endPos, SCE_ERR_MS);
492 } else if (((state == 22) || (state == 24)) && (lineBuffer[0] != '\t')) {
493 styler.ColourTo(endPos, SCE_ERR_CTAG);
494 } else {
495 styler.ColourTo(endPos, SCE_ERR_DEFAULT);
496 }
497 }
498 }
499
500 static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
501 char lineBuffer[1024];
502 styler.StartAt(startPos);
503 styler.StartSegment(startPos);
504 unsigned int linePos = 0;
505 for (unsigned int i = startPos; i < startPos + length; i++) {
506 lineBuffer[linePos++] = styler[i];
507 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
508 // End of line (or of line buffer) met, colourise it
509 lineBuffer[linePos] = '\0';
510 ColouriseErrorListLine(lineBuffer, linePos, i, styler);
511 linePos = 0;
512 }
513 }
514 if (linePos > 0) { // Last line does not have ending characters
515 ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
516 }
517 }
518
519 static int isSpecial(char s) {
520 return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
521 (s == '\"') || (s == '`') || (s == '^') || (s == '~');
522 }
523
524 static int isTag(int start, Accessor &styler) {
525 char s[6];
526 unsigned int i = 0, e = 1;
527 while (i < 5 && e) {
528 s[i] = styler[start + i];
529 i++;
530 e = styler[start + i] != '{';
531 }
532 s[i] = '\0';
533 return (strcmp(s, "begin") == 0) || (strcmp(s, "end") == 0);
534 }
535
536 static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
537 WordList *[], Accessor &styler) {
538
539 styler.StartAt(startPos);
540
541 int state = initStyle;
542 char chNext = styler[startPos];
543 styler.StartSegment(startPos);
544 int lengthDoc = startPos + length;
545
546 for (int i = startPos; i < lengthDoc; i++) {
547 char ch = chNext;
548 chNext = styler.SafeGetCharAt(i + 1);
549
550 if (styler.IsLeadByte(ch)) {
551 chNext = styler.SafeGetCharAt(i + 2);
552 i++;
553 continue;
554 }
555 switch (state) {
556 case SCE_L_DEFAULT :
557 switch (ch) {
558 case '\\' :
559 styler.ColourTo(i - 1, state);
560 if (isSpecial(styler[i + 1])) {
561 styler.ColourTo(i + 1, SCE_L_COMMAND);
562 i++;
563 chNext = styler.SafeGetCharAt(i + 1);
564 } else {
565 if (isTag(i + 1, styler))
566 state = SCE_L_TAG;
567 else
568 state = SCE_L_COMMAND;
569 }
570 break;
571 case '$' :
572 styler.ColourTo(i - 1, state);
573 state = SCE_L_MATH;
574 if (chNext == '$') {
575 i++;
576 chNext = styler.SafeGetCharAt(i + 1);
577 }
578 break;
579 case '%' :
580 styler.ColourTo(i - 1, state);
581 state = SCE_L_COMMENT;
582 break;
583 }
584 break;
585 case SCE_L_COMMAND :
586 if (chNext == '[' || chNext == '{' || chNext == '}' ||
587 chNext == ' ' || chNext == '\r' || chNext == '\n') {
588 styler.ColourTo(i, state);
589 state = SCE_L_DEFAULT;
590 i++;
591 chNext = styler.SafeGetCharAt(i + 1);
592 }
593 break;
594 case SCE_L_TAG :
595 if (ch == '}') {
596 styler.ColourTo(i, state);
597 state = SCE_L_DEFAULT;
598 }
599 break;
600 case SCE_L_MATH :
601 if (ch == '$') {
602 if (chNext == '$') {
603 i++;
604 chNext = styler.SafeGetCharAt(i + 1);
605 }
606 styler.ColourTo(i, state);
607 state = SCE_L_DEFAULT;
608 }
609 break;
610 case SCE_L_COMMENT :
611 if (ch == '\r' || ch == '\n') {
612 styler.ColourTo(i - 1, state);
613 state = SCE_L_DEFAULT;
614 }
615 }
616 }
617 styler.ColourTo(lengthDoc-1, state);
618 }
619
620 static const char * const batchWordListDesc[] = {
621 "Keywords",
622 0
623 };
624
625 static const char * const emptyWordListDesc[] = {
626 0
627 };
628
629 LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
630 LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", 0, emptyWordListDesc);
631 LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", 0, emptyWordListDesc);
632 LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
633 LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
634 LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc);