1
|
ace.define("ace/mode/prolog_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 PrologHighlightRules = function() {
|
8
|
|
9
|
this.$rules = { start:
|
10
|
[ { include: '#comment' },
|
11
|
{ include: '#basic_fact' },
|
12
|
{ include: '#rule' },
|
13
|
{ include: '#directive' },
|
14
|
{ include: '#fact' } ],
|
15
|
'#atom':
|
16
|
[ { token: 'constant.other.atom.prolog',
|
17
|
regex: '\\b[a-z][a-zA-Z0-9_]*\\b' },
|
18
|
{ token: 'constant.numeric.prolog',
|
19
|
regex: '-?\\d+(?:\\.\\d+)?' },
|
20
|
{ include: '#string' } ],
|
21
|
'#basic_elem':
|
22
|
[ { include: '#comment' },
|
23
|
{ include: '#statement' },
|
24
|
{ include: '#constants' },
|
25
|
{ include: '#operators' },
|
26
|
{ include: '#builtins' },
|
27
|
{ include: '#list' },
|
28
|
{ include: '#atom' },
|
29
|
{ include: '#variable' } ],
|
30
|
'#basic_fact':
|
31
|
[ { token:
|
32
|
[ 'entity.name.function.fact.basic.prolog',
|
33
|
'punctuation.end.fact.basic.prolog' ],
|
34
|
regex: '([a-z]\\w*)(\\.)' } ],
|
35
|
'#builtins':
|
36
|
[ { token: 'support.function.builtin.prolog',
|
37
|
regex: '\\b(?:abolish|abort|ancestors|arg|ascii|assert[az]|atom(?:ic)?|body|char|close|conc|concat|consult|define|definition|dynamic|dump|fail|file|free|free_proc|functor|getc|goal|halt|head|head|integer|length|listing|match_args|member|next_clause|nl|nonvar|nth|number|cvars|nvars|offset|op|print?|prompt|putc|quoted|ratom|read|redefine|rename|retract(?:all)?|see|seeing|seen|skip|spy|statistics|system|tab|tell|telling|term|time|told|univ|unlink_clause|unspy_predicate|var|write)\\b' } ],
|
38
|
'#comment':
|
39
|
[ { token:
|
40
|
[ 'punctuation.definition.comment.prolog',
|
41
|
'comment.line.percentage.prolog' ],
|
42
|
regex: '(%)(.*$)' },
|
43
|
{ token: 'punctuation.definition.comment.prolog',
|
44
|
regex: '/\\*',
|
45
|
push:
|
46
|
[ { token: 'punctuation.definition.comment.prolog',
|
47
|
regex: '\\*/',
|
48
|
next: 'pop' },
|
49
|
{ defaultToken: 'comment.block.prolog' } ] } ],
|
50
|
'#constants':
|
51
|
[ { token: 'constant.language.prolog',
|
52
|
regex: '\\b(?:true|false|yes|no)\\b' } ],
|
53
|
'#directive':
|
54
|
[ { token: 'keyword.operator.directive.prolog',
|
55
|
regex: ':-',
|
56
|
push:
|
57
|
[ { token: 'meta.directive.prolog', regex: '\\.', next: 'pop' },
|
58
|
{ include: '#comment' },
|
59
|
{ include: '#statement' },
|
60
|
{ defaultToken: 'meta.directive.prolog' } ] } ],
|
61
|
'#expr':
|
62
|
[ { include: '#comments' },
|
63
|
{ token: 'meta.expression.prolog',
|
64
|
regex: '\\(',
|
65
|
push:
|
66
|
[ { token: 'meta.expression.prolog', regex: '\\)', next: 'pop' },
|
67
|
{ include: '#expr' },
|
68
|
{ defaultToken: 'meta.expression.prolog' } ] },
|
69
|
{ token: 'keyword.control.cutoff.prolog', regex: '!' },
|
70
|
{ token: 'punctuation.control.and.prolog', regex: ',' },
|
71
|
{ token: 'punctuation.control.or.prolog', regex: ';' },
|
72
|
{ include: '#basic_elem' } ],
|
73
|
'#fact':
|
74
|
[ { token:
|
75
|
[ 'entity.name.function.fact.prolog',
|
76
|
'punctuation.begin.fact.parameters.prolog' ],
|
77
|
regex: '([a-z]\\w*)(\\()(?!.*:-)',
|
78
|
push:
|
79
|
[ { token:
|
80
|
[ 'punctuation.end.fact.parameters.prolog',
|
81
|
'punctuation.end.fact.prolog' ],
|
82
|
regex: '(\\))(\\.?)',
|
83
|
next: 'pop' },
|
84
|
{ include: '#parameter' },
|
85
|
{ defaultToken: 'meta.fact.prolog' } ] } ],
|
86
|
'#list':
|
87
|
[ { token: 'punctuation.begin.list.prolog',
|
88
|
regex: '\\[(?=.*\\])',
|
89
|
push:
|
90
|
[ { token: 'punctuation.end.list.prolog',
|
91
|
regex: '\\]',
|
92
|
next: 'pop' },
|
93
|
{ include: '#comment' },
|
94
|
{ token: 'punctuation.separator.list.prolog', regex: ',' },
|
95
|
{ token: 'punctuation.concat.list.prolog',
|
96
|
regex: '\\|',
|
97
|
push:
|
98
|
[ { token: 'meta.list.concat.prolog',
|
99
|
regex: '(?=\\s*\\])',
|
100
|
next: 'pop' },
|
101
|
{ include: '#basic_elem' },
|
102
|
{ defaultToken: 'meta.list.concat.prolog' } ] },
|
103
|
{ include: '#basic_elem' },
|
104
|
{ defaultToken: 'meta.list.prolog' } ] } ],
|
105
|
'#operators':
|
106
|
[ { token: 'keyword.operator.prolog',
|
107
|
regex: '\\\\\\+|\\bnot\\b|\\bis\\b|->|[><]|[><\\\\:=]?=|(?:=\\\\|\\\\=)=' } ],
|
108
|
'#parameter':
|
109
|
[ { token: 'variable.language.anonymous.prolog',
|
110
|
regex: '\\b_\\b' },
|
111
|
{ token: 'variable.parameter.prolog',
|
112
|
regex: '\\b[A-Z_]\\w*\\b' },
|
113
|
{ token: 'punctuation.separator.parameters.prolog', regex: ',' },
|
114
|
{ include: '#basic_elem' },
|
115
|
{ token: 'text', regex: '[^\\s]' } ],
|
116
|
'#rule':
|
117
|
[ { token: 'meta.rule.prolog',
|
118
|
regex: '(?=[a-z]\\w*.*:-)',
|
119
|
push:
|
120
|
[ { token: 'punctuation.rule.end.prolog',
|
121
|
regex: '\\.',
|
122
|
next: 'pop' },
|
123
|
{ token: 'meta.rule.signature.prolog',
|
124
|
regex: '(?=[a-z]\\w*.*:-)',
|
125
|
push:
|
126
|
[ { token: 'meta.rule.signature.prolog',
|
127
|
regex: '(?=:-)',
|
128
|
next: 'pop' },
|
129
|
{ token: 'entity.name.function.rule.prolog',
|
130
|
regex: '[a-z]\\w*(?=\\(|\\s*:-)' },
|
131
|
{ token: 'punctuation.rule.parameters.begin.prolog',
|
132
|
regex: '\\(',
|
133
|
push:
|
134
|
[ { token: 'punctuation.rule.parameters.end.prolog',
|
135
|
regex: '\\)',
|
136
|
next: 'pop' },
|
137
|
{ include: '#parameter' },
|
138
|
{ defaultToken: 'meta.rule.parameters.prolog' } ] },
|
139
|
{ defaultToken: 'meta.rule.signature.prolog' } ] },
|
140
|
{ token: 'keyword.operator.definition.prolog',
|
141
|
regex: ':-',
|
142
|
push:
|
143
|
[ { token: 'meta.rule.definition.prolog',
|
144
|
regex: '(?=\\.)',
|
145
|
next: 'pop' },
|
146
|
{ include: '#comment' },
|
147
|
{ include: '#expr' },
|
148
|
{ defaultToken: 'meta.rule.definition.prolog' } ] },
|
149
|
{ defaultToken: 'meta.rule.prolog' } ] } ],
|
150
|
'#statement':
|
151
|
[ { token: 'meta.statement.prolog',
|
152
|
regex: '(?=[a-z]\\w*\\()',
|
153
|
push:
|
154
|
[ { token: 'punctuation.end.statement.parameters.prolog',
|
155
|
regex: '\\)',
|
156
|
next: 'pop' },
|
157
|
{ include: '#builtins' },
|
158
|
{ include: '#atom' },
|
159
|
{ token: 'punctuation.begin.statement.parameters.prolog',
|
160
|
regex: '\\(',
|
161
|
push:
|
162
|
[ { token: 'meta.statement.parameters.prolog',
|
163
|
regex: '(?=\\))',
|
164
|
next: 'pop' },
|
165
|
{ token: 'punctuation.separator.statement.prolog', regex: ',' },
|
166
|
{ include: '#basic_elem' },
|
167
|
{ defaultToken: 'meta.statement.parameters.prolog' } ] },
|
168
|
{ defaultToken: 'meta.statement.prolog' } ] } ],
|
169
|
'#string':
|
170
|
[ { token: 'punctuation.definition.string.begin.prolog',
|
171
|
regex: '\'',
|
172
|
push:
|
173
|
[ { token: 'punctuation.definition.string.end.prolog',
|
174
|
regex: '\'',
|
175
|
next: 'pop' },
|
176
|
{ token: 'constant.character.escape.prolog', regex: '\\\\.' },
|
177
|
{ token: 'constant.character.escape.quote.prolog',
|
178
|
regex: '\'\'' },
|
179
|
{ defaultToken: 'string.quoted.single.prolog' } ] } ],
|
180
|
'#variable':
|
181
|
[ { token: 'variable.language.anonymous.prolog',
|
182
|
regex: '\\b_\\b' },
|
183
|
{ token: 'variable.other.prolog',
|
184
|
regex: '\\b[A-Z_][a-zA-Z0-9_]*\\b' } ] };
|
185
|
|
186
|
this.normalizeRules();
|
187
|
};
|
188
|
|
189
|
PrologHighlightRules.metaData = { fileTypes: [ 'plg', 'prolog' ],
|
190
|
foldingStartMarker: '(%\\s*region \\w*)|([a-z]\\w*.*:- ?)',
|
191
|
foldingStopMarker: '(%\\s*end(\\s*region)?)|(?=\\.)',
|
192
|
keyEquivalent: '^~P',
|
193
|
name: 'Prolog',
|
194
|
scopeName: 'source.prolog' };
|
195
|
|
196
|
|
197
|
oop.inherits(PrologHighlightRules, TextHighlightRules);
|
198
|
|
199
|
exports.PrologHighlightRules = PrologHighlightRules;
|
200
|
});
|
201
|
|
202
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
203
|
"use strict";
|
204
|
|
205
|
var oop = require("../../lib/oop");
|
206
|
var Range = require("../../range").Range;
|
207
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
208
|
|
209
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
210
|
if (commentRegex) {
|
211
|
this.foldingStartMarker = new RegExp(
|
212
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
213
|
);
|
214
|
this.foldingStopMarker = new RegExp(
|
215
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
216
|
);
|
217
|
}
|
218
|
};
|
219
|
oop.inherits(FoldMode, BaseFoldMode);
|
220
|
|
221
|
(function() {
|
222
|
|
223
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
224
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
225
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
226
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
227
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
228
|
this._getFoldWidgetBase = this.getFoldWidget;
|
229
|
this.getFoldWidget = function(session, foldStyle, row) {
|
230
|
var line = session.getLine(row);
|
231
|
|
232
|
if (this.singleLineBlockCommentRe.test(line)) {
|
233
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
234
|
return "";
|
235
|
}
|
236
|
|
237
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
238
|
|
239
|
if (!fw && this.startRegionRe.test(line))
|
240
|
return "start"; // lineCommentRegionStart
|
241
|
|
242
|
return fw;
|
243
|
};
|
244
|
|
245
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
246
|
var line = session.getLine(row);
|
247
|
|
248
|
if (this.startRegionRe.test(line))
|
249
|
return this.getCommentRegionBlock(session, line, row);
|
250
|
|
251
|
var match = line.match(this.foldingStartMarker);
|
252
|
if (match) {
|
253
|
var i = match.index;
|
254
|
|
255
|
if (match[1])
|
256
|
return this.openingBracketBlock(session, match[1], row, i);
|
257
|
|
258
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
259
|
|
260
|
if (range && !range.isMultiLine()) {
|
261
|
if (forceMultiline) {
|
262
|
range = this.getSectionRange(session, row);
|
263
|
} else if (foldStyle != "all")
|
264
|
range = null;
|
265
|
}
|
266
|
|
267
|
return range;
|
268
|
}
|
269
|
|
270
|
if (foldStyle === "markbegin")
|
271
|
return;
|
272
|
|
273
|
var match = line.match(this.foldingStopMarker);
|
274
|
if (match) {
|
275
|
var i = match.index + match[0].length;
|
276
|
|
277
|
if (match[1])
|
278
|
return this.closingBracketBlock(session, match[1], row, i);
|
279
|
|
280
|
return session.getCommentFoldRange(row, i, -1);
|
281
|
}
|
282
|
};
|
283
|
|
284
|
this.getSectionRange = function(session, row) {
|
285
|
var line = session.getLine(row);
|
286
|
var startIndent = line.search(/\S/);
|
287
|
var startRow = row;
|
288
|
var startColumn = line.length;
|
289
|
row = row + 1;
|
290
|
var endRow = row;
|
291
|
var maxRow = session.getLength();
|
292
|
while (++row < maxRow) {
|
293
|
line = session.getLine(row);
|
294
|
var indent = line.search(/\S/);
|
295
|
if (indent === -1)
|
296
|
continue;
|
297
|
if (startIndent > indent)
|
298
|
break;
|
299
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
300
|
|
301
|
if (subRange) {
|
302
|
if (subRange.start.row <= startRow) {
|
303
|
break;
|
304
|
} else if (subRange.isMultiLine()) {
|
305
|
row = subRange.end.row;
|
306
|
} else if (startIndent == indent) {
|
307
|
break;
|
308
|
}
|
309
|
}
|
310
|
endRow = row;
|
311
|
}
|
312
|
|
313
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
314
|
};
|
315
|
this.getCommentRegionBlock = function(session, line, row) {
|
316
|
var startColumn = line.search(/\s*$/);
|
317
|
var maxRow = session.getLength();
|
318
|
var startRow = row;
|
319
|
|
320
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
321
|
var depth = 1;
|
322
|
while (++row < maxRow) {
|
323
|
line = session.getLine(row);
|
324
|
var m = re.exec(line);
|
325
|
if (!m) continue;
|
326
|
if (m[1]) depth--;
|
327
|
else depth++;
|
328
|
|
329
|
if (!depth) break;
|
330
|
}
|
331
|
|
332
|
var endRow = row;
|
333
|
if (endRow > startRow) {
|
334
|
return new Range(startRow, startColumn, endRow, line.length);
|
335
|
}
|
336
|
};
|
337
|
|
338
|
}).call(FoldMode.prototype);
|
339
|
|
340
|
});
|
341
|
|
342
|
ace.define("ace/mode/prolog",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/prolog_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
343
|
"use strict";
|
344
|
|
345
|
var oop = require("../lib/oop");
|
346
|
var TextMode = require("./text").Mode;
|
347
|
var PrologHighlightRules = require("./prolog_highlight_rules").PrologHighlightRules;
|
348
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
349
|
|
350
|
var Mode = function() {
|
351
|
this.HighlightRules = PrologHighlightRules;
|
352
|
this.foldingRules = new FoldMode();
|
353
|
this.$behaviour = this.$defaultBehaviour;
|
354
|
};
|
355
|
oop.inherits(Mode, TextMode);
|
356
|
|
357
|
(function() {
|
358
|
this.lineCommentStart = "%";
|
359
|
this.blockComment = {start: "/*", end: "*/"};
|
360
|
this.$id = "ace/mode/prolog";
|
361
|
}).call(Mode.prototype);
|
362
|
|
363
|
exports.Mode = Mode;
|
364
|
}); (function() {
|
365
|
ace.require(["ace/mode/prolog"], function(m) {
|
366
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
367
|
module.exports = m;
|
368
|
}
|
369
|
});
|
370
|
})();
|
371
|
|