]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/LexCLW.cxx
Interface fixes for Phoenix
[wxWidgets.git] / src / stc / scintilla / src / LexCLW.cxx
1 // Scintilla source code edit control
2 /** @file LexClw.cxx
3 ** Lexer for Clarion.
4 ** 2004/12/17 Updated Lexer
5 **/
6 // Copyright 2003-2004 by Ron Schofield <ron@schofieldcomputer.com>
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 <stdio.h>
12 #include <stdarg.h>
13 #include <ctype.h>
14
15 #include "Platform.h"
16
17 #include "PropSet.h"
18 #include "Accessor.h"
19 #include "StyleContext.h"
20 #include "KeyWords.h"
21 #include "Scintilla.h"
22 #include "SciLexer.h"
23
24 #ifdef SCI_NAMESPACE
25 using namespace Scintilla;
26 #endif
27
28 // Is an end of line character
29 inline bool IsEOL(const int ch) {
30
31 return(ch == '\n');
32 }
33
34 // Convert character to uppercase
35 static char CharacterUpper(char chChar) {
36
37 if (chChar < 'a' || chChar > 'z') {
38 return(chChar);
39 }
40 else {
41 return(static_cast<char>(chChar - 'a' + 'A'));
42 }
43 }
44
45 // Convert string to uppercase
46 static void StringUpper(char *szString) {
47
48 while (*szString) {
49 *szString = CharacterUpper(*szString);
50 szString++;
51 }
52 }
53
54 // Is a label start character
55 inline bool IsALabelStart(const int iChar) {
56
57 return(isalpha(iChar) || iChar == '_');
58 }
59
60 // Is a label character
61 inline bool IsALabelCharacter(const int iChar) {
62
63 return(isalnum(iChar) || iChar == '_' || iChar == ':');
64 }
65
66 // Is the character is a ! and the the next character is not a !
67 inline bool IsACommentStart(const int iChar) {
68
69 return(iChar == '!');
70 }
71
72 // Is the character a Clarion hex character (ABCDEF)
73 inline bool IsAHexCharacter(const int iChar, bool bCaseSensitive) {
74
75 // Case insensitive.
76 if (!bCaseSensitive) {
77 if (strchr("ABCDEFabcdef", iChar) != NULL) {
78 return(true);
79 }
80 }
81 // Case sensitive
82 else {
83 if (strchr("ABCDEF", iChar) != NULL) {
84 return(true);
85 }
86 }
87 return(false);
88 }
89
90 // Is the character a Clarion base character (B=Binary, O=Octal, H=Hex)
91 inline bool IsANumericBaseCharacter(const int iChar, bool bCaseSensitive) {
92
93 // Case insensitive.
94 if (!bCaseSensitive) {
95 // If character is a numeric base character
96 if (strchr("BOHboh", iChar) != NULL) {
97 return(true);
98 }
99 }
100 // Case sensitive
101 else {
102 // If character is a numeric base character
103 if (strchr("BOH", iChar) != NULL) {
104 return(true);
105 }
106 }
107 return(false);
108 }
109
110 // Set the correct numeric constant state
111 inline bool SetNumericConstantState(StyleContext &scDoc) {
112
113 int iPoints = 0; // Point counter
114 char cNumericString[512]; // Numeric string buffer
115
116 // Buffer the current numberic string
117 scDoc.GetCurrent(cNumericString, sizeof(cNumericString));
118 // Loop through the string until end of string (NULL termination)
119 for (int iIndex = 0; cNumericString[iIndex] != '\0'; iIndex++) {
120 // Depending on the character
121 switch (cNumericString[iIndex]) {
122 // Is a . (point)
123 case '.' :
124 // Increment point counter
125 iPoints++;
126 break;
127 default :
128 break;
129 }
130 }
131 // If points found (can be more than one for improper formatted number
132 if (iPoints > 0) {
133 return(true);
134 }
135 // Else no points found
136 else {
137 return(false);
138 }
139 }
140
141 // Get the next word in uppercase from the current position (keyword lookahead)
142 inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLength, char *cWord) {
143
144 unsigned int iIndex = 0; // Buffer Index
145
146 // Loop through the remaining string from the current position
147 for (int iOffset = uiStartPos; iOffset < iLength; iOffset++) {
148 // Get the character from the buffer using the offset
149 char cCharacter = styler[iOffset];
150 if (IsEOL(cCharacter)) {
151 break;
152 }
153 // If the character is alphabet character
154 if (isalpha(cCharacter)) {
155 // Add UPPERCASE character to the word buffer
156 cWord[iIndex++] = CharacterUpper(cCharacter);
157 }
158 }
159 // Add null termination
160 cWord[iIndex] = '\0';
161 // If no word was found
162 if (iIndex == 0) {
163 // Return failure
164 return(false);
165 }
166 // Else word was found
167 else {
168 // Return success
169 return(true);
170 }
171 }
172
173 // Clarion Language Colouring Procedure
174 static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) {
175
176 int iParenthesesLevel = 0; // Parenthese Level
177 int iColumn1Label = false; // Label starts in Column 1
178
179 WordList &wlClarionKeywords = *wlKeywords[0]; // Clarion Keywords
180 WordList &wlCompilerDirectives = *wlKeywords[1]; // Compiler Directives
181 WordList &wlRuntimeExpressions = *wlKeywords[2]; // Runtime Expressions
182 WordList &wlBuiltInProcsFuncs = *wlKeywords[3]; // Builtin Procedures and Functions
183 WordList &wlStructsDataTypes = *wlKeywords[4]; // Structures and Data Types
184 WordList &wlAttributes = *wlKeywords[5]; // Procedure Attributes
185 WordList &wlStandardEquates = *wlKeywords[6]; // Standard Equates
186 WordList &wlLabelReservedWords = *wlKeywords[7]; // Clarion Reserved Keywords (Labels)
187 WordList &wlProcLabelReservedWords = *wlKeywords[8]; // Clarion Reserved Keywords (Procedure Labels)
188
189 const char wlProcReservedKeywordList[] =
190 "PROCEDURE FUNCTION";
191 WordList wlProcReservedKeywords;
192 wlProcReservedKeywords.Set(wlProcReservedKeywordList);
193
194 const char wlCompilerKeywordList[] =
195 "COMPILE OMIT";
196 WordList wlCompilerKeywords;
197 wlCompilerKeywords.Set(wlCompilerKeywordList);
198
199 const char wlLegacyStatementsList[] =
200 "BOF EOF FUNCTION POINTER SHARE";
201 WordList wlLegacyStatements;
202 wlLegacyStatements.Set(wlLegacyStatementsList);
203
204 StyleContext scDoc(uiStartPos, iLength, iInitStyle, accStyler);
205
206 // lex source code
207 for (; scDoc.More(); scDoc.Forward())
208 {
209 //
210 // Determine if the current state should terminate.
211 //
212
213 // Label State Handling
214 if (scDoc.state == SCE_CLW_LABEL) {
215 // If the character is not a valid label
216 if (!IsALabelCharacter(scDoc.ch)) {
217 // If the character is a . (dot syntax)
218 if (scDoc.ch == '.') {
219 // Turn off column 1 label flag as label now cannot be reserved work
220 iColumn1Label = false;
221 // Uncolour the . (dot) to default state, move forward one character,
222 // and change back to the label state.
223 scDoc.SetState(SCE_CLW_DEFAULT);
224 scDoc.Forward();
225 scDoc.SetState(SCE_CLW_LABEL);
226 }
227 // Else check label
228 else {
229 char cLabel[512]; // Label buffer
230 // Buffer the current label string
231 scDoc.GetCurrent(cLabel,sizeof(cLabel));
232 // If case insensitive, convert string to UPPERCASE to match passed keywords.
233 if (!bCaseSensitive) {
234 StringUpper(cLabel);
235 }
236 // Else if UPPERCASE label string is in the Clarion compiler keyword list
237 if (wlCompilerKeywords.InList(cLabel) && iColumn1Label){
238 // change the label to error state
239 scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
240 }
241 // Else if UPPERCASE label string is in the Clarion reserved keyword list
242 else if (wlLabelReservedWords.InList(cLabel) && iColumn1Label){
243 // change the label to error state
244 scDoc.ChangeState(SCE_CLW_ERROR);
245 }
246 // Else if UPPERCASE label string is
247 else if (wlProcLabelReservedWords.InList(cLabel) && iColumn1Label) {
248 char cWord[512]; // Word buffer
249 // Get the next word from the current position
250 if (GetNextWordUpper(accStyler,scDoc.currentPos,uiStartPos+iLength,cWord)) {
251 // If the next word is a procedure reserved word
252 if (wlProcReservedKeywords.InList(cWord)) {
253 // Change the label to error state
254 scDoc.ChangeState(SCE_CLW_ERROR);
255 }
256 }
257 }
258 // Else if label string is in the compiler directive keyword list
259 else if (wlCompilerDirectives.InList(cLabel)) {
260 // change the state to compiler directive state
261 scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
262 }
263 // Terminate the label state and set to default state
264 scDoc.SetState(SCE_CLW_DEFAULT);
265 }
266 }
267 }
268 // Keyword State Handling
269 else if (scDoc.state == SCE_CLW_KEYWORD) {
270 // If character is : (colon)
271 if (scDoc.ch == ':') {
272 char cEquate[512]; // Equate buffer
273 // Move forward to include : (colon) in buffer
274 scDoc.Forward();
275 // Buffer the equate string
276 scDoc.GetCurrent(cEquate,sizeof(cEquate));
277 // If case insensitive, convert string to UPPERCASE to match passed keywords.
278 if (!bCaseSensitive) {
279 StringUpper(cEquate);
280 }
281 // If statement string is in the equate list
282 if (wlStandardEquates.InList(cEquate)) {
283 // Change to equate state
284 scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE);
285 }
286 }
287 // If the character is not a valid label character
288 else if (!IsALabelCharacter(scDoc.ch)) {
289 char cStatement[512]; // Statement buffer
290 // Buffer the statement string
291 scDoc.GetCurrent(cStatement,sizeof(cStatement));
292 // If case insensitive, convert string to UPPERCASE to match passed keywords.
293 if (!bCaseSensitive) {
294 StringUpper(cStatement);
295 }
296 // If statement string is in the Clarion keyword list
297 if (wlClarionKeywords.InList(cStatement)) {
298 // Change the statement string to the Clarion keyword state
299 scDoc.ChangeState(SCE_CLW_KEYWORD);
300 }
301 // Else if statement string is in the compiler directive keyword list
302 else if (wlCompilerDirectives.InList(cStatement)) {
303 // Change the statement string to the compiler directive state
304 scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
305 }
306 // Else if statement string is in the runtime expressions keyword list
307 else if (wlRuntimeExpressions.InList(cStatement)) {
308 // Change the statement string to the runtime expressions state
309 scDoc.ChangeState(SCE_CLW_RUNTIME_EXPRESSIONS);
310 }
311 // Else if statement string is in the builtin procedures and functions keyword list
312 else if (wlBuiltInProcsFuncs.InList(cStatement)) {
313 // Change the statement string to the builtin procedures and functions state
314 scDoc.ChangeState(SCE_CLW_BUILTIN_PROCEDURES_FUNCTION);
315 }
316 // Else if statement string is in the tructures and data types keyword list
317 else if (wlStructsDataTypes.InList(cStatement)) {
318 // Change the statement string to the structures and data types state
319 scDoc.ChangeState(SCE_CLW_STRUCTURE_DATA_TYPE);
320 }
321 // Else if statement string is in the procedure attribute keyword list
322 else if (wlAttributes.InList(cStatement)) {
323 // Change the statement string to the procedure attribute state
324 scDoc.ChangeState(SCE_CLW_ATTRIBUTE);
325 }
326 // Else if statement string is in the standard equate keyword list
327 else if (wlStandardEquates.InList(cStatement)) {
328 // Change the statement string to the standard equate state
329 scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE);
330 }
331 // Else if statement string is in the deprecated or legacy keyword list
332 else if (wlLegacyStatements.InList(cStatement)) {
333 // Change the statement string to the standard equate state
334 scDoc.ChangeState(SCE_CLW_DEPRECATED);
335 }
336 // Else the statement string doesn't match any work list
337 else {
338 // Change the statement string to the default state
339 scDoc.ChangeState(SCE_CLW_DEFAULT);
340 }
341 // Terminate the keyword state and set to default state
342 scDoc.SetState(SCE_CLW_DEFAULT);
343 }
344 }
345 // String State Handling
346 else if (scDoc.state == SCE_CLW_STRING) {
347 // If the character is an ' (single quote)
348 if (scDoc.ch == '\'') {
349 // Set the state to default and move forward colouring
350 // the ' (single quote) as default state
351 // terminating the string state
352 scDoc.SetState(SCE_CLW_DEFAULT);
353 scDoc.Forward();
354 }
355 // If the next character is an ' (single quote)
356 if (scDoc.chNext == '\'') {
357 // Move forward one character and set to default state
358 // colouring the next ' (single quote) as default state
359 // terminating the string state
360 scDoc.ForwardSetState(SCE_CLW_DEFAULT);
361 scDoc.Forward();
362 }
363 }
364 // Picture String State Handling
365 else if (scDoc.state == SCE_CLW_PICTURE_STRING) {
366 // If the character is an ( (open parenthese)
367 if (scDoc.ch == '(') {
368 // Increment the parenthese level
369 iParenthesesLevel++;
370 }
371 // Else if the character is a ) (close parenthese)
372 else if (scDoc.ch == ')') {
373 // If the parenthese level is set to zero
374 // parentheses matched
375 if (!iParenthesesLevel) {
376 scDoc.SetState(SCE_CLW_DEFAULT);
377 }
378 // Else parenthese level is greater than zero
379 // still looking for matching parentheses
380 else {
381 // Decrement the parenthese level
382 iParenthesesLevel--;
383 }
384 }
385 }
386 // Standard Equate State Handling
387 else if (scDoc.state == SCE_CLW_STANDARD_EQUATE) {
388 if (!isalnum(scDoc.ch)) {
389 scDoc.SetState(SCE_CLW_DEFAULT);
390 }
391 }
392 // Integer Constant State Handling
393 else if (scDoc.state == SCE_CLW_INTEGER_CONSTANT) {
394 // If the character is not a digit (0-9)
395 // or character is not a hexidecimal character (A-F)
396 // or character is not a . (point)
397 // or character is not a numberic base character (B,O,H)
398 if (!(isdigit(scDoc.ch)
399 || IsAHexCharacter(scDoc.ch, bCaseSensitive)
400 || scDoc.ch == '.'
401 || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) {
402 // If the number was a real
403 if (SetNumericConstantState(scDoc)) {
404 // Colour the matched string to the real constant state
405 scDoc.ChangeState(SCE_CLW_REAL_CONSTANT);
406 }
407 // Else the number was an integer
408 else {
409 // Colour the matched string to an integer constant state
410 scDoc.ChangeState(SCE_CLW_INTEGER_CONSTANT);
411 }
412 // Terminate the integer constant state and set to default state
413 scDoc.SetState(SCE_CLW_DEFAULT);
414 }
415 }
416
417 //
418 // Determine if a new state should be entered.
419 //
420
421 // Beginning of Line Handling
422 if (scDoc.atLineStart) {
423 // Reset the column 1 label flag
424 iColumn1Label = false;
425 // If column 1 character is a label start character
426 if (IsALabelStart(scDoc.ch)) {
427 // Label character is found in column 1
428 // so set column 1 label flag and clear last column 1 label
429 iColumn1Label = true;
430 // Set the state to label
431 scDoc.SetState(SCE_CLW_LABEL);
432 }
433 // else if character is a space or tab
434 else if (IsASpace(scDoc.ch)){
435 // Set to default state
436 scDoc.SetState(SCE_CLW_DEFAULT);
437 }
438 // else if comment start (!) or is an * (asterisk)
439 else if (IsACommentStart(scDoc.ch) || scDoc.ch == '*' ) {
440 // then set the state to comment.
441 scDoc.SetState(SCE_CLW_COMMENT);
442 }
443 // else the character is a ? (question mark)
444 else if (scDoc.ch == '?') {
445 // Change to the compiler directive state, move forward,
446 // colouring the ? (question mark), change back to default state.
447 scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
448 scDoc.Forward();
449 scDoc.SetState(SCE_CLW_DEFAULT);
450 }
451 // else an invalid character in column 1
452 else {
453 // Set to error state
454 scDoc.SetState(SCE_CLW_ERROR);
455 }
456 }
457 // End of Line Handling
458 else if (scDoc.atLineEnd) {
459 // Reset to the default state at the end of each line.
460 scDoc.SetState(SCE_CLW_DEFAULT);
461 }
462 // Default Handling
463 else {
464 // If in default state
465 if (scDoc.state == SCE_CLW_DEFAULT) {
466 // If is a letter could be a possible statement
467 if (isalpha(scDoc.ch)) {
468 // Set the state to Clarion Keyword and verify later
469 scDoc.SetState(SCE_CLW_KEYWORD);
470 }
471 // else is a number
472 else if (isdigit(scDoc.ch)) {
473 // Set the state to Integer Constant and verify later
474 scDoc.SetState(SCE_CLW_INTEGER_CONSTANT);
475 }
476 // else if the start of a comment or a | (line continuation)
477 else if (IsACommentStart(scDoc.ch) || scDoc.ch == '|') {
478 // then set the state to comment.
479 scDoc.SetState(SCE_CLW_COMMENT);
480 }
481 // else if the character is a ' (single quote)
482 else if (scDoc.ch == '\'') {
483 // If the character is also a ' (single quote)
484 // Embedded Apostrophe
485 if (scDoc.chNext == '\'') {
486 // Move forward colouring it as default state
487 scDoc.ForwardSetState(SCE_CLW_DEFAULT);
488 }
489 else {
490 // move to the next character and then set the state to comment.
491 scDoc.ForwardSetState(SCE_CLW_STRING);
492 }
493 }
494 // else the character is an @ (ampersand)
495 else if (scDoc.ch == '@') {
496 // Case insensitive.
497 if (!bCaseSensitive) {
498 // If character is a valid picture token character
499 if (strchr("DEKNPSTdeknpst", scDoc.chNext) != NULL) {
500 // Set to the picture string state
501 scDoc.SetState(SCE_CLW_PICTURE_STRING);
502 }
503 }
504 // Case sensitive
505 else {
506 // If character is a valid picture token character
507 if (strchr("DEKNPST", scDoc.chNext) != NULL) {
508 // Set the picture string state
509 scDoc.SetState(SCE_CLW_PICTURE_STRING);
510 }
511 }
512 }
513 }
514 }
515 }
516 // lexing complete
517 scDoc.Complete();
518 }
519
520 // Clarion Language Case Sensitive Colouring Procedure
521 static void ColouriseClarionDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) {
522
523 ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true);
524 }
525
526 // Clarion Language Case Insensitive Colouring Procedure
527 static void ColouriseClarionDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) {
528
529 ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false);
530 }
531
532 // Fill Buffer
533
534 static void FillBuffer(unsigned int uiStart, unsigned int uiEnd, Accessor &accStyler, char *szBuffer, unsigned int uiLength) {
535
536 unsigned int uiPos = 0;
537
538 while ((uiPos < uiEnd - uiStart + 1) && (uiPos < uiLength-1)) {
539 szBuffer[uiPos] = static_cast<char>(toupper(accStyler[uiStart + uiPos]));
540 uiPos++;
541 }
542 szBuffer[uiPos] = '\0';
543 }
544
545 // Classify Clarion Fold Point
546
547 static int ClassifyClarionFoldPoint(int iLevel, const char* szString) {
548
549 if (!(isdigit(szString[0]) || (szString[0] == '.'))) {
550 if (strcmp(szString, "PROCEDURE") == 0) {
551 // iLevel = SC_FOLDLEVELBASE + 1;
552 }
553 else if (strcmp(szString, "MAP") == 0 ||
554 strcmp(szString,"ACCEPT") == 0 ||
555 strcmp(szString,"BEGIN") == 0 ||
556 strcmp(szString,"CASE") == 0 ||
557 strcmp(szString,"EXECUTE") == 0 ||
558 strcmp(szString,"IF") == 0 ||
559 strcmp(szString,"ITEMIZE") == 0 ||
560 strcmp(szString,"INTERFACE") == 0 ||
561 strcmp(szString,"JOIN") == 0 ||
562 strcmp(szString,"LOOP") == 0 ||
563 strcmp(szString,"MODULE") == 0 ||
564 strcmp(szString,"RECORD") == 0) {
565 iLevel++;
566 }
567 else if (strcmp(szString, "APPLICATION") == 0 ||
568 strcmp(szString, "CLASS") == 0 ||
569 strcmp(szString, "DETAIL") == 0 ||
570 strcmp(szString, "FILE") == 0 ||
571 strcmp(szString, "FOOTER") == 0 ||
572 strcmp(szString, "FORM") == 0 ||
573 strcmp(szString, "GROUP") == 0 ||
574 strcmp(szString, "HEADER") == 0 ||
575 strcmp(szString, "INTERFACE") == 0 ||
576 strcmp(szString, "MENU") == 0 ||
577 strcmp(szString, "MENUBAR") == 0 ||
578 strcmp(szString, "OLE") == 0 ||
579 strcmp(szString, "OPTION") == 0 ||
580 strcmp(szString, "QUEUE") == 0 ||
581 strcmp(szString, "REPORT") == 0 ||
582 strcmp(szString, "SHEET") == 0 ||
583 strcmp(szString, "TAB") == 0 ||
584 strcmp(szString, "TOOLBAR") == 0 ||
585 strcmp(szString, "VIEW") == 0 ||
586 strcmp(szString, "WINDOW") == 0) {
587 iLevel++;
588 }
589 else if (strcmp(szString, "END") == 0 ||
590 strcmp(szString, "UNTIL") == 0 ||
591 strcmp(szString, "WHILE") == 0) {
592 iLevel--;
593 }
594 }
595 return(iLevel);
596 }
597
598 // Clarion Language Folding Procedure
599 static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *[], Accessor &accStyler) {
600
601 unsigned int uiEndPos = uiStartPos + iLength;
602 int iLineCurrent = accStyler.GetLine(uiStartPos);
603 int iLevelPrev = accStyler.LevelAt(iLineCurrent) & SC_FOLDLEVELNUMBERMASK;
604 int iLevelCurrent = iLevelPrev;
605 char chNext = accStyler[uiStartPos];
606 int iStyle = iInitStyle;
607 int iStyleNext = accStyler.StyleAt(uiStartPos);
608 int iVisibleChars = 0;
609 int iLastStart = 0;
610
611 for (unsigned int uiPos = uiStartPos; uiPos < uiEndPos; uiPos++) {
612
613 char chChar = chNext;
614 chNext = accStyler.SafeGetCharAt(uiPos + 1);
615 int iStylePrev = iStyle;
616 iStyle = iStyleNext;
617 iStyleNext = accStyler.StyleAt(uiPos + 1);
618 bool bEOL = (chChar == '\r' && chNext != '\n') || (chChar == '\n');
619
620 if (iStylePrev == SCE_CLW_DEFAULT) {
621 if (iStyle == SCE_CLW_KEYWORD || iStyle == SCE_CLW_STRUCTURE_DATA_TYPE) {
622 // Store last word start point.
623 iLastStart = uiPos;
624 }
625 }
626
627 if (iStylePrev == SCE_CLW_KEYWORD || iStylePrev == SCE_CLW_STRUCTURE_DATA_TYPE) {
628 if(iswordchar(chChar) && !iswordchar(chNext)) {
629 char chBuffer[100];
630 FillBuffer(iLastStart, uiPos, accStyler, chBuffer, sizeof(chBuffer));
631 iLevelCurrent = ClassifyClarionFoldPoint(iLevelCurrent,chBuffer);
632 // if ((iLevelCurrent == SC_FOLDLEVELBASE + 1) && iLineCurrent > 1) {
633 // accStyler.SetLevel(iLineCurrent-1,SC_FOLDLEVELBASE);
634 // iLevelPrev = SC_FOLDLEVELBASE;
635 // }
636 }
637 }
638
639 if (bEOL) {
640 int iLevel = iLevelPrev;
641 if ((iLevelCurrent > iLevelPrev) && (iVisibleChars > 0))
642 iLevel |= SC_FOLDLEVELHEADERFLAG;
643 if (iLevel != accStyler.LevelAt(iLineCurrent)) {
644 accStyler.SetLevel(iLineCurrent,iLevel);
645 }
646 iLineCurrent++;
647 iLevelPrev = iLevelCurrent;
648 iVisibleChars = 0;
649 }
650
651 if (!isspacechar(chChar))
652 iVisibleChars++;
653 }
654
655 // Fill in the real level of the next line, keeping the current flags
656 // as they will be filled in later.
657 int iFlagsNext = accStyler.LevelAt(iLineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
658 accStyler.SetLevel(iLineCurrent, iLevelPrev | iFlagsNext);
659 }
660
661 // Word List Descriptions
662 static const char * const rgWordListDescriptions[] = {
663 "Clarion Keywords",
664 "Compiler Directives",
665 "Built-in Procedures and Functions",
666 "Runtime Expressions",
667 "Structure and Data Types",
668 "Attributes",
669 "Standard Equates",
670 "Reserved Words (Labels)",
671 "Reserved Words (Procedure Labels)",
672 0,
673 };
674
675 // Case Sensitive Clarion Language Lexer
676 LexerModule lmClw(SCLEX_CLW, ColouriseClarionDocSensitive, "clarion", FoldClarionDoc, rgWordListDescriptions);
677
678 // Case Insensitive Clarion Language Lexer
679 LexerModule lmClwNoCase(SCLEX_CLWNOCASE, ColouriseClarionDocInsensitive, "clarionnocase", FoldClarionDoc, rgWordListDescriptions);