~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/LexLua.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "KeyWords.h"
22
22
#include "Scintilla.h"
23
23
#include "SciLexer.h"
24
 
 
25
 
// Extended to accept accented characters
26
 
static inline bool IsAWordChar(int ch) {
27
 
        return ch >= 0x80 ||
28
 
               (isalnum(ch) || ch == '.' || ch == '_');
29
 
}
30
 
 
31
 
static inline bool IsAWordStart(int ch) {
32
 
        return ch >= 0x80 ||
33
 
               (isalpha(ch) || ch == '_');
34
 
}
35
 
 
36
 
static inline bool IsANumberChar(int ch) {
37
 
        // Not exactly following number definition (several dots are seen as OK, etc.)
38
 
        // but probably enough in most cases.
39
 
        return (ch < 0x80) &&
40
 
                (isdigit(ch) || toupper(ch) == 'E' ||
41
 
             ch == '.' || ch == '-' || ch == '+');
42
 
}
43
 
 
44
 
static inline bool IsLuaOperator(int ch) {
45
 
        if (ch >= 0x80 || isalnum(ch)) {
46
 
                return false;
47
 
        }
48
 
        // '.' left out as it is used to make up numbers
49
 
        if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
50
 
                ch == '(' || ch == ')' || ch == '=' ||
51
 
                ch == '{' || ch == '}' || ch == '~' ||
52
 
                ch == '[' || ch == ']' || ch == ';' ||
53
 
                ch == '<' || ch == '>' || ch == ',' ||
54
 
                ch == '.' || ch == '^' || ch == '%' || ch == ':') {
55
 
                return true;
56
 
        }
57
 
        return false;
58
 
}
 
24
#include "CharacterSet.h"
 
25
 
 
26
#ifdef SCI_NAMESPACE
 
27
using namespace Scintilla;
 
28
#endif
59
29
 
60
30
// Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ],
61
31
// return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on.
85
55
        WordList &keywords7 = *keywordlists[6];
86
56
        WordList &keywords8 = *keywordlists[7];
87
57
 
 
58
        // Accepts accented characters
 
59
        CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
 
60
        CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
 
61
        // Not exactly following number definition (several dots are seen as OK, etc.)
 
62
        // but probably enough in most cases.
 
63
        CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefABCDEF");
 
64
        CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#");
 
65
        CharacterSet setEscapeSkip(CharacterSet::setNone, "\"'\\");
 
66
 
88
67
        int currentLine = styler.GetLine(startPos);
89
68
        // Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level,
90
69
        // if we are inside such a string. Block comment was introduced in Lua 5.0,
130
109
 
131
110
                // Handle string line continuation
