Compared files  

Left
C:\SDK\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\LexCPP.cxx
Last modified2005-03-21 12:17:54.000 +0100
Size12.2 Kb (406 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
C:\SDK\wxWidgets-2.6.3\contrib\src\stc\scintilla\src\LexCPP.cxx
Last modified2006-03-16 13:07:06.001 +0100
Size13.8 Kb (463 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged31267
Inserted6105
Deleted310
Ignored00
Changed21220



   Comparison Details  

1 1 // Scintilla source code edit control
2 2 /** @file LexCPP.cxx
3  ** Lexer for C++, C, Java, and Javascript. 3  ** Lexer for C++, C, Java, and JavaScript.
4 4  **/
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org> 5 // Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
6 6 // The License.txt file describes the conditions under which this software may be distributed.
7 7  
8 8 #include <stdlib.h>
14 skipped lines
23 23 #define KEYWORD_BOXHEADER 1
24 24 #define KEYWORD_FOLDCONTRACTED 2
25 25  
26 static bool IsOKBeforeRE(const int ch) { 26 static bool IsOKBeforeRE(int ch) {
27 27     return (ch == '(') || (ch == '=') || (ch == ',');
28 28 }
29 29  
30 static inline bool IsAWordChar(const int ch) { 30 static inline bool IsAWordChar(int ch) {
31 31     return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
32 32 }
33 33  
34 static inline bool IsAWordStart(const int ch) { 34 static inline bool IsAWordStart(int ch) {
35     return (ch < 0x80) && (isalnum(ch) || ch == '_'); 35     return (ch < 0x80) && (isalpha(ch) || ch == '_');
36 36 }
37 37  
38 static inline bool IsADoxygenChar(const int ch) { 38 static inline bool IsADoxygenChar(int ch) {
39     return (islower(ch) || ch == '$' || ch == '@' || 39     return (ch < 0x80 && islower(ch)) || ch == '$' || ch == '@' ||
40             ch == '\\' || ch == '&' || ch == '<' || 40         ch == '\\' || ch == '&' || ch == '<' ||
41             ch == '>' || ch == '#' || ch == '{' || 41         ch == '>' || ch == '#' || ch == '{' ||
42             ch == '}' || ch == '[' || ch == ']'); 42         ch == '}' || ch == '[' || ch == ']';
43 43 }
44 44  
45 static inline bool IsStateComment(const int state) { 45 static bool IsSpaceEquiv(int state) {
46     return ((state == SCE_C_COMMENT) || 46     return (state <= SCE_C_COMMENTDOC) ||
47             (state == SCE_C_COMMENTLINE) ||  
48             (state == SCE_C_COMMENTDOC) ||  
49             (state == SCE_C_COMMENTDOCKEYWORD) || 47         // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
50             (state == SCE_C_COMMENTDOCKEYWORDERROR)); 48         (state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) ||
51 }  
52    
53 static inline bool IsStateString(const int state) {  
54     return ((state == SCE_C_STRING) || (state == SCE_C_VERBATIM)); 49         (state == SCE_C_COMMENTDOCKEYWORDERROR);
55 50 }
56 51  
57 52 static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
6 skipped lines
64 59  
65 60     bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
66 61  
67     // Do not leak onto next line  
68     if (initStyle == SCE_C_STRINGEOL)  
69         initStyle = SCE_C_DEFAULT;  
70    
71 62     int chPrevNonWhite = ' ';
72 63     int visibleChars = 0;
73 64     bool lastWordWasUUID = false;
  65     int styleBeforeDCKeyword = SCE_C_DEFAULT;
  66     bool continuationLine = false;
  67  
  68     if (initStyle == SCE_C_PREPROCESSOR) {
  69         // Set continuationLine if last character of previous line is '\'
18 skipped lines
  88         ;
  89         if (styler.StyleAt(back) == SCE_C_OPERATOR) {
  90         chPrevNonWhite = styler.SafeGetCharAt(back);
  91         }
  92     }
74 93  
75 94     StyleContext sc(startPos, length, initStyle, styler);
76 95  
77 96     for (; sc.More(); sc.Forward()) {
78 97  
  98         if (sc.atLineStart) {
79         if (sc.atLineStart && (sc.state == SCE_C_STRING)) { 99         if (sc.state == SCE_C_STRING) {
80         // Prevent SCE_C_STRINGEOL from leaking back to previous line 100         // Prevent SCE_C_STRINGEOL from leaking back to previous line which 
  101         // ends with a line continuation by locking in the state upto this position.
81         sc.SetState(SCE_C_STRING); 102         sc.SetState(SCE_C_STRING);
  103         }
  104         // Reset states to begining of colourise so no surprises
  105         // if different sets of lines lexed.
  106         visibleChars = 0;
  107         lastWordWasUUID = false;
82 108         }
83 109  
84 110         // Handle line continuation generically.
3 skipped lines
88 114         if (sc.ch == '\r' && sc.chNext == '\n') {
89 115         sc.Forward();
90 116         }
  117         continuationLine = true;
91 118         continue;
92 119         }
93 120         }
94 121  
95 122         // Determine if the current state should terminate.
96         if (sc.state == SCE_C_OPERATOR) { 123         switch (sc.state) {
97         sc.SetState(SCE_C_DEFAULT);  
98         } else if (sc.state == SCE_C_NUMBER) {  
99         if (!IsAWordChar(sc.ch)) {  
100         sc.SetState(SCE_C_DEFAULT); 124         case SCE_C_OPERATOR:
101         }  
102         } else if (sc.state == SCE_C_IDENTIFIER) {  
103         if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {  
104         char s[100];  
105         if (caseSensitive) {  
106         sc.GetCurrent(s, sizeof(s));  
107         } else {  
108         sc.GetCurrentLowered(s, sizeof(s));  
109         }  
110         if (keywords.InList(s)) {  
111         lastWordWasUUID = strcmp(s, "uuid") == 0;  
112         sc.ChangeState(SCE_C_WORD);  
113         } else if (keywords2.InList(s)) {  
114         sc.ChangeState(SCE_C_WORD2);  
115         } else if (keywords4.InList(s)) {  
116         sc.ChangeState(SCE_C_GLOBALCLASS);  
117         }  
118 125         sc.SetState(SCE_C_DEFAULT);
119         } 126         break;
120         } else if (sc.state == SCE_C_PREPROCESSOR) { 127         case SCE_C_NUMBER:
121         if (stylingWithinPreprocessor) { 128         // We accept almost anything because of hex. and number suffixes
122         if (IsASpace(sc.ch)) { 129         if (!IsAWordChar(sc.ch)) {
123 130         sc.SetState(SCE_C_DEFAULT);
124 131         }
125         } else { 132         break;
  133         case SCE_C_IDENTIFIER:
126         if ((sc.ch == '\r') || (sc.ch == '\n') || (sc.Match('/', '*')) || (sc.Match('/', '/'))) { 134         if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
  135         char s[1000];
  136         if (caseSensitive) {
  137         sc.GetCurrent(s, sizeof(s));
  138         } else {
  139         sc.GetCurrentLowered(s, sizeof(s));
  140         }
  141         if (keywords.InList(s)) {
  142         lastWordWasUUID = strcmp(s, "uuid") == 0;
  143         sc.ChangeState(SCE_C_WORD);
  144         } else if (keywords2.InList(s)) {
  145         sc.ChangeState(SCE_C_WORD2);
  146         } else if (keywords4.InList(s)) {
  147         sc.ChangeState(SCE_C_GLOBALCLASS);
  148         }
127 149         sc.SetState(SCE_C_DEFAULT);
128 150         }
129         } 151         break;
130         } else if (sc.state == SCE_C_COMMENT) {  
131         if (sc.Match('*', '/')) {  
132         sc.Forward();  
133         sc.ForwardSetState(SCE_C_DEFAULT);  
134         }  
135         } else if (sc.state == SCE_C_COMMENTDOC) { 152         case SCE_C_PREPROCESSOR:
136         if (sc.Match('*', '/')) {  
137         sc.Forward();  
138         sc.ForwardSetState(SCE_C_DEFAULT);  
139         } else if (sc.ch == '@' || sc.ch == '\\') { 153         if (sc.atLineStart && !continuationLine) {
140         sc.SetState(SCE_C_COMMENTDOCKEYWORD);  
141         }  
142         } else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {  
143         if (sc.ch == '\r' || sc.ch == '\n') {  
144         sc.SetState(SCE_C_DEFAULT); 154         sc.SetState(SCE_C_DEFAULT);
145         visibleChars = 0;  
146         }  
147         } else if (sc.state == SCE_C_COMMENTDOCKEYWORD) { 155         } else if (stylingWithinPreprocessor) {
148         if (sc.Match('*', '/')) { 156         if (IsASpace(sc.ch)) {
149         sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);  
150         sc.Forward();  
151         sc.ForwardSetState(SCE_C_DEFAULT); 157         sc.SetState(SCE_C_DEFAULT);
152         } else if (!IsADoxygenChar(sc.ch)) { 158         }
153         char s[100];  
154         if (caseSensitive) {  
155         sc.GetCurrent(s, sizeof(s));  
156 159         } else {
157         sc.GetCurrentLowered(s, sizeof(s));  
158         }  
159         if (!isspace(sc.ch) || !keywords3.InList(s + 1)) { 160         if (sc.Match('/', '*') || sc.Match('/', '/')) {
160         sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR); 161         sc.SetState(SCE_C_DEFAULT);
  162         }
161 163         }
162         sc.SetState(SCE_C_COMMENTDOC); 164         break;
163         }  
164         } else if (sc.state == SCE_C_STRING) { 165         case SCE_C_COMMENT:
165         if (sc.ch == '\\') {  
166         if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { 166         if (sc.Match('*', '/')) {
167 167         sc.Forward();
  168         sc.ForwardSetState(SCE_C_DEFAULT);
168 169         }
169         } else if (sc.ch == '\"') { 170         break;
170         sc.ForwardSetState(SCE_C_DEFAULT);  
171         }</