| 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 |
var oop = require("../lib/oop"); |
| 4 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 5 |
var PrologHighlightRules = function () { |
| 6 |
this.$rules = { start: [{ include: '#comment' }, |
| 7 |
{ include: '#basic_fact' }, |
| 8 |
{ include: '#rule' }, |
| 9 |
{ include: '#directive' }, |
| 10 |
{ include: '#fact' }], |
| 11 |
'#atom': [{ token: 'constant.other.atom.prolog', |
| 12 |
regex: '\\b[a-z][a-zA-Z0-9_]*\\b' }, |
| 13 |
{ token: 'constant.numeric.prolog', |
| 14 |
regex: '-?\\d+(?:\\.\\d+)?' }, |
| 15 |
{ include: '#string' }], |
| 16 |
'#basic_elem': [{ include: '#comment' }, |
| 17 |
{ include: '#statement' }, |
| 18 |
{ include: '#constants' }, |
| 19 |
{ include: '#operators' }, |
| 20 |
{ include: '#builtins' }, |
| 21 |
{ include: '#list' }, |
| 22 |
{ include: '#atom' }, |
| 23 |
{ include: '#variable' }], |
| 24 |
'#basic_fact': [{ token: ['entity.name.function.fact.basic.prolog', |
| 25 |
'punctuation.end.fact.basic.prolog'], |
| 26 |
regex: '([a-z]\\w*)(\\.)' }], |
| 27 |
'#builtins': [{ token: 'support.function.builtin.prolog', |
| 28 |
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' }], |
| 29 |
'#comment': [{ token: ['punctuation.definition.comment.prolog', |
| 30 |
'comment.line.percentage.prolog'], |
| 31 |
regex: '(%)(.*$)' }, |
| 32 |
{ token: 'punctuation.definition.comment.prolog', |
| 33 |
regex: '/\\*', |
| 34 |
push: [{ token: 'punctuation.definition.comment.prolog', |
| 35 |
regex: '\\*/', |
| 36 |
next: 'pop' }, |
| 37 |
{ defaultToken: 'comment.block.prolog' }] }], |
| 38 |
'#constants': [{ token: 'constant.language.prolog', |
| 39 |
regex: '\\b(?:true|false|yes|no)\\b' }], |
| 40 |
'#directive': [{ token: 'keyword.operator.directive.prolog', |
| 41 |
regex: ':-', |
| 42 |
push: [{ token: 'meta.directive.prolog', regex: '\\.', next: 'pop' }, |
| 43 |
{ include: '#comment' }, |
| 44 |
{ include: '#statement' }, |
| 45 |
{ defaultToken: 'meta.directive.prolog' }] }], |
| 46 |
'#expr': [{ include: '#comments' }, |
| 47 |
{ token: 'meta.expression.prolog', |
| 48 |
regex: '\\(', |
| 49 |
push: [{ token: 'meta.expression.prolog', regex: '\\)', next: 'pop' }, |
| 50 |
{ include: '#expr' }, |
| 51 |
{ defaultToken: 'meta.expression.prolog' }] }, |
| 52 |
{ token: 'keyword.control.cutoff.prolog', regex: '!' }, |
| 53 |
{ token: 'punctuation.control.and.prolog', regex: ',' }, |
| 54 |
{ token: 'punctuation.control.or.prolog', regex: ';' }, |
| 55 |
{ include: '#basic_elem' }], |
| 56 |
'#fact': [{ token: ['entity.name.function.fact.prolog', |
| 57 |
'punctuation.begin.fact.parameters.prolog'], |
| 58 |
regex: '([a-z]\\w*)(\\()(?!.*:-)', |
| 59 |
push: [{ token: ['punctuation.end.fact.parameters.prolog', |
| 60 |
'punctuation.end.fact.prolog'], |
| 61 |
regex: '(\\))(\\.?)', |
| 62 |
next: 'pop' }, |
| 63 |
{ include: '#parameter' }, |
| 64 |
{ defaultToken: 'meta.fact.prolog' }] }], |
| 65 |
'#list': [{ token: 'punctuation.begin.list.prolog', |
| 66 |
regex: '\\[(?=.*\\])', |
| 67 |
push: [{ token: 'punctuation.end.list.prolog', |
| 68 |
regex: '\\]', |
| 69 |
next: 'pop' }, |
| 70 |
{ include: '#comment' }, |
| 71 |
{ token: 'punctuation.separator.list.prolog', regex: ',' }, |
| 72 |
{ token: 'punctuation.concat.list.prolog', |
| 73 |
regex: '\\|', |
| 74 |
push: [{ token: 'meta.list.concat.prolog', |
| 75 |
regex: '(?=\\s*\\])', |
| 76 |
next: 'pop' }, |
| 77 |
{ include: '#basic_elem' }, |
| 78 |
{ defaultToken: 'meta.list.concat.prolog' }] }, |
| 79 |
{ include: '#basic_elem' }, |
| 80 |
{ defaultToken: 'meta.list.prolog' }] }], |
| 81 |
'#operators': [{ token: 'keyword.operator.prolog', |
| 82 |
regex: '\\\\\\+|\\bnot\\b|\\bis\\b|->|[><]|[><\\\\:=]?=|(?:=\\\\|\\\\=)=' }], |
| 83 |
'#parameter': [{ token: 'variable.language.anonymous.prolog', |
| 84 |
regex: '\\b_\\b' }, |
| 85 |
{ token: 'variable.parameter.prolog', |
| 86 |
regex: '\\b[A-Z_]\\w*\\b' }, |
| 87 |
{ token: 'punctuation.separator.parameters.prolog', regex: ',' }, |
| 88 |
{ include: '#basic_elem' }, |
| 89 |
{ token: 'text', regex: '[^\\s]' }], |
| 90 |
'#rule': [{ token: 'meta.rule.prolog', |
| 91 |
regex: '(?=[a-z]\\w*.*:-)', |
| 92 |
push: [{ token: 'punctuation.rule.end.prolog', |
| 93 |
regex: '\\.', |
| 94 |
next: 'pop' }, |
| 95 |
{ token: 'meta.rule.signature.prolog', |
| 96 |
regex: '(?=[a-z]\\w*.*:-)', |
| 97 |
push: [{ token: 'meta.rule.signature.prolog', |
| 98 |
regex: '(?=:-)', |
| 99 |
next: 'pop' }, |
| 100 |
{ token: 'entity.name.function.rule.prolog', |
| 101 |
regex: '[a-z]\\w*(?=\\(|\\s*:-)' }, |
| 102 |
{ token: 'punctuation.rule.parameters.begin.prolog', |
| 103 |
regex: '\\(', |
| 104 |
push: [{ token: 'punctuation.rule.parameters.end.prolog', |
| 105 |
regex: '\\)', |
| 106 |
next: 'pop' }, |
| 107 |
{ include: '#parameter' }, |
| 108 |
{ defaultToken: 'meta.rule.parameters.prolog' }] }, |
| 109 |
{ defaultToken: 'meta.rule.signature.prolog' }] }, |
| 110 |
{ token: 'keyword.operator.definition.prolog', |
| 111 |
regex: ':-', |
| 112 |
push: [{ token: 'meta.rule.definition.prolog', |
| 113 |
regex: '(?=\\.)', |
| 114 |
next: 'pop' }, |
| 115 |
{ include: '#comment' }, |
| 116 |
{ include: '#expr' }, |
| 117 |
{ defaultToken: 'meta.rule.definition.prolog' }] }, |
| 118 |
{ defaultToken: 'meta.rule.prolog' }] }], |
| 119 |
'#statement': [{ token: 'meta.statement.prolog', |
| 120 |
regex: '(?=[a-z]\\w*\\()', |
| 121 |
push: [{ token: 'punctuation.end.statement.parameters.prolog', |
| 122 |
regex: '\\)', |
| 123 |
next: 'pop' }, |
| 124 |
{ include: '#builtins' }, |
| 125 |
{ include: '#atom' }, |
| 126 |
{ token: 'punctuation.begin.statement.parameters.prolog', |
| 127 |
regex: '\\(', |
| 128 |
push: [{ token: 'meta.statement.parameters.prolog', |
| 129 |
regex: '(?=\\))', |
| 130 |
next: 'pop' }, |
| 131 |
{ token: 'punctuation.separator.statement.prolog', regex: ',' }, |
| 132 |
{ include: '#basic_elem' }, |
| 133 |
{ defaultToken: 'meta.statement.parameters.prolog' }] }, |
| 134 |
{ defaultToken: 'meta.statement.prolog' }] }], |
| 135 |
'#string': [{ token: 'punctuation.definition.string.begin.prolog', |
| 136 |
regex: '\'', |
| 137 |
push: [{ token: 'punctuation.definition.string.end.prolog', |
| 138 |
regex: '\'', |
| 139 |
next: 'pop' }, |
| 140 |
{ token: 'constant.character.escape.prolog', regex: '\\\\.' }, |
| 141 |
{ token: 'constant.character.escape.quote.prolog', |
| 142 |
regex: '\'\'' }, |
| 143 |
{ defaultToken: 'string.quoted.single.prolog' }] }], |
| 144 |
'#variable': [{ token: 'variable.language.anonymous.prolog', |
| 145 |
regex: '\\b_\\b' }, |
| 146 |
{ token: 'variable.other.prolog', |
| 147 |
regex: '\\b[A-Z_][a-zA-Z0-9_]*\\b' }] }; |
| 148 |
this.normalizeRules(); |
| 149 |
}; |
| 150 |
PrologHighlightRules.metaData = { fileTypes: ['plg', 'prolog'], |
| 151 |
foldingStartMarker: '(%\\s*region \\w*)|([a-z]\\w*.*:- ?)', |
| 152 |
foldingStopMarker: '(%\\s*end(\\s*region)?)|(?=\\.)', |
| 153 |
keyEquivalent: '^~P', |
| 154 |
name: 'Prolog', |
| 155 |
scopeName: 'source.prolog' }; |
| 156 |
oop.inherits(PrologHighlightRules, TextHighlightRules); |
| 157 |
exports.PrologHighlightRules = PrologHighlightRules; |
| 158 |
|
| 159 |
}); |
| 160 |
|
| 161 |
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict"; |
| 162 |
var oop = require("../../lib/oop"); |
| 163 |
var Range = require("../../range").Range; |
| 164 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 165 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 166 |
if (commentRegex) { |
| 167 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 168 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 169 |
} |
| 170 |
}; |
| 171 |
oop.inherits(FoldMode, BaseFoldMode); |
| 172 |
(function () { |
| 173 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 174 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 175 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 176 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 177 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 178 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 179 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 180 |
var line = session.getLine(row); |
| 181 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 182 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 183 |
return ""; |
| 184 |
} |
| 185 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 186 |
if (!fw && this.startRegionRe.test(line)) |
| 187 |
return "start"; |
| 188 |
return fw; |
| 189 |
}; |
| 190 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 191 |
var line = session.getLine(row); |
| 192 |
if (this.startRegionRe.test(line)) |
| 193 |
return this.getCommentRegionBlock(session, line, row); |
| 194 |
var match = line.match(this.foldingStartMarker); |
| 195 |
if (match) { |
| 196 |
var i = match.index; |
| 197 |
if (match[1]) |
| 198 |
return this.openingBracketBlock(session, match[1], row, i); |
| 199 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 200 |
if (range && !range.isMultiLine()) { |
| 201 |
if (forceMultiline) { |
| 202 |
range = this.getSectionRange(session, row); |
| 203 |
} |
| 204 |
else if (foldStyle != "all") |
| 205 |
range = null; |
| 206 |
} |
| 207 |
return range; |
| 208 |
} |
| 209 |
if (foldStyle === "markbegin") |
| 210 |
return; |
| 211 |
var match = line.match(this.foldingStopMarker); |
| 212 |
if (match) { |
| 213 |
var i = match.index + match[0].length; |
| 214 |
if (match[1]) |
| 215 |
return this.closingBracketBlock(session, match[1], row, i); |
| 216 |
return session.getCommentFoldRange(row, i, -1); |
| 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 |
if (subRange) { |
| 236 |
if (subRange.start.row <= startRow) { |
| 237 |
break; |
| 238 |
} |
| 239 |
else if (subRange.isMultiLine()) { |
| 240 |
row = subRange.end.row; |
| 241 |
} |
| 242 |
else if (startIndent == indent) { |
| 243 |
break; |
| 244 |
} |
| 245 |
} |
| 246 |
endRow = row; |
| 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 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 255 |
var depth = 1; |
| 256 |
while (++row < maxRow) { |
| 257 |
line = session.getLine(row); |
| 258 |
var m = re.exec(line); |
| 259 |
if (!m) |
| 260 |
continue; |
| 261 |
if (m[1]) |
| 262 |
depth--; |
| 263 |
else |
| 264 |
depth++; |
| 265 |
if (!depth) |
| 266 |
break; |
| 267 |
} |
| 268 |
var endRow = row; |
| 269 |
if (endRow > startRow) { |
| 270 |
return new Range(startRow, startColumn, endRow, line.length); |
| 271 |
} |
| 272 |
}; |
| 273 |
}).call(FoldMode.prototype); |
| 274 |
|
| 275 |
}); |
| 276 |
|
| 277 |
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){ |
| 278 |
|
| 279 |
|
| 280 |
"use strict"; |
| 281 |
var oop = require("../lib/oop"); |
| 282 |
var TextMode = require("./text").Mode; |
| 283 |
var PrologHighlightRules = require("./prolog_highlight_rules").PrologHighlightRules; |
| 284 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 285 |
var Mode = function () { |
| 286 |
this.HighlightRules = PrologHighlightRules; |
| 287 |
this.foldingRules = new FoldMode(); |
| 288 |
this.$behaviour = this.$defaultBehaviour; |
| 289 |
}; |
| 290 |
oop.inherits(Mode, TextMode); |
| 291 |
(function () { |
| 292 |
this.lineCommentStart = "%"; |
| 293 |
this.blockComment = { start: "/*", end: "*/" }; |
| 294 |
this.$id = "ace/mode/prolog"; |
| 295 |
}).call(Mode.prototype); |
| 296 |
exports.Mode = Mode; |
| 297 |
|
| 298 |
}); (function() { |
| 299 |
ace.require(["ace/mode/prolog"], function(m) { |
| 300 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 301 |
module.exports = m; |
| 302 |
} |
| 303 |
}); |
| 304 |
})(); |
| 305 |
|