1
|
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var Range = require("../range").Range;
|
5
|
|
6
|
var MatchingBraceOutdent = function() {};
|
7
|
|
8
|
(function() {
|
9
|
|
10
|
this.checkOutdent = function(line, input) {
|
11
|
if (! /^\s+$/.test(line))
|
12
|
return false;
|
13
|
|
14
|
return /^\s*\}/.test(input);
|
15
|
};
|
16
|
|
17
|
this.autoOutdent = function(doc, row) {
|
18
|
var line = doc.getLine(row);
|
19
|
var match = line.match(/^(\s*\})/);
|
20
|
|
21
|
if (!match) return 0;
|
22
|
|
23
|
var column = match[1].length;
|
24
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
25
|
|
26
|
if (!openBracePos || openBracePos.row == row) return 0;
|
27
|
|
28
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
29
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
30
|
};
|
31
|
|
32
|
this.$getIndent = function(line) {
|
33
|
return line.match(/^\s*/)[0];
|
34
|
};
|
35
|
|
36
|
}).call(MatchingBraceOutdent.prototype);
|
37
|
|
38
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
39
|
});
|
40
|
|
41
|
ace.define("ace/mode/livescript",["require","exports","module","ace/tokenizer","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/text"], function(require, exports, module){
|
42
|
var identifier, LiveScriptMode, keywordend, stringfill;
|
43
|
identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
|
44
|
exports.Mode = LiveScriptMode = (function(superclass){
|
45
|
var indenter, prototype = extend$((import$(LiveScriptMode, superclass).displayName = 'LiveScriptMode', LiveScriptMode), superclass).prototype, constructor = LiveScriptMode;
|
46
|
function LiveScriptMode(){
|
47
|
var that;
|
48
|
this.$tokenizer = new (require('../tokenizer')).Tokenizer(LiveScriptMode.Rules);
|
49
|
if (that = require('../mode/matching_brace_outdent')) {
|
50
|
this.$outdent = new that.MatchingBraceOutdent;
|
51
|
}
|
52
|
this.$id = "ace/mode/livescript";
|
53
|
this.$behaviour = new (require("./behaviour/cstyle").CstyleBehaviour)();
|
54
|
}
|
55
|
indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
|
56
|
prototype.getNextLineIndent = function(state, line, tab){
|
57
|
var indent, tokens;
|
58
|
indent = this.$getIndent(line);
|
59
|
tokens = this.$tokenizer.getLineTokens(line, state).tokens;
|
60
|
if (!(tokens.length && tokens[tokens.length - 1].type === 'comment')) {
|
61
|
if (state === 'start' && indenter.test(line)) {
|
62
|
indent += tab;
|
63
|
}
|
64
|
}
|
65
|
return indent;
|
66
|
};
|
67
|
prototype.lineCommentStart = "#";
|
68
|
prototype.blockComment = {start: "###", end: "###"};
|
69
|
prototype.checkOutdent = function(state, line, input){
|
70
|
var ref$;
|
71
|
return (ref$ = this.$outdent) != null ? ref$.checkOutdent(line, input) : void 8;
|
72
|
};
|
73
|
prototype.autoOutdent = function(state, doc, row){
|
74
|
var ref$;
|
75
|
return (ref$ = this.$outdent) != null ? ref$.autoOutdent(doc, row) : void 8;
|
76
|
};
|
77
|
return LiveScriptMode;
|
78
|
}(require('../mode/text').Mode));
|
79
|
keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
|
80
|
stringfill = {
|
81
|
defaultToken: 'string'
|
82
|
};
|
83
|
LiveScriptMode.Rules = {
|
84
|
start: [
|
85
|
{
|
86
|
token: 'keyword',
|
87
|
regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
|
88
|
}, {
|
89
|
token: 'constant.language',
|
90
|
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
|
91
|
}, {
|
92
|
token: 'invalid.illegal',
|
93
|
regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
|
94
|
}, {
|
95
|
token: 'language.support.class',
|
96
|
regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
|
97
|
}, {
|
98
|
token: 'language.support.function',
|
99
|
regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
|
100
|
}, {
|
101
|
token: 'variable.language',
|
102
|
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
|
103
|
}, {
|
104
|
token: 'identifier',
|
105
|
regex: identifier + '\\s*:(?![:=])'
|
106
|
}, {
|
107
|
token: 'variable',
|
108
|
regex: identifier
|
109
|
}, {
|
110
|
token: 'keyword.operator',
|
111
|
regex: '(?:\\.{3}|\\s+\\?)'
|
112
|
}, {
|
113
|
token: 'keyword.variable',
|
114
|
regex: '(?:@+|::|\\.\\.)',
|
115
|
next: 'key'
|
116
|
}, {
|
117
|
token: 'keyword.operator',
|
118
|
regex: '\\.\\s*',
|
119
|
next: 'key'
|
120
|
}, {
|
121
|
token: 'string',
|
122
|
regex: '\\\\\\S[^\\s,;)}\\]]*'
|
123
|
}, {
|
124
|
token: 'string.doc',
|
125
|
regex: '\'\'\'',
|
126
|
next: 'qdoc'
|
127
|
}, {
|
128
|
token: 'string.doc',
|
129
|
regex: '"""',
|
130
|
next: 'qqdoc'
|
131
|
}, {
|
132
|
token: 'string',
|
133
|
regex: '\'',
|
134
|
next: 'qstring'
|
135
|
}, {
|
136
|
token: 'string',
|
137
|
regex: '"',
|
138
|
next: 'qqstring'
|
139
|
}, {
|
140
|
token: 'string',
|
141
|
regex: '`',
|
142
|
next: 'js'
|
143
|
}, {
|
144
|
token: 'string',
|
145
|
regex: '<\\[',
|
146
|
next: 'words'
|
147
|
}, {
|
148
|
token: 'string.regex',
|
149
|
regex: '//',
|
150
|
next: 'heregex'
|
151
|
}, {
|
152
|
token: 'comment.doc',
|
153
|
regex: '/\\*',
|
154
|
next: 'comment'
|
155
|
}, {
|
156
|
token: 'comment',
|
157
|
regex: '#.*'
|
158
|
}, {
|
159
|
token: 'string.regex',
|
160
|
regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
|
161
|
next: 'key'
|
162
|
}, {
|
163
|
token: 'constant.numeric',
|
164
|
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
|
165
|
}, {
|
166
|
token: 'lparen',
|
167
|
regex: '[({[]'
|
168
|
}, {
|
169
|
token: 'rparen',
|
170
|
regex: '[)}\\]]',
|
171
|
next: 'key'
|
172
|
}, {
|
173
|
token: 'keyword.operator',
|
174
|
regex: '[\\^!|&%+\\-]+'
|
175
|
}, {
|
176
|
token: 'text',
|
177
|
regex: '\\s+'
|
178
|
}
|
179
|
],
|
180
|
heregex: [
|
181
|
{
|
182
|
token: 'string.regex',
|
183
|
regex: '.*?//[gimy$?]{0,4}',
|
184
|
next: 'start'
|
185
|
}, {
|
186
|
token: 'string.regex',
|
187
|
regex: '\\s*#{'
|
188
|
}, {
|
189
|
token: 'comment.regex',
|
190
|
regex: '\\s+(?:#.*)?'
|
191
|
}, {
|
192
|
defaultToken: 'string.regex'
|
193
|
}
|
194
|
],
|
195
|
key: [
|
196
|
{
|
197
|
token: 'keyword.operator',
|
198
|
regex: '[.?@!]+'
|
199
|
}, {
|
200
|
token: 'identifier',
|
201
|
regex: identifier,
|
202
|
next: 'start'
|
203
|
}, {
|
204
|
token: 'text',
|
205
|
regex: '',
|
206
|
next: 'start'
|
207
|
}
|
208
|
],
|
209
|
comment: [
|
210
|
{
|
211
|
token: 'comment.doc',
|
212
|
regex: '.*?\\*/',
|
213
|
next: 'start'
|
214
|
}, {
|
215
|
defaultToken: 'comment.doc'
|
216
|
}
|
217
|
],
|
218
|
qdoc: [
|
219
|
{
|
220
|
token: 'string',
|
221
|
regex: ".*?'''",
|
222
|
next: 'key'
|
223
|
}, stringfill
|
224
|
],
|
225
|
qqdoc: [
|
226
|
{
|
227
|
token: 'string',
|
228
|
regex: '.*?"""',
|
229
|
next: 'key'
|
230
|
}, stringfill
|
231
|
],
|
232
|
qstring: [
|
233
|
{
|
234
|
token: 'string',
|
235
|
regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
|
236
|
next: 'key'
|
237
|
}, stringfill
|
238
|
],
|
239
|
qqstring: [
|
240
|
{
|
241
|
token: 'string',
|
242
|
regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
|
243
|
next: 'key'
|
244
|
}, stringfill
|
245
|
],
|
246
|
js: [
|
247
|
{
|
248
|
token: 'string',
|
249
|
regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
|
250
|
next: 'key'
|
251
|
}, stringfill
|
252
|
],
|
253
|
words: [
|
254
|
{
|
255
|
token: 'string',
|
256
|
regex: '.*?\\]>',
|
257
|
next: 'key'
|
258
|
}, stringfill
|
259
|
]
|
260
|
};
|
261
|
function extend$(sub, sup){
|
262
|
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
|
263
|
(sub.prototype = new fun).constructor = sub;
|
264
|
if (typeof sup.extended == 'function') sup.extended(sub);
|
265
|
return sub;
|
266
|
}
|
267
|
function import$(obj, src){
|
268
|
var own = {}.hasOwnProperty;
|
269
|
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
270
|
return obj;
|
271
|
}
|
272
|
}); (function() {
|
273
|
ace.require(["ace/mode/livescript"], function(m) {
|
274
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
275
|
module.exports = m;
|
276
|
}
|
277
|
});
|
278
|
})();
|
279
|
|