1
|
ace.define("ace/mode/elm_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 ElmHighlightRules = function() {
|
8
|
var keywordMapper = this.createKeywordMapper({
|
9
|
"keyword": "as|case|class|data|default|deriving|do|else|export|foreign|" +
|
10
|
"hiding|jsevent|if|import|in|infix|infixl|infixr|instance|let|" +
|
11
|
"module|newtype|of|open|then|type|where|_|port|\u03BB"
|
12
|
}, "identifier");
|
13
|
|
14
|
var escapeRe = /\\(\d+|['"\\&trnbvf])/;
|
15
|
|
16
|
var smallRe = /[a-z_]/.source;
|
17
|
var largeRe = /[A-Z]/.source;
|
18
|
var idRe = /[a-z_A-Z0-9']/.source;
|
19
|
|
20
|
this.$rules = {
|
21
|
start: [{
|
22
|
token: "string.start",
|
23
|
regex: '"',
|
24
|
next: "string"
|
25
|
}, {
|
26
|
token: "string.character",
|
27
|
regex: "'(?:" + escapeRe.source + "|.)'?"
|
28
|
}, {
|
29
|
regex: /0(?:[xX][0-9A-Fa-f]+|[oO][0-7]+)|\d+(\.\d+)?([eE][-+]?\d*)?/,
|
30
|
token: "constant.numeric"
|
31
|
}, {
|
32
|
token: "comment",
|
33
|
regex: "--.*"
|
34
|
}, {
|
35
|
token : "keyword",
|
36
|
regex : /\.\.|\||:|=|\\|"|->|<-|\u2192/
|
37
|
}, {
|
38
|
token : "keyword.operator",
|
39
|
regex : /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]+/
|
40
|
}, {
|
41
|
token : "operator.punctuation",
|
42
|
regex : /[,;`]/
|
43
|
}, {
|
44
|
regex : largeRe + idRe + "+\\.?",
|
45
|
token : function(value) {
|
46
|
if (value[value.length - 1] == ".")
|
47
|
return "entity.name.function";
|
48
|
return "constant.language";
|
49
|
}
|
50
|
}, {
|
51
|
regex : "^" + smallRe + idRe + "+",
|
52
|
token : function(value) {
|
53
|
return "constant.language";
|
54
|
}
|
55
|
}, {
|
56
|
token : keywordMapper,
|
57
|
regex : "[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b"
|
58
|
}, {
|
59
|
regex: "{-#?",
|
60
|
token: "comment.start",
|
61
|
onMatch: function(value, currentState, stack) {
|
62
|
this.next = value.length == 2 ? "blockComment" : "docComment";
|
63
|
return this.token;
|
64
|
}
|
65
|
}, {
|
66
|
token: "variable.language",
|
67
|
regex: /\[markdown\|/,
|
68
|
next: "markdown"
|
69
|
}, {
|
70
|
token: "paren.lparen",
|
71
|
regex: /[\[({]/
|
72
|
}, {
|
73
|
token: "paren.rparen",
|
74
|
regex: /[\])}]/
|
75
|
} ],
|
76
|
markdown: [{
|
77
|
regex: /\|\]/,
|
78
|
next: "start"
|
79
|
}, {
|
80
|
defaultToken : "string"
|
81
|
}],
|
82
|
blockComment: [{
|
83
|
regex: "{-",
|
84
|
token: "comment.start",
|
85
|
push: "blockComment"
|
86
|
}, {
|
87
|
regex: "-}",
|
88
|
token: "comment.end",
|
89
|
next: "pop"
|
90
|
}, {
|
91
|
defaultToken: "comment"
|
92
|
}],
|
93
|
docComment: [{
|
94
|
regex: "{-",
|
95
|
token: "comment.start",
|
96
|
push: "docComment"
|
97
|
}, {
|
98
|
regex: "-}",
|
99
|
token: "comment.end",
|
100
|
next: "pop"
|
101
|
}, {
|
102
|
defaultToken: "doc.comment"
|
103
|
}],
|
104
|
string: [{
|
105
|
token: "constant.language.escape",
|
106
|
regex: escapeRe
|
107
|
}, {
|
108
|
token: "text",
|
109
|
regex: /\\(\s|$)/,
|
110
|
next: "stringGap"
|
111
|
}, {
|
112
|
token: "string.end",
|
113
|
regex: '"',
|
114
|
next: "start"
|
115
|
}, {
|
116
|
defaultToken: "string"
|
117
|
}],
|
118
|
stringGap: [{
|
119
|
token: "text",
|
120
|
regex: /\\/,
|
121
|
next: "string"
|
122
|
}, {
|
123
|
token: "error",
|
124
|
regex: "",
|
125
|
next: "start"
|
126
|
}]
|
127
|
};
|
128
|
|
129
|
this.normalizeRules();
|
130
|
};
|
131
|
|
132
|
oop.inherits(ElmHighlightRules, TextHighlightRules);
|
133
|
|
134
|
exports.ElmHighlightRules = ElmHighlightRules;
|
135
|
});
|
136
|
|
137
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
138
|
"use strict";
|
139
|
|
140
|
var oop = require("../../lib/oop");
|
141
|
var Range = require("../../range").Range;
|
142
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
143
|
|
144
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
145
|
if (commentRegex) {
|
146
|
this.foldingStartMarker = new RegExp(
|
147
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
148
|
);
|
149
|
this.foldingStopMarker = new RegExp(
|
150
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
151
|
);
|
152
|
}
|
153
|
};
|
154
|
oop.inherits(FoldMode, BaseFoldMode);
|
155
|
|
156
|
(function() {
|
157
|
|
158
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
159
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
160
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
161
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
162
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
163
|
this._getFoldWidgetBase = this.getFoldWidget;
|
164
|
this.getFoldWidget = function(session, foldStyle, row) {
|
165
|
var line = session.getLine(row);
|
166
|
|
167
|
if (this.singleLineBlockCommentRe.test(line)) {
|
168
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
169
|
return "";
|
170
|
}
|
171
|
|
172
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
173
|
|
174
|
if (!fw && this.startRegionRe.test(line))
|
175
|
return "start"; // lineCommentRegionStart
|
176
|
|
177
|
return fw;
|
178
|
};
|
179
|
|
180
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
181
|
var line = session.getLine(row);
|
182
|
|
183
|
if (this.startRegionRe.test(line))
|
184
|
return this.getCommentRegionBlock(session, line, row);
|
185
|
|
186
|
var match = line.match(this.foldingStartMarker);
|
187
|
if (match) {
|
188
|
var i = match.index;
|
189
|
|
190
|
if (match[1])
|
191
|
return this.openingBracketBlock(session, match[1], row, i);
|
192
|
|
193
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
194
|
|
195
|
if (range && !range.isMultiLine()) {
|
196
|
if (forceMultiline) {
|
197
|
range = this.getSectionRange(session, row);
|
198
|
} else if (foldStyle != "all")
|
199
|
range = null;
|
200
|
}
|
201
|
|
202
|
return range;
|
203
|
}
|
204
|
|
205
|
if (foldStyle === "markbegin")
|
206
|
return;
|
207
|
|
208
|
var match = line.match(this.foldingStopMarker);
|
209
|
if (match) {
|
210
|
var i = match.index + match[0].length;
|
211
|
|
212
|
if (match[1])
|
213
|
return this.closingBracketBlock(session, match[1], row, i);
|
214
|
|
215
|
return session.getCommentFoldRange(row, i, -1);
|
216
|
}
|
217
|
};
|
218
|
|
219
|
this.getSectionRange = function(session, row) {
|
220
|
var line = session.getLine(row);
|
221
|
var startIndent = line.search(/\S/);
|
222
|
var startRow = row;
|
223
|
var startColumn = line.length;
|
224
|
row = row + 1;
|
225
|
var endRow = row;
|
226
|
var maxRow = session.getLength();
|
227
|
while (++row < maxRow) {
|
228
|
line = session.getLine(row);
|
229
|
var indent = line.search(/\S/);
|
230
|
if (indent === -1)
|
231
|
continue;
|
232
|
if (startIndent > indent)
|
233
|
break;
|
234
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
235
|
|
236
|
if (subRange) {
|
237
|
if (subRange.start.row <= startRow) {
|
238
|
break;
|
239
|
} else if (subRange.isMultiLine()) {
|
240
|
row = subRange.end.row;
|
241
|
} else if (startIndent == indent) {
|
242
|
break;
|
243
|
}
|
244
|
}
|
245
|
endRow = row;
|
246
|
}
|
247
|
|
248
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
249
|
};
|
250
|
this.getCommentRegionBlock = function(session, line, row) {
|
251
|
var startColumn = line.search(/\s*$/);
|
252
|
var maxRow = session.getLength();
|
253
|
var startRow = row;
|
254
|
|
255
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
256
|
var depth = 1;
|
257
|
while (++row < maxRow) {
|
258
|
line = session.getLine(row);
|
259
|
var m = re.exec(line);
|
260
|
if (!m) continue;
|
261
|
if (m[1]) depth--;
|
262
|
else depth++;
|
263
|
|
264
|
if (!depth) break;
|
265
|
}
|
266
|
|
267
|
var endRow = row;
|
268
|
if (endRow > startRow) {
|
269
|
return new Range(startRow, startColumn, endRow, line.length);
|
270
|
}
|
271
|
};
|
272
|
|
273
|
}).call(FoldMode.prototype);
|
274
|
|
275
|
});
|
276
|
|
277
|
ace.define("ace/mode/elm",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/elm_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
278
|
"use strict";
|
279
|
|
280
|
var oop = require("../lib/oop");
|
281
|
var TextMode = require("./text").Mode;
|
282
|
var HighlightRules = require("./elm_highlight_rules").ElmHighlightRules;
|
283
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
284
|
|
285
|
var Mode = function() {
|
286
|
this.HighlightRules = HighlightRules;
|
287
|
this.foldingRules = new FoldMode();
|
288
|
this.$behaviour = this.$defaultBehaviour;
|
289
|
};
|
290
|
oop.inherits(Mode, TextMode);
|
291
|
|
292
|
(function() {
|
293
|
this.lineCommentStart = "--";
|
294
|
this.blockComment = {start: "{-", end: "-}", nestable: true};
|
295
|
this.$id = "ace/mode/elm";
|
296
|
}).call(Mode.prototype);
|
297
|
|
298
|
exports.Mode = Mode;
|
299
|
}); (function() {
|
300
|
ace.require(["ace/mode/elm"], function(m) {
|
301
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
302
|
module.exports = m;
|
303
|
}
|
304
|
});
|
305
|
})();
|
306
|
|