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  

1U1U// Scintilla source code edit control
2U2U/** @file LexClw.cxx
3U3U ** Lexer for Clarion.
  4A ** 2004/12/17 Updated Lexer
4U5U **/
5C// Copyright 2003 by Ron Schofield <ron@schofieldcomputer.com> 6C// Copyright 2003-2004 by Ron Schofield <ron@schofieldcomputer.com>
6U7U// The License.txt file describes the conditions under which this software may be distributed.
7U8U 
8U9U#include <stdlib.h>
9U10U#include <string.h>
10R#include <ctype.h>  
11U11U#include <stdio.h>
12U12U#include <stdarg.h>
  13A#include <ctype.h>
13U14U 
14U15U#include "Platform.h"
15U16U 
4 skipped lines
20U21U#include "Scintilla.h"
21U22U#include "SciLexer.h"
22U23U 
  24C// Is an end of line character
  25Cinline bool IsEOL(const int ch) {
  26C 
  27C    return(ch == '\n');
  28C}
  29C 
  30C// Convert character to uppercase
23Cstatic char MakeUpperCase(char ch) { 31Cstatic char CharacterUpper(char chChar) {
  32C 
24C    if (ch < 'a' || ch > 'z') 33C    if (chChar < 'a' || chChar > 'z') {
25C        return ch; 34C        return(chChar);
  35C    }
26C    else 36C    else {
27C        return static_cast<char>(ch - 'a' + 'A'); 37C        return(static_cast<char>(chChar - 'a' + 'A'));
  38C    }
28U39U}
29U40U 
  41C// Convert string to uppercase
30Cstatic void MakeUpperCaseString(char *s) { 42Cstatic void StringUpper(char *szString) {
  43C 
31C    while (*s) { 44C    while (*szString) {
32C        *s = MakeUpperCase(*s); 45C        *szString = CharacterUpper(*szString);
33C        s++; 46C        szString++;
34U47U    }
35U48U}
36U49U 
37U50U// Is a label start character
38U51Uinline bool IsALabelStart(const int iChar) {
  52A 
39U53U    return(isalpha(iChar) || iChar == '_');
40U54U}
41U55U 
42U56U// Is a label character
43U57Uinline bool IsALabelCharacter(const int iChar) {
  58C 
44C    return(isalnum(iChar) || iChar == '_' || iChar == ':'); 59C    return(isalnum(iChar) || iChar == '_' || iChar == ':'); 
45U60U}
46U61U 
47C// Is the character is a ! and the the next character is not a ! 62C// Is the character is a ! and the the next character is not a ! 
48Cinline bool IsACommentStart(StyleContext &scDoc) { 63Cinline bool IsACommentStart(const int iChar) {
  64C 
49C    return(scDoc.ch == '!' && scDoc.chNext != '!'); 65C    return(iChar == '!');
50U66U}
51U67U 
52U68U// Is the character a Clarion hex character (ABCDEF)
53U69Uinline bool IsAHexCharacter(const int iChar, bool bCaseSensitive) {
  70A 
54U71U    // Case insensitive.
55U72U    if (!bCaseSensitive) {
56U73U        if (strchr("ABCDEFabcdef", iChar) != NULL) {
11 skipped lines
68U85U 
69U86U// Is the character a Clarion base character (B=Binary, O=Octal, H=Hex)
70U87Uinline bool IsANumericBaseCharacter(const int iChar, bool bCaseSensitive) {
  88A 
71U89U    // Case insensitive.
72U90U    if (!bCaseSensitive) {
73U91U        // If character is a numeric base character
13 skipped lines
87U105U 
88U106U// Set the correct numeric constant state
89U107Uinline bool SetNumericConstantState(StyleContext &scDoc) {
  108A 
90U109U    int iPoints = 0;// Point counter
91C    char cNumericString[100]; // Numeric string buffer 110C    char cNumericString[512]; // Numeric string buffer
92U111U 
93U112U    // Buffer the current numberic string
94U113U    scDoc.GetCurrent(cNumericString, sizeof(cNumericString));
8 skipped lines
103U122U        break;
104U123U        default :
105U124U        break;
106C        } 125C        } 
107U126U    }
108U127U    // If points found (can be more than one for improper formatted number
109U128U    if (iPoints > 0) {
5 skipped lines
115U134U    }
116U135U}
117U136U 
  137A// Get the next word in uppercase from the current position (keyword lookahead)
  138Ainline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLength, char *cWord) {
  139A 
  140A    unsigned int iIndex = 0;// Buffer Index
  141A 
22 skipped lines
  164A        // Return success
  165A        return(true);
  166A    }
  167A}
  168A 
118U169U// Clarion Language Colouring Procedure
119Cstatic void ColouriseClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { 170Cstatic void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) {
  171C 
  172C    int iParenthesesLevel = 0;  // Parenthese Level
  173C    int iColumn1Label = false;  // Label starts in Column 1
  174C 
  175C    WordList &wlClarionKeywords = *wlKeywords[0];   // Clarion Keywords
  176C    WordList &wlCompilerDirectives = *wlKeywords[1];// Compiler Directives
  177C    WordList &wlRuntimeExpressions = *wlKeywords[2];// Runtime Expressions
  178C    WordList &wlBuiltInProcsFuncs = *wlKeywords[3];     // Builtin Procedures and Functions
  179C    WordList &wlStructsDataTypes = *wlKeywords[4];  // Structures and Data Types
  180C    WordList &wlAttributes = *wlKeywords[5];// Procedure Attributes
  181C    WordList &wlStandardEquates = *wlKeywords[6];   // Standard Equates
  182C    WordList &wlLabelReservedWords = *wlKeywords[7];// Clarion Reserved Keywords (Labels)
  183C    WordList &wlProcLabelReservedWords = *wlKeywords[8];// Clarion Reserved Keywords (Procedure Labels)
120U184U 
121C    int iParenthesesLevel=0;// Parenthese Level 185C    const char wlProcReservedKeywordList[] = 
  186C    "PROCEDURE FUNCTION";
  187C    WordList wlProcReservedKeywords;
  188C    wlProcReservedKeywords.Set(wlProcReservedKeywordList);
122U189U 
123C    WordList &wlClarionKeywords = *wlKeywords[0];   // Clarion Keywords 190C    const char wlCompilerKeywordList[] = 
124C    WordList &wlCompilerDirectives = *wlKeywords[1];// Compiler Directives 191C    "COMPILE OMIT";
125C    WordList &wlBuiltInProcsFuncs = *wlKeywords[2];     // Builtin Procedures and Functions 192C    WordList wlCompilerKeywords;
126C    WordList &wlStructsDataTypes = *wlKeywords[3];  // Structures and Data Types 193C    wlCompilerKeywords.Set(wlCompilerKeywordList);
127C    WordList &wlAttributes = *wlKeywords[4];// Procedure Attributes 194C 
128C    WordList &wlStandardEquates = *wlKeywords[5];   // Standard Equates 195C    const char wlLegacyStatementsList[] =
  196C    "BOF EOF FUNCTION POINTER SHARE";
129C    WordList &wlReservedWords = *wlKeywords[6];     // Clarion Reserved Keywords 197C    WordList wlLegacyStatements;
  198C    wlLegacyStatements.Set(wlLegacyStatementsList);
130U199U 
131U200U    StyleContext scDoc(uiStartPos, iLength, iInitStyle, accStyler);
132U201U 
10 skipped lines
143U212U        if (!IsALabelCharacter(scDoc.ch)) {
144U213U        // If the character is a . (dot syntax)
145U214U        if (scDoc.ch == '.') {
  215A        // Turn off column 1 label flag as label now cannot be reserved work
  216A        iColumn1Label = false;
146U217U        // Uncolour the . (dot) to default state, move forward one character,
147U218U        // and change back to the label state.
148U219U        scDoc.SetState(SCE_CLW_DEFAULT);
149U220U        scDoc.Forward();
150U221U        scDoc.SetState(SCE_CLW_LABEL);
151U222U        }
152C        // Else terminate the label state 223C        // Else check label
153U224U        else {
154C        char cLabel[100];   // Label buffer 225C        char cLabel[512];   // Label buffer
155U226U        // Buffer the current label string
156U227U        scDoc.GetCurrent(cLabel,sizeof(cLabel));
157U228U        // If case insensitive, convert string to UPPERCASE to match passed keywords.
158U229U        if (!bCaseSensitive) {
159C        MakeUpperCaseString(cLabel); 230C        StringUpper(cLabel);
160U231U        }
  232C        // Else if UPPERCASE label string is in the Clarion compiler keyword list
  233C        if (wlCompilerKeywords.InList(cLabel) && iColumn1Label){
  234C        // change the label to error state
  235C        scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
  236C        }
161C        // If label string is in the Clarion reserved keyword list 237C        // Else if UPPERCASE label string is in the Clarion reserved keyword list
162C        if (wlReservedWords.InList(cLabel)){ 238C        else if (wlLabelReservedWords.InList(cLabel) && iColumn1Label){
163C        // change to error state 239C        // change the label to error state
164U240U        scDoc.ChangeState(SCE_CLW_ERROR);
165U241U        }
  242A        // Else if UPPERCASE label string is 
  243A        else if (wlProcLabelReservedWords.InList(cLabel) && iColumn1Label) {
  244A        char cWord[512];// Word buffer
  245A        // Get the next word from the current position
  246A        if (GetNextWordUpper(accStyler,scDoc.currentPos,uiStartPos+iLength,cWord)) {
2 skipped lines
  249A        // Change the label to error state
  250A        scDoc.ChangeState(SCE_CLW_ERROR);
  251A        }
  252A        }
  253A        }
166U254U        // Else if label string is in the compiler directive keyword list
167U255U        else if (wlCompilerDirectives.InList(cLabel)) {
168U256U        // change the state to compiler directive state
8 skipped lines
177U265U        else if (scDoc.state == SCE_CLW_KEYWORD) {
178U266U        // If character is : (colon)
179U267U        if (scDoc.ch == ':') {
180C        char cEquate[100];  // Equate buffer 268C        char cEquate[512];  // Equate buffer
181U269U        // Move forward to include : (colon) in buffer
182U270U        scDoc.Forward();
183U271U        // Buffer the equate string
184U272U        scDoc.GetCurrent(cEquate,sizeof(cEquate));
185U273U        // If case insensitive, convert string to UPPERCASE to match passed keywords.
186U274U        if (!bCaseSensitive) {
187C        MakeUpperCaseString(cEquate); 275C        StringUpper(cEquate);
188U276U        }
189U277U        // If statement string is in the equate list
190U278U        if (wlStandardEquates.InList(cEquate)) {
3 skipped lines
194U282U        }
195U283U        // If the character is not a valid label character
196U284U        else if (!IsALabelCharacter(scDoc.ch)) {
197C        char cStatement[100];   // Statement buffer 285C        char cStatement[512];   // Statement buffer
198U286U        // Buffer the statement string
199U287U        scDoc.GetCurrent(cStatement,sizeof(cStatement));
200U288U        // If case insensitive, convert string to UPPERCASE to match passed keywords.
201U289U        if (!bCaseSensitive) {
202C        MakeUpperCaseString(cStatement); 290C        StringUpper(cStatement);
203U291U        }
204U292U        // If statement string is in the Clarion keyword list
205U293U        if (wlClarionKeywords.InList(cStatement)) {
206C        // Set to the Clarion keyword state 294C        // Change the statement string to the Clarion keyword state
207U295U        scDoc.ChangeState(SCE_CLW_KEYWORD);
208U296U        }
209U297U        // Else if statement string is in the compiler directive keyword list
210U298U        else if (wlCompilerDirectives.InList(cStatement)) {
211C        // Set to the compiler directive state 299C        // Change the statement string to the compiler directive state
212U300U        scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE);
213U301U        }
  302A        // Else if statement string is in the runtime expressions keyword list
  303A        else if (wlRuntimeExpressions.InList(cStatement)) {
  304A        // Change the statement string to the runtime expressions state
  305A        scDoc.ChangeState(SCE_CLW_RUNTIME_EXPRESSIONS);
  306A        }
214U307U        // Else if statement string is in the builtin procedures and functions keyword list
215U308U        else if (wlBuiltInProcsFuncs.InList(cStatement)) {
216C        // Set to the builtin procedures and functions state 309C        // Change the statement string to the builtin procedures and functions state
217U310U        scDoc.ChangeState(SCE_CLW_BUILTIN_PROCEDURES_FUNCTION);
218U311U        }
219U312U        // Else if statement string is in the tructures and data types keyword list
220U313U        else if (wlStructsDataTypes.InList(cStatement)) {
221C        // Set to the structures and data types state 314C        // Change the statement string to the structures and data types state
222U315U        scDoc.ChangeState(SCE_CLW_STRUCTURE_DATA_TYPE);
223U316U        }
224U317U        // Else if statement string is in the procedure attribute keyword list
225U318U        else if (wlAttributes.InList(cStatement)) {
226C        // Set to the procedure attribute state 319C        // Change the statement string to the procedure attribute state
227U320U        scDoc.ChangeState(SCE_CLW_ATTRIBUTE);
228U321U        }
229U322U        // Else if statement string is in the standard equate keyword list
230U323U        else if (wlStandardEquates.InList(cStatement)) {
231C        // Set to the standard equate state 324C        // Change the statement string to the standard equate state
232U325U        scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE);
233U326U        }
  327A        // Else if statement string is in the deprecated or legacy keyword list
  328A        else if (wlLegacyStatements.InList(cStatement)) {
  329A        // Change the statement string to the standard equate state
  330A        scDoc.ChangeState(SCE_CLW_DEPRECATED);
  331A        }
  332A        // Else the statement string doesn't match any work list
  333A        else {
  334A        // Change the statement string to the default state
  335A        scDoc.ChangeState(SCE_CLW_DEFAULT);
  336A        }
234U337U        // Terminate the keyword state and set to default state
235U338U        scDoc.SetState(SCE_CLW_DEFAULT);
236U339U        }
24 skipped lines
261U364U        // Increment the parenthese level
262U365U        iParenthesesLevel++;
263U366U        }
264C        // Else if the character is a ) (close parenthese) 367C        // Else if the character is a ) (close parenthese) 
265U368U        else if (scDoc.ch == ')') {
266U369U        // If the parenthese level is set to zero
267U370U        // parentheses matched
268U371U        if (!iParenthesesLevel) {
269U372U        scDoc.SetState(SCE_CLW_DEFAULT);
270C        } 373C        } 
271U374U        // Else parenthese level is greater than zero
272U375U        // still looking for matching parentheses
273U376U        else {
18 skipped lines
292U395U        || IsAHexCharacter(scDoc.ch, bCaseSensitive)
293U396U        || scDoc.ch == '.'
294U397U        || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) {
295C        // If the number was a real 398C        // If the number was a real 
296U399U        if (SetNumericConstantState(scDoc)) {
297U400U        // Colour the matched string to the real constant state
298U401U        scDoc.ChangeState(SCE_CLW_REAL_CONSTANT);
14 skipped lines
313U416U 
314U417U        // Beginning of Line Handling
315U418U        if (scDoc.atLineStart) {
  419A        // Reset the column 1 label flag
  420A        iColumn1Label = false;
316U421U        // If column 1 character is a label start character
317U422U        if (IsALabelStart(scDoc.ch)) {
  423A        // Label character is found in column 1
  424A        // so set column 1 label flag and clear last column 1 label
  425A        iColumn1Label = true;
318U426U        // Set the state to label
319U427U        scDoc.SetState(SCE_CLW_LABEL);
320U428U        }
2 skipped lines
323U431U        // Set to default state
324U432U        scDoc.SetState(SCE_CLW_DEFAULT);
325U433U        }
326C        // else if the start of a comment or is an * (asterisk) 434C        // else if comment start (!) or is an * (asterisk)
327C        else if (IsACommentStart(scDoc) || scDoc.ch == '*' ) { 435C        else if (IsACommentStart(scDoc.ch) || scDoc.ch == '*' ) {
328U436U        // then set the state to comment.
329U437U        scDoc.SetState(SCE_CLW_COMMENT);
330U438U        }
18 skipped lines
349U457U        }
350U458U        // Default Handling
351U459U        else {
352C        // If in default state 460C        // If in default state