a861e5537ad18a87bd993445c930764c.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. ace.define("ace/mode/logtalk_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var LogtalkHighlightRules = function () {
  5. this.$rules = { start: [{ token: 'punctuation.definition.comment.logtalk',
  6. regex: '/\\*',
  7. push: [{ token: 'punctuation.definition.comment.logtalk',
  8. regex: '\\*/',
  9. next: 'pop' },
  10. { defaultToken: 'comment.block.logtalk' }] },
  11. { todo: 'fix grouping',
  12. token: ['comment.line.percentage.logtalk',
  13. 'punctuation.definition.comment.logtalk'],
  14. regex: '%.*$\\n?' },
  15. { todo: 'fix grouping',
  16. token: ['storage.type.opening.logtalk',
  17. 'punctuation.definition.storage.type.logtalk'],
  18. regex: ':-\\s(?:object|protocol|category|module)(?=[(])' },
  19. { todo: 'fix grouping',
  20. token: ['storage.type.closing.logtalk',
  21. 'punctuation.definition.storage.type.logtalk'],
  22. regex: ':-\\send_(?:object|protocol|category)(?=[.])' },
  23. { caseInsensitive: false,
  24. token: 'storage.type.relations.logtalk',
  25. regex: '\\b(?:complements|extends|i(?:nstantiates|mp(?:orts|lements))|specializes)(?=[(])' },
  26. { caseInsensitive: false,
  27. todo: 'fix grouping',
  28. token: ['storage.modifier.others.logtalk',
  29. 'punctuation.definition.storage.modifier.logtalk'],
  30. regex: ':-\\s(?:e(?:lse|ndif)|built_in|dynamic|synchronized|threaded)(?=[.])' },
  31. { caseInsensitive: false,
  32. todo: 'fix grouping',
  33. token: ['storage.modifier.others.logtalk',
  34. 'punctuation.definition.storage.modifier.logtalk'],
  35. regex: ':-\\s(?:c(?:alls|oinductive)|e(?:lif|n(?:coding|sure_loaded)|xport)|i(?:f|n(?:clude|itialization|fo))|reexport|set_(?:logtalk|prolog)_flag|uses)(?=[(])' },
  36. { caseInsensitive: false,
  37. todo: 'fix grouping',
  38. token: ['storage.modifier.others.logtalk',
  39. 'punctuation.definition.storage.modifier.logtalk'],
  40. regex: ':-\\s(?:alias|info|d(?:ynamic|iscontiguous)|m(?:eta_(?:non_terminal|predicate)|ode|ultifile)|p(?:ublic|r(?:otected|ivate))|op|use(?:s|_module)|synchronized)(?=[(])' },
  41. { token: 'keyword.operator.message-sending.logtalk',
  42. regex: '(:|::|\\^\\^)' },
  43. { token: 'keyword.operator.external-call.logtalk',
  44. regex: '([{}])' },
  45. { token: 'keyword.operator.mode.logtalk', regex: '(\\?|@)' },
  46. { token: 'keyword.operator.comparison.term.logtalk',
  47. regex: '(@=<|@<|@>|@>=|==|\\\\==)' },
  48. { token: 'keyword.operator.comparison.arithmetic.logtalk',
  49. regex: '(=<|<|>|>=|=:=|=\\\\=)' },
  50. { token: 'keyword.operator.bitwise.logtalk',
  51. regex: '(<<|>>|/\\\\|\\\\/|\\\\)' },
  52. { token: 'keyword.operator.evaluable.logtalk',
  53. regex: '\\b(?:e|pi|div|mod|rem)\\b(?![-!(^~])' },
  54. { token: 'keyword.operator.evaluable.logtalk',
  55. regex: '(\\*\\*|\\+|-|\\*|/|//)' },
  56. { token: 'keyword.operator.misc.logtalk',
  57. regex: '(:-|!|\\\\+|,|;|-->|->|=|\\=|\\.|=\\.\\.|\\^|\\bas\\b|\\bis\\b)' },
  58. { caseInsensitive: false,
  59. token: 'support.function.evaluable.logtalk',
  60. regex: '\\b(a(bs|cos|sin|tan|tan2)|c(eiling|os)|div|exp|flo(at(_(integer|fractional)_part)?|or)|log|m(ax|in|od)|r(em|ound)|s(i(n|gn)|qrt)|t(an|runcate)|xor)(?=[(])' },
  61. { token: 'support.function.control.logtalk',
  62. regex: '\\b(?:true|fa(?:il|lse)|repeat|(?:instantiation|system)_error)\\b(?![-!(^~])' },
  63. { token: 'support.function.control.logtalk',
  64. regex: '\\b((?:uninstantiation|type|domain|existence|permission|representation|evaluation|resource|syntax)_error)(?=[(])' },
  65. { token: 'support.function.control.logtalk',
  66. regex: '\\b(?:ca(?:ll|tch)|ignore|throw|once)(?=[(])' },
  67. { token: 'support.function.chars-and-bytes-io.logtalk',
  68. regex: '\\b(?:(?:get|p(?:eek|ut))_(c(?:har|ode)|byte)|nl)(?=[(])' },
  69. { token: 'support.function.chars-and-bytes-io.logtalk',
  70. regex: '\\bnl\\b' },
  71. { token: 'support.function.atom-term-processing.logtalk',
  72. regex: '\\b(?:atom_(?:length|c(?:hars|o(?:ncat|des)))|sub_atom|char_code|number_c(?:har|ode)s)(?=[(])' },
  73. { caseInsensitive: false,
  74. token: 'support.function.term-testing.logtalk',
  75. regex: '\\b(?:var|atom(ic)?|integer|float|c(?:allable|ompound)|n(?:onvar|umber)|ground|acyclic_term)(?=[(])' },
  76. { token: 'support.function.term-comparison.logtalk',
  77. regex: '\\b(compare)(?=[(])' },
  78. { token: 'support.function.term-io.logtalk',
  79. regex: '\\b(?:read(_term)?|write(?:q|_(?:canonical|term))?|(current_)?(?:char_conversion|op))(?=[(])' },
  80. { caseInsensitive: false,
  81. token: 'support.function.term-creation-and-decomposition.logtalk',
  82. regex: '\\b(arg|copy_term|functor|numbervars|term_variables)(?=[(])' },
  83. { caseInsensitive: false,
  84. token: 'support.function.term-unification.logtalk',
  85. regex: '\\b(subsumes_term|unify_with_occurs_check)(?=[(])' },
  86. { caseInsensitive: false,
  87. token: 'support.function.stream-selection-and-control.logtalk',
  88. regex: '\\b(?:(?:se|curren)t_(?:in|out)put|open|close|flush_output|stream_property|at_end_of_stream|set_stream_position)(?=[(])' },
  89. { token: 'support.function.stream-selection-and-control.logtalk',
  90. regex: '\\b(?:flush_output|at_end_of_stream)\\b' },
  91. { token: 'support.function.prolog-flags.logtalk',
  92. regex: '\\b((?:se|curren)t_prolog_flag)(?=[(])' },
  93. { token: 'support.function.compiling-and-loading.logtalk',
  94. regex: '\\b(logtalk_(?:compile|l(?:ibrary_path|oad|oad_context)|make(_target_action)?))(?=[(])' },
  95. { token: 'support.function.compiling-and-loading.logtalk',
  96. regex: '\\b(logtalk_make)\\b' },
  97. { caseInsensitive: false,
  98. token: 'support.function.event-handling.logtalk',
  99. regex: '\\b(?:(?:abolish|define)_events|current_event)(?=[(])' },
  100. { token: 'support.function.implementation-defined-hooks.logtalk',
  101. regex: '\\b(?:(?:create|current|set)_logtalk_flag|halt)(?=[(])' },
  102. { token: 'support.function.implementation-defined-hooks.logtalk',
  103. regex: '\\b(halt)\\b' },
  104. { token: 'support.function.sorting.logtalk',
  105. regex: '\\b((key)?(sort))(?=[(])' },
  106. { caseInsensitive: false,
  107. token: 'support.function.entity-creation-and-abolishing.logtalk',
  108. regex: '\\b((c(?:reate|urrent)|abolish)_(?:object|protocol|category))(?=[(])' },
  109. { caseInsensitive: false,
  110. token: 'support.function.reflection.logtalk',
  111. regex: '\\b((object|protocol|category)_property|co(mplements_object|nforms_to_protocol)|extends_(object|protocol|category)|imp(orts_category|lements_protocol)|(instantiat|specializ)es_class)(?=[(])' },
  112. { token: 'support.function.logtalk',
  113. regex: '\\b((?:for|retract)all)(?=[(])' },
  114. { caseInsensitive: false,
  115. token: 'support.function.execution-context.logtalk',
  116. regex: '\\b(?:context|parameter|se(?:lf|nder)|this)(?=[(])' },
  117. { token: 'support.function.database.logtalk',
  118. regex: '\\b(?:a(?:bolish|ssert(?:a|z))|clause|retract(all)?)(?=[(])' },
  119. { token: 'support.function.all-solutions.logtalk',
  120. regex: '\\b((?:bag|set)of|f(?:ind|or)all)(?=[(])' },
  121. { caseInsensitive: false,
  122. token: 'support.function.multi-threading.logtalk',
  123. regex: '\\b(threaded(_(ca(?:ll|ncel)|once|ignore|exit|peek|wait|notify))?)(?=[(])' },
  124. { caseInsensitive: false,
  125. token: 'support.function.engines.logtalk',
  126. regex: '\\b(threaded_engine(_(create|destroy|self|next(?:_reified)?|yield|post|fetch))?)(?=[(])' },
  127. { caseInsensitive: false,
  128. token: 'support.function.reflection.logtalk',
  129. regex: '\\b(?:current_predicate|predicate_property)(?=[(])' },
  130. { token: 'support.function.event-handler.logtalk',
  131. regex: '\\b(?:before|after)(?=[(])' },
  132. { token: 'support.function.message-forwarding-handler.logtalk',
  133. regex: '\\b(forward)(?=[(])' },
  134. { token: 'support.function.grammar-rule.logtalk',
  135. regex: '\\b(?:expand_(?:goal|term)|(?:goal|term)_expansion|phrase)(?=[(])' },
  136. { token: 'punctuation.definition.string.begin.logtalk',
  137. regex: '\'',
  138. push: [{ token: 'constant.character.escape.logtalk',
  139. regex: '\\\\([\\\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\\\)' },
  140. { token: 'punctuation.definition.string.end.logtalk',
  141. regex: '\'',
  142. next: 'pop' },
  143. { defaultToken: 'string.quoted.single.logtalk' }] },
  144. { token: 'punctuation.definition.string.begin.logtalk',
  145. regex: '"',
  146. push: [{ token: 'constant.character.escape.logtalk',
  147. regex: '\\\\([\\\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\\\)' },
  148. { token: 'punctuation.definition.string.end.logtalk',
  149. regex: '"',
  150. next: 'pop' },
  151. { defaultToken: 'string.quoted.double.logtalk' }] },
  152. { token: 'constant.numeric.logtalk',
  153. regex: '\\b(0b[0-1]+|0o[0-7]+|0x[0-9a-fA-F]+)\\b' },
  154. { token: 'constant.numeric.logtalk',
  155. regex: '\\b(0\'\\\\.|0\'.|0\'\'|0\'")' },
  156. { token: 'constant.numeric.logtalk',
  157. regex: '\\b(\\d+\\.?\\d*((e|E)(\\+|-)?\\d+)?)\\b' },
  158. { token: 'variable.other.logtalk',
  159. regex: '\\b([A-Z_][A-Za-z0-9_]*)\\b' }] };
  160. this.normalizeRules();
  161. };
  162. oop.inherits(LogtalkHighlightRules, TextHighlightRules);
  163. exports.LogtalkHighlightRules = LogtalkHighlightRules;
  164. });
  165. 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";
  166. var oop = require("../../lib/oop");
  167. var Range = require("../../range").Range;
  168. var BaseFoldMode = require("./fold_mode").FoldMode;
  169. var FoldMode = exports.FoldMode = function (commentRegex) {
  170. if (commentRegex) {
  171. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  172. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  173. }
  174. };
  175. oop.inherits(FoldMode, BaseFoldMode);
  176. (function () {
  177. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  178. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  179. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  180. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  181. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  182. this._getFoldWidgetBase = this.getFoldWidget;
  183. this.getFoldWidget = function (session, foldStyle, row) {
  184. var line = session.getLine(row);
  185. if (this.singleLineBlockCommentRe.test(line)) {
  186. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  187. return "";
  188. }
  189. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  190. if (!fw && this.startRegionRe.test(line))
  191. return "start"; // lineCommentRegionStart
  192. return fw;
  193. };
  194. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  195. var line = session.getLine(row);
  196. if (this.startRegionRe.test(line))
  197. return this.getCommentRegionBlock(session, line, row);
  198. var match = line.match(this.foldingStartMarker);
  199. if (match) {
  200. var i = match.index;
  201. if (match[1])
  202. return this.openingBracketBlock(session, match[1], row, i);
  203. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  204. if (range && !range.isMultiLine()) {
  205. if (forceMultiline) {
  206. range = this.getSectionRange(session, row);
  207. }
  208. else if (foldStyle != "all")
  209. range = null;
  210. }
  211. return range;
  212. }
  213. if (foldStyle === "markbegin")
  214. return;
  215. var match = line.match(this.foldingStopMarker);
  216. if (match) {
  217. var i = match.index + match[0].length;
  218. if (match[1])
  219. return this.closingBracketBlock(session, match[1], row, i);
  220. return session.getCommentFoldRange(row, i, -1);
  221. }
  222. };
  223. this.getSectionRange = function (session, row) {
  224. var line = session.getLine(row);
  225. var startIndent = line.search(/\S/);
  226. var startRow = row;
  227. var startColumn = line.length;
  228. row = row + 1;
  229. var endRow = row;
  230. var maxRow = session.getLength();
  231. while (++row < maxRow) {
  232. line = session.getLine(row);
  233. var indent = line.search(/\S/);
  234. if (indent === -1)
  235. continue;
  236. if (startIndent > indent)
  237. break;
  238. var subRange = this.getFoldWidgetRange(session, "all", row);
  239. if (subRange) {
  240. if (subRange.start.row <= startRow) {
  241. break;
  242. }
  243. else if (subRange.isMultiLine()) {
  244. row = subRange.end.row;
  245. }
  246. else if (startIndent == indent) {
  247. break;
  248. }
  249. }
  250. endRow = row;
  251. }
  252. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  253. };
  254. this.getCommentRegionBlock = function (session, line, row) {
  255. var startColumn = line.search(/\s*$/);
  256. var maxRow = session.getLength();
  257. var startRow = row;
  258. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  259. var depth = 1;
  260. while (++row < maxRow) {
  261. line = session.getLine(row);
  262. var m = re.exec(line);
  263. if (!m)
  264. continue;
  265. if (m[1])
  266. depth--;
  267. else
  268. depth++;
  269. if (!depth)
  270. break;
  271. }
  272. var endRow = row;
  273. if (endRow > startRow) {
  274. return new Range(startRow, startColumn, endRow, line.length);
  275. }
  276. };
  277. }).call(FoldMode.prototype);
  278. });
  279. ace.define("ace/mode/logtalk",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/logtalk_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  280. var oop = require("../lib/oop");
  281. var TextMode = require("./text").Mode;
  282. var Tokenizer = require("../tokenizer").Tokenizer;
  283. var LogtalkHighlightRules = require("./logtalk_highlight_rules").LogtalkHighlightRules;
  284. var FoldMode = require("./folding/cstyle").FoldMode;
  285. var Mode = function () {
  286. this.HighlightRules = LogtalkHighlightRules;
  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/logtalk";
  295. }).call(Mode.prototype);
  296. exports.Mode = Mode;
  297. }); (function() {
  298. ace.require(["ace/mode/logtalk"], function(m) {
  299. if (typeof module == "object" && typeof exports == "object" && module) {
  300. module.exports = m;
  301. }
  302. });
  303. })();