1
|
ace.define("ace/mode/nim_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function (require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../lib/oop");
|
5
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
6
|
var NimHighlightRules = function () {
|
7
|
|
8
|
var keywordMapper = this.createKeywordMapper({
|
9
|
"variable": "var|let|const",
|
10
|
"keyword": "assert|parallel|spawn|export|include|from|template|mixin|bind|import|concept|raise|defer|try|finally|except|converter|proc|func|macro|method|and|or|not|xor|shl|shr|div|mod|in|notin|is|isnot|of|static|if|elif|else|case|of|discard|when|return|yield|block|break|while|echo|continue|asm|using|cast|addr|unsafeAddr|type|ref|ptr|do|declared|defined|definedInScope|compiles|sizeOf|is|shallowCopy|getAst|astToStr|spawn|procCall|for|iterator|as",
|
11
|
"storage.type": "newSeq|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|char|bool|string|set|pointer|float32|float64|enum|object|cstring|array|seq|openArray|varargs|UncheckedArray|tuple|set|distinct|void|auto|openarray|range",
|
12
|
"support.function": "lock|ze|toU8|toU16|toU32|ord|low|len|high|add|pop|contains|card|incl|excl|dealloc|inc",
|
13
|
"constant.language": "nil|true|false"
|
14
|
}, "identifier");
|
15
|
|
16
|
var hexNumber = "(?:0[xX][\\dA-Fa-f][\\dA-Fa-f_]*)";
|
17
|
var decNumber = "(?:[0-9][\\d_]*)";
|
18
|
var octNumber = "(?:0o[0-7][0-7_]*)";
|
19
|
var binNumber = "(?:0[bB][01][01_]*)";
|
20
|
var intNumber = "(?:" + hexNumber + "|" + decNumber + "|" + octNumber + "|" + binNumber + ")(?:'?[iIuU](?:8|16|32|64)|u)?\\b";
|
21
|
var exponent = "(?:[eE][+-]?[\\d][\\d_]*)";
|
22
|
var floatNumber = "(?:[\\d][\\d_]*(?:[.][\\d](?:[\\d_]*)" + exponent + "?)|" + exponent + ")";
|
23
|
var floatNumberExt = "(?:" + hexNumber + "(?:'(?:(?:[fF](?:32|64)?)|[dD])))|(?:" + floatNumber + "|" + decNumber + "|" + octNumber + "|" + binNumber + ")(?:'(?:(?:[fF](?:32|64)?)|[dD]))";
|
24
|
var stringEscape = "\\\\([abeprcnlftv\\\"']|x[0-9A-Fa-f]{2}|[0-2][0-9]{2}|u[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})";
|
25
|
var identifier = '[a-zA-Z][a-zA-Z0-9_]*';
|
26
|
this.$rules = {
|
27
|
"start": [{
|
28
|
token: ["identifier", "keyword.operator", "support.function"],
|
29
|
regex: "(" + identifier + ")([.]{1})(" + identifier + ")(?=\\()"
|
30
|
}, {//pragmas
|
31
|
token: "paren.lparen",
|
32
|
regex: "(\\{\\.)",
|
33
|
next: [{
|
34
|
token: "paren.rparen",
|
35
|
regex: '(\\.\\}|\\})',
|
36
|
next: "start"
|
37
|
}, {
|
38
|
include: "methods"
|
39
|
}, {
|
40
|
token: "identifier",
|
41
|
regex: identifier
|
42
|
}, {
|
43
|
token: "punctuation",
|
44
|
regex: /[,]/
|
45
|
}, {
|
46
|
token: "keyword.operator",
|
47
|
regex: /[=:.]/
|
48
|
}, {
|
49
|
token: "paren.lparen",
|
50
|
regex: /[[(]/
|
51
|
}, {
|
52
|
token: "paren.rparen",
|
53
|
regex: /[\])]/
|
54
|
}, {
|
55
|
include: "math"
|
56
|
}, {
|
57
|
include: "strings"
|
58
|
}, {
|
59
|
defaultToken: "text"
|
60
|
}]
|
61
|
}, {
|
62
|
token: "comment.doc.start",
|
63
|
regex: /##\[(?!])/,
|
64
|
push: "docBlockComment"
|
65
|
}, {
|
66
|
token: "comment.start",
|
67
|
regex: /#\[(?!])/,
|
68
|
push: "blockComment"
|
69
|
}, {
|
70
|
token: "comment.doc",
|
71
|
regex: '##.*$'
|
72
|
}, {
|
73
|
token: "comment",
|
74
|
regex: '#.*$'
|
75
|
}, {
|
76
|
include: "strings"
|
77
|
}, {// character
|
78
|
token: "string",
|
79
|
regex: "'(?:\\\\(?:[abercnlftv]|x[0-9A-Fa-f]{2}|[0-2][0-9]{2}|u[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})|.{1})?'"
|
80
|
}, {
|
81
|
include: "methods"
|
82
|
}, {
|
83
|
token: keywordMapper,
|
84
|
regex: "[a-zA-Z][a-zA-Z0-9_]*\\b"
|
85
|
}, {
|
86
|
token: ["keyword.operator", "text", "storage.type"],
|
87
|
regex: "([:])(\\s+)(" + identifier + ")(?=$|\\)|\\[|,|\\s+=|;|\\s+\\{)"
|
88
|
}, {
|
89
|
token: "paren.lparen",
|
90
|
regex: /\[\.|{\||\(\.|\[:|[[({`]/
|
91
|
}, {
|
92
|
token: "paren.rparen",
|
93
|
regex: /\.\)|\|}|\.]|[\])}]/
|
94
|
}, {
|
95
|
token: "keyword.operator",
|
96
|
regex: /[=+\-*\/<>@$~&%|!?^.:\\]/
|
97
|
}, {
|
98
|
token: "punctuation",
|
99
|
regex: /[,;]/
|
100
|
}, {
|
101
|
include: "math"
|
102
|
}],
|
103
|
blockComment: [{
|
104
|
regex: /#\[]/,
|
105
|
token: "comment"
|
106
|
}, {
|
107
|
regex: /#\[(?!])/,
|
108
|
token: "comment.start",
|
109
|
push: "blockComment"
|
110
|
}, {
|
111
|
regex: /]#/,
|
112
|
token: "comment.end",
|
113
|
next: "pop"
|
114
|
}, {
|
115
|
defaultToken: "comment"
|
116
|
}],
|
117
|
docBlockComment: [{
|
118
|
regex: /##\[]/,
|
119
|
token: "comment.doc"
|
120
|
}, {
|
121
|
regex: /##\[(?!])/,
|
122
|
token: "comment.doc.start",
|
123
|
push: "docBlockComment"
|
124
|
}, {
|
125
|
regex: /]##/,
|
126
|
token: "comment.doc.end",
|
127
|
next: "pop"
|
128
|
}, {
|
129
|
defaultToken: "comment.doc"
|
130
|
}],
|
131
|
math: [{
|
132
|
token: "constant.float",
|
133
|
regex: floatNumberExt
|
134
|
}, {
|
135
|
token: "constant.float",
|
136
|
regex: floatNumber
|
137
|
}, {
|
138
|
token: "constant.integer",
|
139
|
regex: intNumber
|
140
|
}],
|
141
|
methods: [{
|
142
|
token: "support.function",
|
143
|
regex: "(\\w+)(?=\\()"
|
144
|
}],
|
145
|
strings: [{
|
146
|
token: "string",
|
147
|
regex: '(\\b' + identifier + ')?"""',
|
148
|
push: [{
|
149
|
token: "string",
|
150
|
regex: '"""',
|
151
|
next: "pop"
|
152
|
}, {
|
153
|
defaultToken: "string"
|
154
|
}]
|
155
|
}, {
|
156
|
token: "string",
|
157
|
regex: "\\b" + identifier + '"(?=.)',
|
158
|
push: [{
|
159
|
token: "string",
|
160
|
regex: '"|$',
|
161
|
next: "pop"
|
162
|
}, {
|
163
|
defaultToken: "string"
|
164
|
}]
|
165
|
}, {
|
166
|
token: "string",
|
167
|
regex: '"',
|
168
|
push: [{
|
169
|
token: "string",
|
170
|
regex: '"|$',
|
171
|
next: "pop"
|
172
|
}, {
|
173
|
token: "constant.language.escape",
|
174
|
regex: stringEscape
|
175
|
}, {
|
176
|
defaultToken: "string"
|
177
|
}]
|
178
|
}]
|
179
|
};
|
180
|
this.normalizeRules();
|
181
|
};
|
182
|
|
183
|
|
184
|
oop.inherits(NimHighlightRules, TextHighlightRules);
|
185
|
|
186
|
exports.NimHighlightRules = NimHighlightRules;
|
187
|
});
|
188
|
|
189
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
190
|
"use strict";
|
191
|
|
192
|
var oop = require("../../lib/oop");
|
193
|
var Range = require("../../range").Range;
|
194
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
195
|
|
196
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
197
|
if (commentRegex) {
|
198
|
this.foldingStartMarker = new RegExp(
|
199
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
200
|
);
|
201
|
this.foldingStopMarker = new RegExp(
|
202
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
203
|
);
|
204
|
}
|
205
|
};
|
206
|
oop.inherits(FoldMode, BaseFoldMode);
|
207
|
|
208
|
(function() {
|
209
|
|
210
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
211
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
212
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
213
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
214
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
215
|
this._getFoldWidgetBase = this.getFoldWidget;
|
216
|
this.getFoldWidget = function(session, foldStyle, row) {
|
217
|
var line = session.getLine(row);
|
218
|
|
219
|
if (this.singleLineBlockCommentRe.test(line)) {
|
220
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
221
|
return "";
|
222
|
}
|
223
|
|
224
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
225
|
|
226
|
if (!fw && this.startRegionRe.test(line))
|
227
|
return "start"; // lineCommentRegionStart
|
228
|
|
229
|
return fw;
|
230
|
};
|
231
|
|
232
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
233
|
var line = session.getLine(row);
|
234
|
|
235
|
if (this.startRegionRe.test(line))
|
236
|
return this.getCommentRegionBlock(session, line, row);
|
237
|
|
238
|
var match = line.match(this.foldingStartMarker);
|
239
|
if (match) {
|
240
|
var i = match.index;
|
241
|
|
242
|
if (match[1])
|
243
|
return this.openingBracketBlock(session, match[1], row, i);
|
244
|
|
245
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
246
|
|
247
|
if (range && !range.isMultiLine()) {
|
248
|
if (forceMultiline) {
|
249
|
range = this.getSectionRange(session, row);
|
250
|
} else if (foldStyle != "all")
|
251
|
range = null;
|
252
|
}
|
253
|
|
254
|
return range;
|
255
|
}
|
256
|
|
257
|
if (foldStyle === "markbegin")
|
258
|
return;
|
259
|
|
260
|
var match = line.match(this.foldingStopMarker);
|
261
|
if (match) {
|
262
|
var i = match.index + match[0].length;
|
263
|
|
264
|
if (match[1])
|
265
|
return this.closingBracketBlock(session, match[1], row, i);
|
266
|
|
267
|
return session.getCommentFoldRange(row, i, -1);
|
268
|
}
|
269
|
};
|
270
|
|
271
|
this.getSectionRange = function(session, row) {
|
272
|
var line = session.getLine(row);
|
273
|
var startIndent = line.search(/\S/);
|
274
|
var startRow = row;
|
275
|
var startColumn = line.length;
|
276
|
row = row + 1;
|
277
|
var endRow = row;
|
278
|
var maxRow = session.getLength();
|
279
|
while (++row < maxRow) {
|
280
|
line = session.getLine(row);
|
281
|
var indent = line.search(/\S/);
|
282
|
if (indent === -1)
|
283
|
continue;
|
284
|
if (startIndent > indent)
|
285
|
break;
|
286
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
287
|
|
288
|
if (subRange) {
|
289
|
if (subRange.start.row <= startRow) {
|
290
|
break;
|
291
|
} else if (subRange.isMultiLine()) {
|
292
|
row = subRange.end.row;
|
293
|
} else if (startIndent == indent) {
|
294
|
break;
|
295
|
}
|
296
|
}
|
297
|
endRow = row;
|
298
|
}
|
299
|
|
300
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
301
|
};
|
302
|
this.getCommentRegionBlock = function(session, line, row) {
|
303
|
var startColumn = line.search(/\s*$/);
|
304
|
var maxRow = session.getLength();
|
305
|
var startRow = row;
|
306
|
|
307
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
308
|
var depth = 1;
|
309
|
while (++row < maxRow) {
|
310
|
line = session.getLine(row);
|
311
|
var m = re.exec(line);
|
312
|
if (!m) continue;
|
313
|
if (m[1]) depth--;
|
314
|
else depth++;
|
315
|
|
316
|
if (!depth) break;
|
317
|
}
|
318
|
|
319
|
var endRow = row;
|
320
|
if (endRow > startRow) {
|
321
|
return new Range(startRow, startColumn, endRow, line.length);
|
322
|
}
|
323
|
};
|
324
|
|
325
|
}).call(FoldMode.prototype);
|
326
|
|
327
|
});
|
328
|
|
329
|
ace.define("ace/mode/nim",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/nim_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) {
|
330
|
"use strict";
|
331
|
|
332
|
var oop = require("../lib/oop");
|
333
|
var TextMode = require("./text").Mode;
|
334
|
var NimHighlightRules = require("./nim_highlight_rules").NimHighlightRules;
|
335
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
336
|
|
337
|
var Mode = function () {
|
338
|
TextMode.call(this);
|
339
|
this.HighlightRules = NimHighlightRules;
|
340
|
this.foldingRules = new CStyleFoldMode();
|
341
|
this.$behaviour = this.$defaultBehaviour;
|
342
|
};
|
343
|
|
344
|
oop.inherits(Mode, TextMode);
|
345
|
|
346
|
|
347
|
(function () {
|
348
|
this.lineCommentStart = "#";
|
349
|
this.blockComment = {start: "#[", end: "]#", nestable: true};
|
350
|
|
351
|
|
352
|
this.$id = "ace/mode/nim";
|
353
|
}).call(Mode.prototype);
|
354
|
|
355
|
exports.Mode = Mode;
|
356
|
}); (function() {
|
357
|
ace.require(["ace/mode/nim"], function(m) {
|
358
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
359
|
module.exports = m;
|
360
|
}
|
361
|
});
|
362
|
})();
|
363
|
|