2dcf359bda4d96fcd06e8b0b7bc039bf.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. ace.define("ace/mode/prolog_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was autogenerated from https://raw.github.com/stephenroller/prolog-tmbundle/master/Syntaxes/Prolog.tmLanguage (uuid: ) */
  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. 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";
  160. var oop = require("../../lib/oop");
  161. var Range = require("../../range").Range;
  162. var BaseFoldMode = require("./fold_mode").FoldMode;
  163. var FoldMode = exports.FoldMode = function (commentRegex) {
  164. if (commentRegex) {
  165. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  166. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  167. }
  168. };
  169. oop.inherits(FoldMode, BaseFoldMode);
  170. (function () {
  171. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  172. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  173. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  174. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  175. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  176. this._getFoldWidgetBase = this.getFoldWidget;
  177. this.getFoldWidget = function (session, foldStyle, row) {
  178. var line = session.getLine(row);
  179. if (this.singleLineBlockCommentRe.test(line)) {
  180. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  181. return "";
  182. }
  183. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  184. if (!fw && this.startRegionRe.test(line))
  185. return "start"; // lineCommentRegionStart
  186. return fw;
  187. };
  188. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  189. var line = session.getLine(row);
  190. if (this.startRegionRe.test(line))
  191. return this.getCommentRegionBlock(session, line, row);
  192. var match = line.match(this.foldingStartMarker);
  193. if (match) {
  194. var i = match.index;
  195. if (match[1])
  196. return this.openingBracketBlock(session, match[1], row, i);
  197. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  198. if (range && !range.isMultiLine()) {
  199. if (forceMultiline) {
  200. range = this.getSectionRange(session, row);
  201. }
  202. else if (foldStyle != "all")
  203. range = null;
  204. }
  205. return range;
  206. }
  207. if (foldStyle === "markbegin")
  208. return;
  209. var match = line.match(this.foldingStopMarker);
  210. if (match) {
  211. var i = match.index + match[0].length;
  212. if (match[1])
  213. return this.closingBracketBlock(session, match[1], row, i);
  214. return session.getCommentFoldRange(row, i, -1);
  215. }
  216. };
  217. this.getSectionRange = function (session, row) {
  218. var line = session.getLine(row);
  219. var startIndent = line.search(/\S/);
  220. var startRow = row;
  221. var startColumn = line.length;
  222. row = row + 1;
  223. var endRow = row;
  224. var maxRow = session.getLength();
  225. while (++row < maxRow) {
  226. line = session.getLine(row);
  227. var indent = line.search(/\S/);
  228. if (indent === -1)
  229. continue;
  230. if (startIndent > indent)
  231. break;
  232. var subRange = this.getFoldWidgetRange(session, "all", row);
  233. if (subRange) {
  234. if (subRange.start.row <= startRow) {
  235. break;
  236. }
  237. else if (subRange.isMultiLine()) {
  238. row = subRange.end.row;
  239. }
  240. else if (startIndent == indent) {
  241. break;
  242. }
  243. }
  244. endRow = row;
  245. }
  246. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  247. };
  248. this.getCommentRegionBlock = function (session, line, row) {
  249. var startColumn = line.search(/\s*$/);
  250. var maxRow = session.getLength();
  251. var startRow = row;
  252. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  253. var depth = 1;
  254. while (++row < maxRow) {
  255. line = session.getLine(row);
  256. var m = re.exec(line);
  257. if (!m)
  258. continue;
  259. if (m[1])
  260. depth--;
  261. else
  262. depth++;
  263. if (!depth)
  264. break;
  265. }
  266. var endRow = row;
  267. if (endRow > startRow) {
  268. return new Range(startRow, startColumn, endRow, line.length);
  269. }
  270. };
  271. }).call(FoldMode.prototype);
  272. });
  273. 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){/*
  274. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  275. */
  276. "use strict";
  277. var oop = require("../lib/oop");
  278. var TextMode = require("./text").Mode;
  279. var PrologHighlightRules = require("./prolog_highlight_rules").PrologHighlightRules;
  280. var FoldMode = require("./folding/cstyle").FoldMode;
  281. var Mode = function () {
  282. this.HighlightRules = PrologHighlightRules;
  283. this.foldingRules = new FoldMode();
  284. this.$behaviour = this.$defaultBehaviour;
  285. };
  286. oop.inherits(Mode, TextMode);
  287. (function () {
  288. this.lineCommentStart = "%";
  289. this.blockComment = { start: "/*", end: "*/" };
  290. this.$id = "ace/mode/prolog";
  291. }).call(Mode.prototype);
  292. exports.Mode = Mode;
  293. }); (function() {
  294. ace.require(["ace/mode/prolog"], function(m) {
  295. if (typeof module == "object" && typeof exports == "object" && module) {
  296. module.exports = m;
  297. }
  298. });
  299. })();