1
|
ace.define("ace/mode/haskell_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 HaskellHighlightRules = function() {
|
8
|
|
9
|
this.$rules = { start:
|
10
|
[ { token:
|
11
|
[ 'punctuation.definition.entity.haskell',
|
12
|
'keyword.operator.function.infix.haskell',
|
13
|
'punctuation.definition.entity.haskell' ],
|
14
|
regex: '(`)([a-zA-Z_\']*?)(`)',
|
15
|
comment: 'In case this regex seems unusual for an infix operator, note that Haskell allows any ordinary function application (elem 4 [1..10]) to be rewritten as an infix expression (4 `elem` [1..10]).' },
|
16
|
{ token: 'constant.language.unit.haskell', regex: '\\(\\)' },
|
17
|
{ token: 'constant.language.empty-list.haskell',
|
18
|
regex: '\\[\\]' },
|
19
|
{ token: 'keyword.other.haskell',
|
20
|
regex: '\\b(module|signature)\\b',
|
21
|
push:
|
22
|
[ { token: 'keyword.other.haskell', regex: '\\bwhere\\b', next: 'pop' },
|
23
|
{ include: '#module_name' },
|
24
|
{ include: '#module_exports' },
|
25
|
{ token: 'invalid', regex: '[a-z]+' },
|
26
|
{ defaultToken: 'meta.declaration.module.haskell' } ] },
|
27
|
{ token: 'keyword.other.haskell',
|
28
|
regex: '\\bclass\\b',
|
29
|
push:
|
30
|
[ { token: 'keyword.other.haskell',
|
31
|
regex: '\\bwhere\\b',
|
32
|
next: 'pop' },
|
33
|
{ token: 'support.class.prelude.haskell',
|
34
|
regex: '\\b(?:Monad|Functor|Eq|Ord|Read|Show|Num|(?:Frac|Ra)tional|Enum|Bounded|Real(?:Frac|Float)?|Integral|Floating)\\b' },
|
35
|
{ token: 'entity.other.inherited-class.haskell',
|
36
|
regex: '[A-Z][A-Za-z_\']*' },
|
37
|
{ token: 'variable.other.generic-type.haskell',
|
38
|
regex: '\\b[a-z][a-zA-Z0-9_\']*\\b' },
|
39
|
{ defaultToken: 'meta.declaration.class.haskell' } ] },
|
40
|
{ token: 'keyword.other.haskell',
|
41
|
regex: '\\binstance\\b',
|
42
|
push:
|
43
|
[ { token: 'keyword.other.haskell',
|
44
|
regex: '\\bwhere\\b|$',
|
45
|
next: 'pop' },
|
46
|
{ include: '#type_signature' },
|
47
|
{ defaultToken: 'meta.declaration.instance.haskell' } ] },
|
48
|
{ token: 'keyword.other.haskell',
|
49
|
regex: 'import',
|
50
|
push:
|
51
|
[ { token: 'meta.import.haskell', regex: '$|;|^', next: 'pop' },
|
52
|
{ token: 'keyword.other.haskell', regex: 'qualified|as|hiding' },
|
53
|
{ include: '#module_name' },
|
54
|
{ include: '#module_exports' },
|
55
|
{ defaultToken: 'meta.import.haskell' } ] },
|
56
|
{ token: [ 'keyword.other.haskell', 'meta.deriving.haskell' ],
|
57
|
regex: '(deriving)(\\s*\\()',
|
58
|
push:
|
59
|
[ { token: 'meta.deriving.haskell', regex: '\\)', next: 'pop' },
|
60
|
{ token: 'entity.other.inherited-class.haskell',
|
61
|
regex: '\\b[A-Z][a-zA-Z_\']*' },
|
62
|
{ defaultToken: 'meta.deriving.haskell' } ] },
|
63
|
{ token: 'keyword.other.haskell',
|
64
|
regex: '\\b(?:deriving|where|data|type|case|of|let|in|newtype|default)\\b' },
|
65
|
{ token: 'keyword.operator.haskell', regex: '\\binfix[lr]?\\b' },
|
66
|
{ token: 'keyword.control.haskell',
|
67
|
regex: '\\b(?:do|if|then|else)\\b' },
|
68
|
{ token: 'constant.numeric.float.haskell',
|
69
|
regex: '\\b(?:[0-9]+\\.[0-9]+(?:[eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b',
|
70
|
comment: 'Floats are always decimal' },
|
71
|
{ token: 'constant.numeric.haskell',
|
72
|
regex: '\\b(?:[0-9]+|0(?:[xX][0-9a-fA-F]+|[oO][0-7]+))\\b' },
|
73
|
{ token:
|
74
|
[ 'meta.preprocessor.c',
|
75
|
'punctuation.definition.preprocessor.c',
|
76
|
'meta.preprocessor.c' ],
|
77
|
regex: '^(\\s*)(#)(\\s*\\w+)',
|
78
|
comment: 'In addition to Haskell\'s "native" syntax, GHC permits the C preprocessor to be run on a source file.' },
|
79
|
{ include: '#pragma' },
|
80
|
{ token: 'punctuation.definition.string.begin.haskell',
|
81
|
regex: '"',
|
82
|
push:
|
83
|
[ { token: 'punctuation.definition.string.end.haskell',
|
84
|
regex: '"',
|
85
|
next: 'pop' },
|
86
|
{ token: 'constant.character.escape.haskell',
|
87
|
regex: '\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&])' },
|
88
|
{ token: 'constant.character.escape.octal.haskell',
|
89
|
regex: '\\\\o[0-7]+|\\\\x[0-9A-Fa-f]+|\\\\[0-9]+' },
|
90
|
{ token: 'constant.character.escape.control.haskell',
|
91
|
regex: '\\^[A-Z@\\[\\]\\\\\\^_]' },
|
92
|
{ defaultToken: 'string.quoted.double.haskell' } ] },
|
93
|
{ token:
|
94
|
[ 'punctuation.definition.string.begin.haskell',
|
95
|
'string.quoted.single.haskell',
|
96
|
'constant.character.escape.haskell',
|
97
|
'constant.character.escape.octal.haskell',
|
98
|
'constant.character.escape.hexadecimal.haskell',
|
99
|
'constant.character.escape.control.haskell',
|
100
|
'punctuation.definition.string.end.haskell' ],
|
101
|
regex: '(\')(?:([\\ -\\[\\]-~])|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))(\')' },
|
102
|
{ token:
|
103
|
[ 'meta.function.type-declaration.haskell',
|
104
|
'entity.name.function.haskell',
|
105
|
'meta.function.type-declaration.haskell',
|
106
|
'keyword.other.double-colon.haskell' ],
|
107
|
regex: '^(\\s*)([a-z_][a-zA-Z0-9_\']*|\\([|!%$+\\-.,=</>]+\\))(\\s*)(::)',
|
108
|
push:
|
109
|
[ { token: 'meta.function.type-declaration.haskell',
|
110
|
regex: '$',
|
111
|
next: 'pop' },
|
112
|
{ include: '#type_signature' },
|
113
|
{ defaultToken: 'meta.function.type-declaration.haskell' } ] },
|
114
|
{ token: 'support.constant.haskell',
|
115
|
regex: '\\b(?:Just|Nothing|Left|Right|True|False|LT|EQ|GT|\\(\\)|\\[\\])\\b' },
|
116
|
{ token: 'constant.other.haskell', regex: '\\b[A-Z]\\w*\\b' },
|
117
|
{ include: '#comments' },
|
118
|
{ token: 'support.function.prelude.haskell',
|
119
|
regex: '\\b(?:abs|acos|acosh|all|and|any|appendFile|applyM|asTypeOf|asin|asinh|atan|atan2|atanh|break|catch|ceiling|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|div|divMod|drop|dropWhile|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromEnum|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|head|id|init|interact|ioError|isDenormalized|isIEEE|isInfinite|isNaN|isNegativeZero|iterate|last|lcm|length|lex|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|odd|or|otherwise|pi|pred|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|read|readFile|readIO|readList|readLn|readParen|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showList|showParen|showString|shows|showsPrec|significand|signum|sin|sinh|snd|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|toEnum|toInteger|toRational|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\\b' },
|
120
|
{ include: '#infix_op' },
|
121
|
{ token: 'keyword.operator.haskell',
|
122
|
regex: '[|!%$?~+:\\-.=</>\\\\]+',
|
123
|
comment: 'In case this regex seems overly general, note that Haskell permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*.' },
|
124
|
{ token: 'punctuation.separator.comma.haskell', regex: ',' } ],
|
125
|
'#block_comment':
|
126
|
[ { token: 'punctuation.definition.comment.haskell',
|
127
|
regex: '\\{-(?!#)',
|
128
|
push:
|
129
|
[ { include: '#block_comment' },
|
130
|
{ token: 'punctuation.definition.comment.haskell',
|
131
|
regex: '-\\}',
|
132
|
next: 'pop' },
|
133
|
{ defaultToken: 'comment.block.haskell' } ] } ],
|
134
|
'#comments':
|
135
|
[ { token: 'punctuation.definition.comment.haskell',
|
136
|
regex: '--.*',
|
137
|
push_:
|
138
|
[ { token: 'comment.line.double-dash.haskell',
|
139
|
regex: '$',
|
140
|
next: 'pop' },
|
141
|
{ defaultToken: 'comment.line.double-dash.haskell' } ] },
|
142
|
{ include: '#block_comment' } ],
|
143
|
'#infix_op':
|
144
|
[ { token: 'entity.name.function.infix.haskell',
|
145
|
regex: '\\([|!%$+:\\-.=</>]+\\)|\\(,+\\)' } ],
|
146
|
'#module_exports':
|
147
|
[ { token: 'meta.declaration.exports.haskell',
|
148
|
regex: '\\(',
|
149
|
push:
|
150
|
[ { token: 'meta.declaration.exports.haskell.end',
|
151
|
regex: '\\)',
|
152
|
next: 'pop' },
|
153
|
{ token: 'entity.name.function.haskell',
|
154
|
regex: '\\b[a-z][a-zA-Z_\']*' },
|
155
|
{ token: 'storage.type.haskell', regex: '\\b[A-Z][A-Za-z_\']*' },
|
156
|
{ token: 'punctuation.separator.comma.haskell', regex: ',' },
|
157
|
{ include: '#infix_op' },
|
158
|
{ token: 'meta.other.unknown.haskell',
|
159
|
regex: '\\(.*?\\)',
|
160
|
comment: 'So named because I don\'t know what to call this.' },
|
161
|
{ defaultToken: 'meta.declaration.exports.haskell.end' } ] } ],
|
162
|
'#module_name':
|
163
|
[ { token: 'support.other.module.haskell',
|
164
|
regex: '[A-Z][A-Za-z._\']*' } ],
|
165
|
'#pragma':
|
166
|
[ { token: 'meta.preprocessor.haskell',
|
167
|
regex: '\\{-#',
|
168
|
push:
|
169
|
[ { token: 'meta.preprocessor.haskell',
|
170
|
regex: '#-\\}',
|
171
|
next: 'pop' },
|
172
|
{ token: 'keyword.other.preprocessor.haskell',
|
173
|
regex: '\\b(?:LANGUAGE|UNPACK|INLINE)\\b' },
|
174
|
{ defaultToken: 'meta.preprocessor.haskell' } ] } ],
|
175
|
'#type_signature':
|
176
|
[ { token:
|
177
|
[ 'meta.class-constraint.haskell',
|
178
|
'entity.other.inherited-class.haskell',
|
179
|
'meta.class-constraint.haskell',
|
180
|
'variable.other.generic-type.haskell',
|
181
|
'meta.class-constraint.haskell',
|
182
|
'keyword.other.big-arrow.haskell' ],
|
183
|
regex: '(\\(\\s*)([A-Z][A-Za-z]*)(\\s+)([a-z][A-Za-z_\']*)(\\)\\s*)(=>)' },
|
184
|
{ include: '#pragma' },
|
185
|
{ token: 'keyword.other.arrow.haskell', regex: '->' },
|
186
|
{ token: 'keyword.other.big-arrow.haskell', regex: '=>' },
|
187
|
{ token: 'support.type.prelude.haskell',
|
188
|
regex: '\\b(?:Int(?:eger)?|Maybe|Either|Bool|Float|Double|Char|String|Ordering|ShowS|ReadS|FilePath|IO(?:Error)?)\\b' },
|
189
|
{ token: 'variable.other.generic-type.haskell',
|
190
|
regex: '\\b[a-z][a-zA-Z0-9_\']*\\b' },
|
191
|
{ token: 'storage.type.haskell',
|
192
|
regex: '\\b[A-Z][a-zA-Z0-9_\']*\\b' },
|
193
|
{ token: 'support.constant.unit.haskell', regex: '\\(\\)' },
|
194
|
{ include: '#comments' } ] };
|
195
|
|
196
|
this.normalizeRules();
|
197
|
};
|
198
|
|
199
|
HaskellHighlightRules.metaData = { fileTypes: [ 'hs' ],
|
200
|
keyEquivalent: '^~H',
|
201
|
name: 'Haskell',
|
202
|
scopeName: 'source.haskell' };
|
203
|
|
204
|
|
205
|
oop.inherits(HaskellHighlightRules, TextHighlightRules);
|
206
|
|
207
|
exports.HaskellHighlightRules = HaskellHighlightRules;
|
208
|
});
|
209
|
|
210
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
211
|
"use strict";
|
212
|
|
213
|
var oop = require("../../lib/oop");
|
214
|
var Range = require("../../range").Range;
|
215
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
216
|
|
217
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
218
|
if (commentRegex) {
|
219
|
this.foldingStartMarker = new RegExp(
|
220
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
221
|
);
|
222
|
this.foldingStopMarker = new RegExp(
|
223
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
224
|
);
|
225
|
}
|
226
|
};
|
227
|
oop.inherits(FoldMode, BaseFoldMode);
|
228
|
|
229
|
(function() {
|
230
|
|
231
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
232
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
233
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
234
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
235
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
236
|
this._getFoldWidgetBase = this.getFoldWidget;
|
237
|
this.getFoldWidget = function(session, foldStyle, row) {
|
238
|
var line = session.getLine(row);
|
239
|
|
240
|
if (this.singleLineBlockCommentRe.test(line)) {
|
241
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
242
|
return "";
|
243
|
}
|
244
|
|
245
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
246
|
|
247
|
if (!fw && this.startRegionRe.test(line))
|
248
|
return "start"; // lineCommentRegionStart
|
249
|
|
250
|
return fw;
|
251
|
};
|
252
|
|
253
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
254
|
var line = session.getLine(row);
|
255
|
|
256
|
if (this.startRegionRe.test(line))
|
257
|
return this.getCommentRegionBlock(session, line, row);
|
258
|
|
259
|
var match = line.match(this.foldingStartMarker);
|
260
|
if (match) {
|
261
|
var i = match.index;
|
262
|
|
263
|
if (match[1])
|
264
|
return this.openingBracketBlock(session, match[1], row, i);
|
265
|
|
266
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
267
|
|
268
|
if (range && !range.isMultiLine()) {
|
269
|
if (forceMultiline) {
|
270
|
range = this.getSectionRange(session, row);
|
271
|
} else if (foldStyle != "all")
|
272
|
range = null;
|
273
|
}
|
274
|
|
275
|
return range;
|
276
|
}
|
277
|
|
278
|
if (foldStyle === "markbegin")
|
279
|
return;
|
280
|
|
281
|
var match = line.match(this.foldingStopMarker);
|
282
|
if (match) {
|
283
|
var i = match.index + match[0].length;
|
284
|
|
285
|
if (match[1])
|
286
|
return this.closingBracketBlock(session, match[1], row, i);
|
287
|
|
288
|
return session.getCommentFoldRange(row, i, -1);
|
289
|
}
|
290
|
};
|
291
|
|
292
|
this.getSectionRange = function(session, row) {
|
293
|
var line = session.getLine(row);
|
294
|
var startIndent = line.search(/\S/);
|
295
|
var startRow = row;
|
296
|
var startColumn = line.length;
|
297
|
row = row + 1;
|
298
|
var endRow = row;
|
299
|
var maxRow = session.getLength();
|
300
|
while (++row < maxRow) {
|
301
|
line = session.getLine(row);
|
302
|
var indent = line.search(/\S/);
|
303
|
if (indent === -1)
|
304
|
continue;
|
305
|
if (startIndent > indent)
|
306
|
break;
|
307
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
308
|
|
309
|
if (subRange) {
|
310
|
if (subRange.start.row <= startRow) {
|
311
|
break;
|
312
|
} else if (subRange.isMultiLine()) {
|
313
|
row = subRange.end.row;
|
314
|
} else if (startIndent == indent) {
|
315
|
break;
|
316
|
}
|
317
|
}
|
318
|
endRow = row;
|
319
|
}
|
320
|
|
321
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
322
|
};
|
323
|
this.getCommentRegionBlock = function(session, line, row) {
|
324
|
var startColumn = line.search(/\s*$/);
|
325
|
var maxRow = session.getLength();
|
326
|
var startRow = row;
|
327
|
|
328
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
329
|
var depth = 1;
|
330
|
while (++row < maxRow) {
|
331
|
line = session.getLine(row);
|
332
|
var m = re.exec(line);
|
333
|
if (!m) continue;
|
334
|
if (m[1]) depth--;
|
335
|
else depth++;
|
336
|
|
337
|
if (!depth) break;
|
338
|
}
|
339
|
|
340
|
var endRow = row;
|
341
|
if (endRow > startRow) {
|
342
|
return new Range(startRow, startColumn, endRow, line.length);
|
343
|
}
|
344
|
};
|
345
|
|
346
|
}).call(FoldMode.prototype);
|
347
|
|
348
|
});
|
349
|
|
350
|
ace.define("ace/mode/haskell",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haskell_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
351
|
"use strict";
|
352
|
|
353
|
var oop = require("../lib/oop");
|
354
|
var TextMode = require("./text").Mode;
|
355
|
var HaskellHighlightRules = require("./haskell_highlight_rules").HaskellHighlightRules;
|
356
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
357
|
|
358
|
var Mode = function() {
|
359
|
this.HighlightRules = HaskellHighlightRules;
|
360
|
this.foldingRules = new FoldMode();
|
361
|
this.$behaviour = this.$defaultBehaviour;
|
362
|
};
|
363
|
oop.inherits(Mode, TextMode);
|
364
|
|
365
|
(function() {
|
366
|
this.lineCommentStart = "--";
|
367
|
this.blockComment = null;
|
368
|
this.$id = "ace/mode/haskell";
|
369
|
this.snippetFileId = "ace/snippets/haskell";
|
370
|
}).call(Mode.prototype);
|
371
|
|
372
|
exports.Mode = Mode;
|
373
|
}); (function() {
|
374
|
ace.require(["ace/mode/haskell"], function(m) {
|
375
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
376
|
module.exports = m;
|
377
|
}
|
378
|
});
|
379
|
})();
|
380
|
|