Compared files  

Left
C:\SDK\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\LexLua.cxx
Last modified2005-03-21 12:17:54.000 +0100
Size9.6 Kb (330 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
C:\SDK\wxWidgets-2.6.3\contrib\src\stc\scintilla\src\LexLua.cxx
Last modified2006-03-16 13:07:08.000 +0100
Size10.3 Kb (353 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged22267
Inserted218
Deleted11
Ignored00
Changed18130



   Comparison Details  

11 skipped lines
12 12 #include <ctype.h>
13 13 #include <stdarg.h>
14 14 #include <stdio.h>
15 #include <fcntl.h>  
16 15  
17 16 #include "Platform.h"
18 17  
4 skipped lines
23 22 #include "Scintilla.h"
24 23 #include "SciLexer.h"
25 24  
  25 // Extended to accept accented characters
26 static inline bool IsAWordChar(const int ch) { 26 static inline bool IsAWordChar(int ch) {
  27     return ch >= 0x80 ||
27     return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); 28            (isalnum(ch) || ch == '.' || ch == '_');
28 29 }
29 30  
30 static inline bool IsAWordStart(const int ch) { 31 static inline bool IsAWordStart(int ch) {
  32     return ch >= 0x80 ||
31     return (ch < 0x80) && (isalnum(ch) || ch == '_'); 33            (isalpha(ch) || ch == '_');
32 34 }
33 35  
34 static inline bool IsANumberChar(const int ch) { 36 static inline bool IsANumberChar(int ch) {
35 37     // Not exactly following number definition (several dots are seen as OK, etc.)
36 38     // but probably enough in most cases.
37 39     return (ch < 0x80) &&
17 skipped lines
55 57     return false;
56 58 }
57 59  
  60 // Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ],
  61 // return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on.
  62 // The maximum number of '=' characters allowed is 254.
  63 static int LongDelimCheck(StyleContext &sc) {
  64     int sep = 1;
2 skipped lines
  67     if (sc.GetRelative(sep) == sc.ch)
  68         return sep;
  69     return 0;
  70 }
  71  
58 72 static void ColouriseLuaDoc(
59 73     unsigned int startPos,
60 74     int length,
11 skipped lines
72 86     WordList &keywords8 = *keywordlists[7];
73 87  
74 88     int currentLine = styler.GetLine(startPos);
75     // Initialize the literal string [[ ... ]] nesting level, if we are inside such a string. 89     // Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level,
76     int literalStringLevel = 0; 90     // if we are inside such a string. Block comment was introduced in Lua 5.0,
77     if (initStyle == SCE_LUA_LITERALSTRING) {  
78         literalStringLevel = styler.GetLineState(currentLine - 1);  
79     }  
80     // Initialize the block comment --[[ ... ]nesting level, if we are inside such a comment 91     // blocks with separators [=[ ... ]=] in Lua 5.1.
  92     int nestLevel = 0;
81     int blockCommentLevel = 0; 93     int sepCount = 0;
82     if (initStyle == SCE_LUA_COMMENT) { 94     if (initStyle == SCE_LUA_LITERALSTRING || initStyle == SCE_LUA_COMMENT) {
83         blockCommentLevel = styler.GetLineState(currentLine - 1); 95         int lineState = styler.GetLineState(currentLine - 1);
  96         nestLevel = lineState >> 8;
  97         sepCount = lineState & 0xFF;
84 98     }
85 99  
86 100     // Do not leak onto next line
87     if (initStyle == SCE_LUA_STRINGEOL) { 101     if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) {
88 102         initStyle = SCE_LUA_DEFAULT;
89 103     }
90 104  
8 skipped lines
99 113         currentLine = styler.GetLine(sc.currentPos);
100 114         switch (sc.state) {
101 115         case SCE_LUA_LITERALSTRING:
102         // Inside a literal string, we set the line state  
103         styler.SetLineState(currentLine, literalStringLevel);  
104         break;  
105         case SCE_LUA_COMMENT:   // Block comment 116         case SCE_LUA_COMMENT:
106         // Inside a block comment, we set the line state 117         // Inside a literal string oblock comment, we set the line state
107         styler.SetLineState(currentLine, blockCommentLevel); 118         styler.SetLineState(currentLine, (nestLevel << 8) | sepCount);
108 119         break;
109 120         default:
110 121         // Reset the line state
51 skipped lines
162 173         }
163 174         sc.SetState(SCE_LUA_DEFAULT);
164 175         }
165         } else if (sc.state == SCE_LUA_COMMENTLINE ) { 176         } else if (sc.state == SCE_LUA_COMMENTLINE || sc.state == SCE_LUA_PREPROCESSOR) {
166 177         if (sc.atLineEnd) {
167         sc.SetState(SCE_LUA_DEFAULT);  
168         }  
169         } else if (sc.state == SCE_LUA_PREPROCESSOR ) {  
170         if (sc.atLineEnd) {  
171         sc.SetState(SCE_LUA_DEFAULT); 178         sc.ForwardSetState(SCE_LUA_DEFAULT);
172 179         }
173 180         } else if (sc.state == SCE_LUA_STRING) {
174 181         if (sc.ch == '\\') {
17 skipped lines
192 199         sc.ChangeState(SCE_LUA_STRINGEOL);
193 200         sc.ForwardSetState(SCE_LUA_DEFAULT);
194 201         }
195         } else if (sc.state == SCE_LUA_LITERALSTRING) { 202         } else if (sc.state == SCE_LUA_LITERALSTRING || sc.state == SCE_LUA_COMMENT) {
196         if (sc.Match('[', '[')) {  
197         literalStringLevel++;  
198         sc.Forward();  
199         sc.SetState(SCE_LUA_LITERALSTRING);  
200         } else if (sc.Match(']', ']') && literalStringLevel > 0) { 203         if (sc.ch == '[') {
201         literalStringLevel--;  
202         sc.Forward(); 204         int sep = LongDelimCheck(sc);
203         if (literalStringLevel == 0) { 205         if (sep == 1 && sepCount == 1) {    // [[-only allowed to nest
  206         nestLevel++;
204         sc.ForwardSetState(SCE_LUA_DEFAULT); 207         sc.Forward();
205 208         }
206         }  
207         } else if (sc.state == SCE_LUA_COMMENT) { // Lua 5.0's block comment 209         } else if (sc.ch == ']') {
  210         int sep = LongDelimCheck(sc);
208         if (sc.Match('[', '[')) { 211         if (sep == 1 && sepCount == 1) {    // un-nest with ]]-only
209         blockCommentLevel++; 212         nestLevel--;
210         sc.Forward(); 213         sc.Forward();
211         } else if (sc.Match(']', ']') && blockCommentLevel > 0) { 214         if (nestLevel == 0) {
212         blockCommentLevel--;  
213         sc.Forward(); 215         sc.ForwardSetState(SCE_LUA_DEFAULT);
  216         }
214         if (blockCommentLevel == 0) { 217         } else if (sep > 1 && sep == sepCount) {   // ]=]-style delim
  218         sc.Forward(sep);
215 219         sc.ForwardSetState(SCE_LUA_DEFAULT);
216 220         }
217 221         }
5 skipped lines
223 227         sc.SetState(SCE_LUA_NUMBER);
224 228         } else if (IsAWordStart(sc.ch)) {
225 229         sc.SetState(SCE_LUA_IDENTIFIER);
226         } else if (sc.Match('\"')) { 230         } else if (sc.ch == '\"') {
227 231         sc.SetState(SCE_LUA_STRING);
228         } else if (sc.Match('\'')) { 232         } else if (sc.ch == '\'') {
229 233         sc.SetState(SCE_LUA_CHARACTER);
230         } else if (sc.Match('[', '[')) { 234         } else if (sc.ch == '[') {
231         literalStringLevel = 1; 235         sepCount = LongDelimCheck(sc);
  236         if (sepCount == 0) {
232         sc.SetState(SCE_LUA_LITERALSTRING); 237         sc.SetState(SCE_LUA_OPERATOR);
233         sc.Forward();  
234         } else if (sc.Match("--[[")) {  // Lua 5.0's block comment 238         } else {
235         blockCommentLevel = 1; 239         nestLevel = 1;
236         sc.SetState(SCE_LUA_COMMENT); 240         sc.SetState(SCE_LUA_LITERALSTRING);
237         sc.Forward(3); 241         sc.Forward(sepCount);
  242         }
238 243         } else if (sc.Match('-', '-')) {
239 244         sc.SetState(SCE_LUA_COMMENTLINE);
  245         if (sc.Match("--[")) {
  246         sc.Forward(2);
  247         sepCount = LongDelimCheck(sc);
  248         if (sepCount > 0) {
  249         nestLevel = 1;
  250         sc.ChangeState(SCE_LUA_COMMENT);
240         sc.Forward(); 251         sc.Forward(sepCount);
  252         }
  253         } else {
  254         sc.Forward();
  255         }
241 256         } else if (sc.atLineStart && sc.Match('$')) {
242 257         sc.SetState(SCE_LUA_PREPROCESSOR);  // Obsolete since Lua 4.0, but still in old code
243 258         } else if (IsLuaOperator(static_cast<char>(sc.ch))) {
23 skipped lines
267 282         styleNext = styler.StyleAt(i + 1);
268 283         bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
269 284         if (style == SCE_LUA_WORD) {
270         if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e') { 285         if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e' || ch == 'r' || ch == 'u') {
271 286         for (unsigned int j = 0; j < 8; j++) {
272 287         if (!iswordchar(styler[i + j])) {
273 288         break;
2 skipped lines
276 291         s[j + 1] = '\0';
277 292         }
278 293  
279         if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0) || (strcmp(s, "function") == 0)) { 294         if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0) || (strcmp(s, "function") == 0) || (strcmp(s, "repeat") == 0)) {
280 295         levelCurrent++;
281 296         }
282         if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0)) { 297         if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0) || (strcmp(s, "until")