Compared files  

Left
C:\SDK\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\LexCLW.cxx
Last modified2004-02-06 01:02:50.000 +0100
Size13.8 Kb (442 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
C:\SDK\wxWidgets-2.6.3\contrib\src\stc\scintilla\src\LexCLW.cxx
Last modified2006-03-16 13:07:06.001 +0100
Size21.4 Kb (676 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged58378
Inserted1577
Deleted22
Ignored00
Changed40283



   Comparison Details  

1 1 // Scintilla source code edit control
2 2 /** @file LexClw.cxx
3 3  ** Lexer for Clarion.
  4  ** 2004/12/17 Updated Lexer
4 5  **/
5 // Copyright 2003 by Ron Schofield <ron@schofieldcomputer.com> 6 // Copyright 2003-2004 by Ron Schofield <ron@schofieldcomputer.com>
6 7 // The License.txt file describes the conditions under which this software may be distributed.
7 8  
8 9 #include <stdlib.h>
9 10 #include <string.h>
10 #include <ctype.h>  
11 11 #include <stdio.h>
12 12 #include <stdarg.h>
  13 #include <ctype.h>
13 14  
14 15 #include "Platform.h"
15 16  
4 skipped lines
20 21 #include "Scintilla.h"
21 22 #include "SciLexer.h"
22 23  
  24 // Is an end of line character
  25 inline bool IsEOL(const int ch) {
  26  
  27     return(ch == '\n');
  28 }
  29  
  30 // Convert character to uppercase
23 static char MakeUpperCase(char ch) { 31 static char CharacterUpper(char chChar) {
  32  
24     if (ch < 'a' || ch > 'z') 33     if (chChar < 'a' || chChar > 'z') {
25         return ch; 34         return(chChar);
  35     }
26     else 36     else {
27         return static_cast<char>(ch - 'a' + 'A'); 37         return(static_cast<char>(chChar - 'a' + 'A'));
  38     }
28 39 }
29 40  
  41 // Convert string to uppercase
30 static void MakeUpperCaseString(char *s) { 42 static void StringUpper(char *szString) {
  43  
31     while (*s) { 44     while (*szString) {
32         *s = MakeUpperCase(*s); 45         *szString = CharacterUpper(*szString);
33         s++; 46         szString++;
34 47     }
35 48 }
36 49  
37 50 // Is a label start character
38 51 inline bool IsALabelStart(const int iChar) {
  52  
39 53     return(isalpha(iChar) || iChar == '_');
40 54 }
41 55  
42 56 // Is a label character
43 57 inline bool IsALabelCharacter(const int iChar) {
  58  
44     return(isalnum(iChar) || iChar == '_' || iChar == ':'); 59     return(isalnum(iChar) || iChar == '_' || iChar == ':'); 
45 60 }
46 61  
47 // Is the character is a ! and the the next character is not a ! 62 // Is the character is a ! and the the next character is not a ! 
48 inline bool IsACommentStart(StyleContext &scDoc) { 63 inline bool IsACommentStart(const int iChar) {
  64  
49     return(scDoc.ch == '!' && scDoc.chNext != '!'); 65     return(iChar == '!');
50 66 }
51 67  
52 68 // Is the character a Clarion hex character (ABCDEF)
53 69 inline bool IsAHexCharacter(const int iChar, bool bCaseSensitive) {
  70  
54 71     // Case insensitive.
55 72     if (!bCaseSensitive) {
56 73         if (strchr("ABCDEFabcdef", iChar) != NULL) {
11 skipped lines
68 85  
69 86 // Is the character a Clarion base character (B=Binary, O=Octal, H=Hex)
70 87 inline bool IsANumericBaseCharacter(const int iChar, bool bCaseSensitive) {
  88  
71 89     // Case insensitive.
72 90     if (!bCaseSensitive) {
73 91         // If character is a numeric base character
13 skipped lines
87 105  
88 106 // Set the correct numeric constant state
89 107 inline bool SetNumericConstantState(StyleContext &scDoc) {
  108  
90 109     int iPoints = 0;// Point counter
91     char cNumericString[100]; // Numeric string buffer 110     char cNumericString[512]; // Numeric string buffer
92 111  
93 112     // Buffer the current numberic string
94 113     scDoc.GetCurrent(cNumericString, sizeof(cNumericString));
8 skipped lines
103 122         break;
104 123         default :
105 124         break;
106         } 125         } 
107 126     }
108 127     // If points found (can be more than one for improper formatted number
109 128     if (iPoints > 0) {
5 skipped lines
115 134     }
116 135 }
117 136  
  137 // Get the next word in uppercase from the current position (keyword lookahead)
  138 inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLength, char *cWord) {
  139  
  140     unsigned int iIndex = 0;// Buffer Index
  141  
22 skipped lines
  164         // Return success
  165         return(true);
  166     }
  167 }
  168  
118 169 // Clarion Language Colouring Procedure
119 static void ColouriseClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { 170 static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) {
  171  
  172     int iParenthesesLevel = 0;  // Parenthese Level
  173     int iColumn1Label = false;  // Label starts in Column 1
  174  
  175     WordList &wlClarionKeywords = *wlKeywords[0];   // Clarion Keywords
  176     WordList &wlCompilerDirectives = *wlKeywords[1];// Compiler Directives
  177     WordList &wlRuntimeExpressions = *wlKeywords[2];// Runtime Expressions
  178     WordList &wlBuiltInProcsFuncs = *wlKeywords[3];     // Builtin Procedures and Functions
  179     WordList &wlStructsDataTypes = *wlKeywords[4];  // Structures and Data Types
  180     WordList &wlAttributes = *wlKeywords[5];// Procedure Attributes
  181     WordList &wlStandardEquates = *wlKeywords[6];   // Standard Equates
  182     WordList &wlLabelReservedWords = *wlKeywords[7];// Clarion Reserved Keywords (Labels)
  183     WordList &wlProcLabelReservedWords = *wlKeywords[8];// Clarion Reserved Keywords (Procedure Labels)
120 184  
121     int iParenthesesLevel=0;// Parenthese Level 185     const char wlProcReservedKeywordList[] = 
  186     "PROCEDURE FUNCTION";
  187     WordList wlProcReservedKeywords;
  188     wlProcReservedKeywords.Set(wlProcReservedKeywordList);
122 189  
123     WordList &wlClarionKeywords = *wlKeywords[0];   // Clarion Keywords 190     const char wlCompilerKeywordList[] = 
124     WordList &wlCompilerDirectives = *wlKeywords[1];// Compiler Directives 191     "COMPILE OMIT";
125     WordList &wlBuiltInProcsFuncs = *wlKeywords[2];     // Builtin Procedures and Functions 192     WordList wlCompilerKeywords;
126     WordList &wlStructsDataTypes = *wlKeywords[3];  // Structures and Data Types 193     wlCompilerKeywords.Set(wlCompilerKeywordList);
127     WordList &wlAttributes = *wlKeywords[4];// Procedure Attributes 194  
128     WordList &wlStandardEquates = *wlKeywords[5];   // Standard Equates 195     const char wlLegacyStatementsList[] =
  196     "BOF EOF FUNCTION POINTER SHARE";
129     WordList &wlReservedWords = *wlKeywords[6];     // Clarion Reserved Keywords 197     WordList wlLegacyStatements;
  198     wlLegacyStatements.Set(wlLegacyStatementsList);
130 199  
131 200     StyleContext scDoc(uiStartPos, iLength, iInitStyle, accStyler);
132 201  
10 skipped lines
143 212         if (!IsALabelCharacter(scDoc.ch)) {
144 213         // If the character is a . (dot syntax)
145 214         if (scDoc.ch == '.') {
  215         // Turn off column 1 label flag as label now cannot be reserved work
  216         iColumn1Label = false;
146 217         // Uncolour the . (dot) to default state, move forward one character,
147 218         // and change back to the label state.
148 219         scDoc.SetState(SCE_CLW_DEFAULT);
149 220         scDoc.Forward();
150 221         scDoc.SetState(SCE_CLW_LABEL);
151 222         }
152         // Else terminate the label state 223         // Else check label
153 224         else {
154         char cLabel[100];   // Label buffer 225         char cLabel[512];   // Label buffer
155 226         // Buffer the current label string
156 227         scDoc.GetCurrent(cLabel,sizeof(cLabel));
157 228         // If case insensitive, convert string to UPPERCASE to match passed keywords.
158 229         if (!bCaseSensitive) {
159         MakeUpperCaseString(cLabel); 230         StringUpper(cLabel);
160 231         }
  232         // Else if UPPERCASE label string is in the Clarion compiler keyword list
  233         if (wlCompilerKeywords.InList(cLabel) && iColumn1Label){
  234         // change the label to error state
  235         scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
  236         }
161         // If label string is in the Clarion reserved keyword list 237         // Else if UPPERCASE label string is in the Clarion reserved keyword list
162         if (wlReservedWords.InList(cLabel)){ 238         else if (wlLabelReservedWords.InList(cLabel) && iColumn1Label){
163         // change to error state 239         // change the label to error state
164 240         scDoc.ChangeState(SCE_CLW_ERROR);
165 241         }
  242         // Else if UPPERCASE label string is 
  243         else if (wlProcLabelReservedWords.InList(cLabel) && iColumn1Label) {
  244         char cWord[512];// Word buffer
  245         // Get the next word from the current position
  246         if (GetNextWordUpper(accStyler,scDoc.currentPos,uiStartPos+iLength,cWord)) {
2 skipped lines
  249         // Change the label to error state
  250         scDoc.ChangeState(SCE_CLW_ERROR);
  251         }
  252         }
  253         }
166 254         // Else if label string is in the compiler directive keyword list
167 255         else if (wlCompilerDirectives.InList(cLabel)) {
168 256         // change the state to compiler directive state
8 skipped lines
177 265         else if (scDoc.state == SCE_CLW_KEYWORD) {
178 266         // If character is : (colon)
179 267         if (scDoc.ch == ':') {
180         char cEquate[100];  // Equate buffer 268         char cEquate[512];  // Equate buffer
181 269         // Move forward to include : (colon) in buffer
182 270         scDoc.Forward();
183 271         // Buffer the equate string
184 272         scDoc.GetCurrent(cEquate,sizeof(cEquate));
185 273         // If case insensitive, convert string to UPPERCASE to match passed keywords.
186 274         if (!bCaseSensitive) {
187         MakeUpperCaseString(cEquate); 275         StringUpper(cEquate);
188 276         }
189 277         // If statement string is in the equate list
190 278         if (wlStandardEquates.InList(cEquate)) {
3 skipped lines
194 282         }
195 283         // If the character is not a valid label character
196 284         else if (!IsALabelCharacter(scDoc.ch)) {
197         char cStatement[100];   // Statement buffer 285         char cStatement[512];   // Statement buffer
198 286         // Buffer the statement string
199 287         scDoc.GetCurrent(cStatement,sizeof(cStatement));
200 288         // If case insensitive, convert string to UPPERCASE to match passed keywords.
201 289         if (!bCaseSensitive) {
202         MakeUpperCaseString(cStatement); 290         StringUpper(cStatement);
203 291         }
204 292         // If statement string is in the Clarion keyword list
205 293         if (wlClarionKeywords.InList(cStatement)) {
206         // Set to the Clarion keyword state 294         // Change the statement string to the Clarion keyword state
207 295         scDoc.ChangeState(SCE_CLW_KEYWORD);
208 296         }
209 297         // Else if statement string is in the compiler directive keyword list
210 298         else if (wlCompilerDirectives.InList(cStatement)) {
211         // Set to the compiler directive state 299         // Change the statement string to the compiler directive state
212 300         scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
213 301         }
  302         // Else if statement string is in the runtime expressions keyword list
  303         else if (wlRuntimeExpressions.InList(cStatement)) {
  304         // Change the statement string to the runtime expressions state
  305         scDoc.ChangeState(SCE_CLW_RUNTIME_EXPRESSIONS);
  306         }
214 307         // Else if statement string is in the builtin procedures and functions keyword list
215 308         else if (wlBuiltInProcsFuncs.InList(cStatement)) {
216         // Set to the builtin procedures and functions state 309         // Change the statement string to the builtin procedures and functions state
217 310         scDoc.ChangeState(SCE_CLW_BUILTIN_PROCEDURES_FUNCTION);
218 311         }
219 312         // Else if statement string is in the tructures and data types keyword list
220 313         else if (wlStructsDataTypes.InList(cStatement)) {
221         // Set to the structures and data types state 314         // Change the statement string to the structures and data types state
222 315         scDoc.ChangeState(SCE_CLW_STRUCTURE_DATA_TYPE);
223 316         }
224 317         // Else if statement string is in the procedure attribute keyword list
225 318         else if (wlAttributes.InList(cStatement)) {
226         // Set to the procedure attribute state 319         // Change the statement string to the procedure attribute state
227 320         scDoc.ChangeState(SCE_CLW_ATTRIBUTE);
228 321         }
229 322         // Else if statement string is in the standard equate keyword list
230 323         else if (wlStandardEquates.InList(cStatement)) {
231         // Set to the standard equate state 324         // Change the statement string to the standard equate state
232 325         scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE);
233 326         }
  327         // Else if statement string is in the deprecated or legacy keyword list
  328         else if (wlLegacyStatements.InList(cStatement)) {
  329         // Change the statement string to the standard equate state
  330         scDoc.ChangeState(SCE_CLW_DEPRECATED);
  331         }
  332         // Else the statement string doesn't match any work list
  333         else {
  334         // Change the statement string to the default state
  335         scDoc.ChangeState(SCE_CLW_DEFAULT);
  336         }
234 337         // Terminate the keyword state and set to default state
235 338         scDoc.SetState(SCE_CLW_DEFAULT);
236 339         }
24 skipped lines
261 364         // Increment the parenthese level
262 365         iParenthesesLevel++;
263 366         }
264         // Else if the character is a ) (close parenthese) 367         // Else if the character is a ) (close parenthese) 
265 368         else if (scDoc.ch == ')') {
266 369         // If the parenthese level is set to zero
267 370         // parentheses matched
268 371         if (!iParenthesesLevel) {
269 372         scDoc.SetState(SCE_CLW_DEFAULT);
270         } 373         } 
271 374         // Else parenthese level is greater than zero
272 375         // still looking for matching parentheses
273 376         else {
18 skipped lines
292 395         || IsAHexCharacter(scDoc.ch, bCaseSensitive)
293 396         || scDoc.ch == '.'
294 397         || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) {
295         // If the number was a real 398         // If the number was a real 
296 399         if (SetNumericConstantState(scDoc)) {
297 400         // Colour the matched string to the real constant state
298 401         scDoc.ChangeState(SCE_CLW_REAL_CONSTANT);
14 skipped lines
313 416  
314 417         // Beginning of Line Handling
315 418         if (scDoc.atLineStart) {
  419         // Reset the column 1 label flag
  420         iColumn1Label = false;
316 421         // If column 1 character is a label start character
317 422         if (IsALabelStart(scDoc.ch)) {
  423         // Label character is found in column 1
  424         // so set column 1 label flag and clear last column 1 label
  425         iColumn1Label = true;
318 426         // Set the state to label
319 427         scDoc.SetState(SCE_CLW_LABEL);
320 428         }
2 skipped lines
323 431         // Set to default state
324 432         scDoc.SetState(SCE_CLW_DEFAULT);
325 433         }
326         // else if the start of a comment or is an * (asterisk) 434         // else if comment start (!) or is an * (asterisk)
327         else if (IsACommentStart(scDoc) || scDoc.ch == '*' ) { 435         else if (IsACommentStart(scDoc.ch) || scDoc.ch == '*' ) {
328 436         // then set the state to comment.
329 437         scDoc.SetState(SCE_CLW_COMMENT);
330 438         }
18 skipped lines
349 457         }
350 458         // Default Handling
351 459         else {
352         // If in default state 460         // If in default state 
353 461         if (scDoc.state == SCE_CLW_DEFAULT) {
354 462         // If is a letter could be a possible statement
355 463         if (isalpha(scDoc.ch)) {
6 skipped lines
362 470         scDoc.SetState(SCE_CLW_INTEGER_CONSTANT);
363 471         }
364 472         // else if the start of a comment or a | (line continuation)
365         else if (IsACommentStart(scDoc) || scDoc.ch == '|') { 473         else if (IsACommentStart(scDoc.ch) || scDoc.ch == '|') {
366 474         // then set the state to comment.
367 475         scDoc.SetState(SCE_CLW_COMMENT);
368         } 476         }   
369 477         // else if the character is a ' (single quote)
370 478         else if (scDoc.ch == '\'') {
371         // If the character is also a ' (single quote) 479         // If the character is also a ' (single quote) 
372 480         // Embedded Apostrophe
373 481         if (scDoc.chNext == '\'') {
374 482         // Move forward colouring it as default state
3 skipped lines
378 486         // move to the next character and then set the state to comment.
379 487         scDoc.ForwardSetState(SCE_CLW_STRING);
380 488         }
381         } 489         }   
382         // else the character is an @ (apersand) 490         // else the character is an @ (ampersand)
383 491         else if (scDoc.ch == '@') {
384 492         // Case insensitive.
385 493         if (!bCaseSensitive) {
11 skipped lines
397 505         scDoc.SetState(SCE_CLW_PICTURE_STRING);
398 506         }
399 507         }
400         } 508         }   
401 509         }
402 510         }
403 511     }
2 skipped lines
406 514 }
407 515  
408 516 // Clarion Language Case Sensitive Colouring Procedure
409 static void ColouriseClwDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { 517 static void ColouriseClarionDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) {
  518  
410     ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true); 519     ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true);
411 520 }
412 521  
413 522 // Clarion Language Case Insensitive Colouring Procedure
414 static void ColouriseClwDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { 523 static void ColouriseClarionDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) {
  524  
415     ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false); 525     ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false);
  526 }
  527  
  528 // Fill Buffer
  529  
  530 static void FillBuffer(unsigned int uiStart, unsigned int uiEnd, Accessor &accStyler, char *szBuffer, unsigned int uiLength) {
  531  
  532     unsigned int uiPos = 0;
  533  
  534     while ((uiPos < uiEnd - uiStart + 1) && (uiPos < uiLength-1)) {
  535         szBuffer[uiPos] = static_cast<char>(toupper(accStyler[uiStart + uiPos]));
46 skipped lines
  582         strcmp(szString, "WINDOW") == 0) {
  583         iLevel++;
  584         }
  585         else if (strcmp(szString, "END") == 0 ||
  586         strcmp(szString, "UNTIL") == 0 ||
  587         strcmp(szString, "WHILE") == 0) {
  588         iLevel--;
  589         }
  590     }
  591     return(iLevel);
416 592 }
417 593  
418 594 // Clarion Language Folding Procedure
419 #ifdef FOLDING_IMPLEMENTED  
420 static void FoldClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { 595 static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *[], Accessor &accStyler) {
  596  
  597     unsigned int uiEndPos = uiStartPos + iLength;
  598     int iLineCurrent = accStyler.GetLine(uiStartPos);
  599     int iLevelPrev = accStyler.LevelAt(iLineCurrent) & SC_FOLDLEVELNUMBERMASK;
  600     int iLevelCurrent = iLevelPrev;
  601     char chNext = accStyler[uiStartPos];
  602     int iStyle = iInitStyle;
  603     int iStyleNext = accStyler.StyleAt(uiStartPos);
  604     int iVisibleChars = 0;
  605     int iLastStart = 0;
34 skipped lines
  640         accStyler.SetLevel(iLineCurrent,iLevel);
  641         }
  642         iLineCurrent++;
  643         iLevelPrev = iLevelCurrent;
  644         iVisibleChars = 0;
  645         }
  646          
  647         if (!isspacechar(chChar))
  648         iVisibleChars++;
  649     }
