1
|
ace.define("ace/mode/jack_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
|
|
7
|
var JackHighlightRules = function() {
|
8
|
this.$rules = {
|
9
|
"start" : [
|
10
|
{
|
11
|
token : "string",
|
12
|
regex : '"',
|
13
|
next : "string2"
|
14
|
}, {
|
15
|
token : "string",
|
16
|
regex : "'",
|
17
|
next : "string1"
|
18
|
}, {
|
19
|
token : "constant.numeric", // hex
|
20
|
regex: "-?0[xX][0-9a-fA-F]+\\b"
|
21
|
}, {
|
22
|
token : "constant.numeric", // float
|
23
|
regex : "(?:0|[-+]?[1-9][0-9]*)\\b"
|
24
|
}, {
|
25
|
token : "constant.binary",
|
26
|
regex : "<[0-9A-Fa-f][0-9A-Fa-f](\\s+[0-9A-Fa-f][0-9A-Fa-f])*>"
|
27
|
}, {
|
28
|
token : "constant.language.boolean",
|
29
|
regex : "(?:true|false)\\b"
|
30
|
}, {
|
31
|
token : "constant.language.null",
|
32
|
regex : "null\\b"
|
33
|
}, {
|
34
|
token : "storage.type",
|
35
|
regex: "(?:Integer|Boolean|Null|String|Buffer|Tuple|List|Object|Function|Coroutine|Form)\\b"
|
36
|
}, {
|
37
|
token : "keyword",
|
38
|
regex : "(?:return|abort|vars|for|delete|in|is|escape|exec|split|and|if|elif|else|while)\\b"
|
39
|
}, {
|
40
|
token : "language.builtin",
|
41
|
regex : "(?:lines|source|parse|read-stream|interval|substr|parseint|write|print|range|rand|inspect|bind|i-values|i-pairs|i-map|i-filter|i-chunk|i-all\\?|i-any\\?|i-collect|i-zip|i-merge|i-each)\\b"
|
42
|
}, {
|
43
|
token : "comment",
|
44
|
regex : "--.*$"
|
45
|
}, {
|
46
|
token : "paren.lparen",
|
47
|
regex : "[[({]"
|
48
|
}, {
|
49
|
token : "paren.rparen",
|
50
|
regex : "[\\])}]"
|
51
|
}, {
|
52
|
token : "storage.form",
|
53
|
regex : "@[a-z]+"
|
54
|
}, {
|
55
|
token : "constant.other.symbol",
|
56
|
regex : ':+[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?'
|
57
|
}, {
|
58
|
token : "variable",
|
59
|
regex : '[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?'
|
60
|
}, {
|
61
|
token : "keyword.operator",
|
62
|
regex : "\\|\\||\\^\\^|&&|!=|==|<=|<|>=|>|\\+|-|\\*|\\/|\\^|\\%|\\#|\\!"
|
63
|
}, {
|
64
|
token : "text",
|
65
|
regex : "\\s+"
|
66
|
}
|
67
|
],
|
68
|
"string1" : [
|
69
|
{
|
70
|
token : "constant.language.escape",
|
71
|
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|['"\\\/bfnrt])/
|
72
|
}, {
|
73
|
token : "string",
|
74
|
regex : "[^'\\\\]+"
|
75
|
}, {
|
76
|
token : "string",
|
77
|
regex : "'",
|
78
|
next : "start"
|
79
|
}, {
|
80
|
token : "string",
|
81
|
regex : "",
|
82
|
next : "start"
|
83
|
}
|
84
|
],
|
85
|
"string2" : [
|
86
|
{
|
87
|
token : "constant.language.escape",
|
88
|
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|['"\\\/bfnrt])/
|
89
|
}, {
|
90
|
token : "string",
|
91
|
regex : '[^"\\\\]+'
|
92
|
}, {
|
93
|
token : "string",
|
94
|
regex : '"',
|
95
|
next : "start"
|
96
|
}, {
|
97
|
token : "string",
|
98
|
regex : "",
|
99
|
next : "start"
|
100
|
}
|
101
|
]
|
102
|
};
|
103
|
|
104
|
};
|
105
|
|
106
|
oop.inherits(JackHighlightRules, TextHighlightRules);
|
107
|
|
108
|
exports.JackHighlightRules = JackHighlightRules;
|
109
|
});
|
110
|
|
111
|
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
112
|
"use strict";
|
113
|
|
114
|
var Range = require("../range").Range;
|
115
|
|
116
|
var MatchingBraceOutdent = function() {};
|
117
|
|
118
|
(function() {
|
119
|
|
120
|
this.checkOutdent = function(line, input) {
|
121
|
if (! /^\s+$/.test(line))
|
122
|
return false;
|
123
|
|
124
|
return /^\s*\}/.test(input);
|
125
|
};
|
126
|
|
127
|
this.autoOutdent = function(doc, row) {
|
128
|
var line = doc.getLine(row);
|
129
|
var match = line.match(/^(\s*\})/);
|
130
|
|
131
|
if (!match) return 0;
|
132
|
|
133
|
var column = match[1].length;
|
134
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
135
|
|
136
|
if (!openBracePos || openBracePos.row == row) return 0;
|
137
|
|
138
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
139
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
140
|
};
|
141
|
|
142
|
this.$getIndent = function(line) {
|
143
|
return line.match(/^\s*/)[0];
|
144
|
};
|
145
|
|
146
|
}).call(MatchingBraceOutdent.prototype);
|
147
|
|
148
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
149
|
});
|
150
|
|
151
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
152
|
"use strict";
|
153
|
|
154
|
var oop = require("../../lib/oop");
|
155
|
var Range = require("../../range").Range;
|
156
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
157
|
|
158
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
159
|
if (commentRegex) {
|
160
|
this.foldingStartMarker = new RegExp(
|
161
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
162
|
);
|
163
|
this.foldingStopMarker = new RegExp(
|
164
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
165
|
);
|
166
|
}
|
167
|
};
|
168
|
oop.inherits(FoldMode, BaseFoldMode);
|
169
|
|
170
|
(function() {
|
171
|
|
172
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
173
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
174
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
175
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
176
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
177
|
this._getFoldWidgetBase = this.getFoldWidget;
|
178
|
this.getFoldWidget = function(session, foldStyle, row) {
|
179
|
var line = session.getLine(row);
|
180
|
|
181
|
if (this.singleLineBlockCommentRe.test(line)) {
|
182
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
183
|
return "";
|
184
|
}
|
185
|
|
186
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
187
|
|
188
|
if (!fw && this.startRegionRe.test(line))
|
189
|
return "start"; // lineCommentRegionStart
|
190
|
|
191
|
return fw;
|
192
|
};
|
193
|
|
194
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
195
|
var line = session.getLine(row);
|
196
|
|
197
|
if (this.startRegionRe.test(line))
|
198
|
return this.getCommentRegionBlock(session, line, row);
|
199
|
|
200
|
var match = line.match(this.foldingStartMarker);
|
201
|
if (match) {
|
202
|
var i = match.index;
|
203
|
|
204
|
if (match[1])
|
205
|
return this.openingBracketBlock(session, match[1], row, i);
|
206
|
|
207
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
208
|
|
209
|
if (range && !range.isMultiLine()) {
|
210
|
if (forceMultiline) {
|
211
|
range = this.getSectionRange(session, row);
|
212
|
} else if (foldStyle != "all")
|
213
|
range = null;
|
214
|
}
|
215
|
|
216
|
return range;
|
217
|
}
|
218
|
|
219
|
if (foldStyle === "markbegin")
|
220
|
return;
|
221
|
|
222
|
var match = line.match(this.foldingStopMarker);
|
223
|
if (match) {
|
224
|
var i = match.index + match[0].length;
|
225
|
|
226
|
if (match[1])
|
227
|
return this.closingBracketBlock(session, match[1], row, i);
|
228
|
|
229
|
return session.getCommentFoldRange(row, i, -1);
|
230
|
}
|
231
|
};
|
232
|
|
233
|
this.getSectionRange = function(session, row) {
|
234
|
var line = session.getLine(row);
|
235
|
var startIndent = line.search(/\S/);
|
236
|
var startRow = row;
|
237
|
var startColumn = line.length;
|
238
|
row = row + 1;
|
239
|
var endRow = row;
|
240
|
var maxRow = session.getLength();
|
241
|
while (++row < maxRow) {
|
242
|
line = session.getLine(row);
|
243
|
var indent = line.search(/\S/);
|
244
|
if (indent === -1)
|
245
|
continue;
|
246
|
if (startIndent > indent)
|
247
|
break;
|
248
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
249
|
|
250
|
if (subRange) {
|
251
|
if (subRange.start.row <= startRow) {
|
252
|
break;
|
253
|
} else if (subRange.isMultiLine()) {
|
254
|
row = subRange.end.row;
|
255
|
} else if (startIndent == indent) {
|
256
|
break;
|
257
|
}
|
258
|
}
|
259
|
endRow = row;
|
260
|
}
|
261
|
|
262
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
263
|
};
|
264
|
this.getCommentRegionBlock = function(session, line, row) {
|
265
|
var startColumn = line.search(/\s*$/);
|
266
|
var maxRow = session.getLength();
|
267
|
var startRow = row;
|
268
|
|
269
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
270
|
var depth = 1;
|
271
|
while (++row < maxRow) {
|
272
|
line = session.getLine(row);
|
273
|
var m = re.exec(line);
|
274
|
if (!m) continue;
|
275
|
if (m[1]) depth--;
|
276
|
else depth++;
|
277
|
|
278
|
if (!depth) break;
|
279
|
}
|
280
|
|
281
|
var endRow = row;
|
282
|
if (endRow > startRow) {
|
283
|
return new Range(startRow, startColumn, endRow, line.length);
|
284
|
}
|
285
|
};
|
286
|
|
287
|
}).call(FoldMode.prototype);
|
288
|
|
289
|
});
|
290
|
|
291
|
ace.define("ace/mode/jack",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/jack_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
292
|
"use strict";
|
293
|
|
294
|
var oop = require("../lib/oop");
|
295
|
var TextMode = require("./text").Mode;
|
296
|
var HighlightRules = require("./jack_highlight_rules").JackHighlightRules;
|
297
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
298
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
299
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
300
|
|
301
|
var Mode = function() {
|
302
|
this.HighlightRules = HighlightRules;
|
303
|
this.$outdent = new MatchingBraceOutdent();
|
304
|
this.$behaviour = new CstyleBehaviour();
|
305
|
this.foldingRules = new CStyleFoldMode();
|
306
|
};
|
307
|
oop.inherits(Mode, TextMode);
|
308
|
|
309
|
(function() {
|
310
|
|
311
|
this.lineCommentStart = "--";
|
312
|
|
313
|
this.getNextLineIndent = function(state, line, tab) {
|
314
|
var indent = this.$getIndent(line);
|
315
|
|
316
|
if (state == "start") {
|
317
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
318
|
if (match) {
|
319
|
indent += tab;
|
320
|
}
|
321
|
}
|
322
|
|
323
|
return indent;
|
324
|
};
|
325
|
|
326
|
this.checkOutdent = function(state, line, input) {
|
327
|
return this.$outdent.checkOutdent(line, input);
|
328
|
};
|
329
|
|
330
|
this.autoOutdent = function(state, doc, row) {
|
331
|
this.$outdent.autoOutdent(doc, row);
|
332
|
};
|
333
|
|
334
|
|
335
|
this.$id = "ace/mode/jack";
|
336
|
}).call(Mode.prototype);
|
337
|
|
338
|
exports.Mode = Mode;
|
339
|
}); (function() {
|
340
|
ace.require(["ace/mode/jack"], function(m) {
|
341
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
342
|
module.exports = m;
|
343
|
}
|
344
|
});
|
345
|
})();
|
346
|
|