132
111
                if ((sc.state == SCE_LUA_STRING || sc.state == SCE_LUA_CHARACTER) &&
133
 
                        sc.ch == '\\') {
 
112
                                sc.ch == '\\') {
134
113
                        if (sc.chNext == '\n' || sc.chNext == '\r') {
135
114
                                sc.Forward();
136
115
                                if (sc.ch == '\r' && sc.chNext == '\n') {
144
123
                if (sc.state == SCE_LUA_OPERATOR) {
145
124
                        sc.SetState(SCE_LUA_DEFAULT);
146
125
                } else if (sc.state == SCE_LUA_NUMBER) {
147
 
                        // We stop the number definition on non-numerical non-dot non-eE non-sign char
148
 
                        if (!IsANumberChar(sc.ch)) {
 
126
                        // We stop the number definition on non-numerical non-dot non-eE non-sign non-hexdigit char
 
127
                        if (!setNumber.Contains(sc.ch)) {
149
128
                                sc.SetState(SCE_LUA_DEFAULT);
 
129
                        } else if (sc.ch == '-' || sc.ch == '+') {
 
130
                                if (sc.chPrev != 'E' && sc.chPrev != 'e')
 
131
                                        sc.SetState(SCE_LUA_DEFAULT);
150
132
                        }
151
133
                } else if (sc.state == SCE_LUA_IDENTIFIER) {
152
 
                        if (!IsAWordChar(sc.ch) || sc.Match('.', '.')) {
 
134
                        if (!setWord.Contains(sc.ch) || sc.Match('.', '.')) {
153
135
                                char s[100];
154
136
                                sc.GetCurrent(s, sizeof(s));
155
137
                                if (keywords.InList(s)) {
164
146
                                        sc.ChangeState(SCE_LUA_WORD5);
165
147
                                } else if (keywords6.InList(s)) {
166
148
                                        sc.ChangeState(SCE_LUA_WORD6);
167
 
                                } else if (keywords6.InList(s)) {
168
 
                                        sc.ChangeState(SCE_LUA_WORD6);
169
149
                                } else if (keywords7.InList(s)) {
170
150
                                        sc.ChangeState(SCE_LUA_WORD7);
171
151
                                } else if (keywords8.InList(s)) {
179
159
                        }
180
160
                } else if (sc.state == SCE_LUA_STRING) {
181
161
                        if (sc.ch == '\\') {
182
 
                                if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
 
162
                                if (setEscapeSkip.Contains(sc.chNext)) {
183
163
                                        sc.Forward();
184
164
                                }
185
165
                        } else if (sc.ch == '\"') {
190
170
                        }
191
171
                } else if (sc.state == SCE_LUA_CHARACTER) {
192
172
                        if (sc.ch == '\\') {
193
 
                                if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
 
173
                                if (setEscapeSkip.Contains(sc.chNext)) {
194
174
                                        sc.Forward();
195
175
                                }
196
176
                        } else if (sc.ch == '\'') {
225
205
                if (sc.state == SCE_LUA_DEFAULT) {
226
206
                        if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
227
207
                                sc.SetState(SCE_LUA_NUMBER);
228
 
                        } else if (IsAWordStart(sc.ch)) {
 
208
                                if (sc.ch == '0' && toupper(sc.chNext) == 'X') {
 
209
                                        sc.Forward();
 
210
                                }
 
211
                        } else if (setWordStart.Contains(sc.ch)) {
229
212
                                sc.SetState(SCE_LUA_IDENTIFIER);
230
213
                        } else if (sc.ch == '\"') {
231
214
                                sc.SetState(SCE_LUA_STRING);
255
238
                                }
256
239
                        } else if (sc.atLineStart && sc.Match('$')) {
257
240
                                sc.SetState(SCE_LUA_PREPROCESSOR);      // Obsolete since Lua 4.0, but still in old code
258
 
                        } else if (IsLuaOperator(static_cast<char>(sc.ch))) {
 
241
                        } else if (setLuaOperator.Contains(sc.ch)) {
259
242
                                sc.SetState(SCE_LUA_OPERATOR);
260
243
                        }
261
244
                }
262
245
        }
 
246
 
 
247
        if (setWord.Contains(sc.chPrev)) {
 
248
                char s[100];
 
249
                sc.GetCurrent(s, sizeof(s));
 
250
                if (keywords.InList(s)) {
 
251
                        sc.ChangeState(SCE_LUA_WORD);
 
252
                } else if (keywords2.InList(s)) {
 
253
                        sc.ChangeState(SCE_LUA_WORD2);
 
254
                } else if (keywords3.InList(s)) {
 
255
                        sc.ChangeState(SCE_LUA_WORD3);
 
256
                } else if (keywords4.InList(s)) {
 
257
                        sc.ChangeState(SCE_LUA_WORD4);
 
258
                } else if (keywords5.InList(s)) {
 
259
                        sc.ChangeState(SCE_LUA_WORD5);
 
260
                } else if (keywords6.InList(s)) {
 
261
                        sc.ChangeState(SCE_LUA_WORD6);
 
262
                } else if (keywords7.InList(s)) {
 
263
                        sc.ChangeState(SCE_LUA_WORD7);
 
264
                } else if (keywords8.InList(s)) {
 
265
                        sc.ChangeState(SCE_LUA_WORD8);
 
266
                }
 
267
        }
 
268
 
263
269
        sc.Complete();
264
270
}
265
271