421 650  
  651     // Fill in the real level of the next line, keeping the current flags
  652     // as they will be filled in later.
  653     int iFlagsNext = accStyler.LevelAt(iLineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
  654     accStyler.SetLevel(iLineCurrent, iLevelPrev | iFlagsNext);
422 655 }
423 #endif  
424 656  
425 657 // Word List Descriptions
426 658 static const char * const rgWordListDescriptions[] = {
427 659     "Clarion Keywords",
428 660     "Compiler Directives",
429 661     "Built-in Procedures and Functions",
  662     "Runtime Expressions",
430 663     "Structure and Data Types",
431 664     "Attributes",
432 665     "Standard Equates",
433     "Reserved Words", 666     "Reserved Words (Labels)",
  667     "Reserved Words (Procedure Labels)",
434 668     0,
435 669 };
436 670  
437 671 // Case Sensitive Clarion Language Lexer
438 LexerModule lmClw(SCLEX_CLW, ColouriseClwDocSensitive, "clw", NULL, rgWordListDescriptions); 672 LexerModule lmClw(SCLEX_CLW, ColouriseClarionDocSensitive, "clarion", FoldClarionDoc, rgWordListDescriptions);
439 673  
440 674 // Case Insensitive Clarion Language Lexer
441 LexerModule lmClwNoCase(SCLEX_CLWNOCASE, ColouriseClwDocInsensitive, "clwnocase", NULL, rgWordListDescriptions); 675 LexerModule lmClwNoCase(SCLEX_CLWNOCASE, ColouriseClarionDocInsensitive, "clarionnocase", FoldClarionDoc, rgWordListDescriptions);
442 676  

   Text comparison Options  

Syntax colouring language used: C / C++
Match character case: yes.
Match line endings: no.
Match spaces

At start of lines: yes,
In middle of lines: yes,
At end of lines: yes.
Blank lines as empty lines: no.
Activate comparison algorithm
At word level: yes,
At character level: no.


   Legend  

Unchanged lineExample of unchanged line
Modified lineExample of modified line
Added lineExample of added line
Removed lineExample of removed line
Ignored lineExample of ignored line

This report has been generated by Ellié Computing Merge on 2006-09-07 15:48:20.001 +0200.
© 2005-2006 Ellié Computing http://www.elliecomputing.com. All rights reserved.