5343fc74a2893a130daa6ff1bff15621.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. ace.define("ace/mode/red_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 RedHighlightRules = function () {
  5. var compoundKeywords = "";
  6. this.$rules = {
  7. "start": [
  8. { token: "keyword.operator",
  9. regex: /\s([\-+%/=<>*]|(?:\*\*\|\/\/|==|>>>?|<>|<<|=>|<=|=\?))(\s|(?=:))/ },
  10. { token: "string.email", regex: /\w[-\w._]*\@\w[-\w._]*/ },
  11. { token: "value.time", regex: /\b\d+:\d+(:\d+)?/ },
  12. { token: "string.url", regex: /\w[-\w_]*\:(\/\/)?\w[-\w._]*(:\d+)?/ },
  13. { token: "value.date", regex: /(\b\d{1,4}[-/]\d{1,2}[-/]\d{1,2}|\d{1,2}[-/]\d{1,2}[-/]\d{1,4})\b/ },
  14. { token: "value.tuple", regex: /\b\d{1,3}\.\d{1,3}\.\d{1,3}(\.\d{1,3}){0,9}/ },
  15. { token: "value.pair", regex: /[+-]?\d+x[-+]?\d+/ },
  16. { token: "value.binary", regex: /\b2#{([01]{8})+}/ },
  17. { token: "value.binary", regex: /\b64#{([\w/=+])+}/ },
  18. { token: "value.binary", regex: /(16)?#{([\dabcdefABCDEF][\dabcdefABCDEF])*}/ },
  19. { token: "value.issue", regex: /#\w[-\w'*.]*/ },
  20. { token: "value.numeric", regex: /[+-]?\d['\d]*(?:\.\d+)?e[-+]?\d{1,3}\%?(?!\w)/ },
  21. { token: "invalid.illegal", regex: /[+-]?\d['\d]*(?:\.\d+)?\%?[a-zA-Z]/ },
  22. { token: "value.numeric", regex: /[+-]?\d['\d]*(?:\.\d+)?\%?(?![a-zA-Z])/ },
  23. { token: "value.character", regex: /#"(\^[-@/_~^"HKLM\[]|.)"/ },
  24. { token: "string.file", regex: /%[-\w\.\/]+/ },
  25. { token: "string.tag", regex: /</, next: "tag" },
  26. { token: "string", regex: /"/, next: "string" },
  27. { token: "string.other", regex: "{", next: "string.other" },
  28. { token: "comment", regex: "comment [{]", next: "comment" },
  29. { token: "comment", regex: /;.+$/ },
  30. { token: "paren.map-start", regex: "#\\(" },
  31. { token: "paren.block-start", regex: "[\\[]" },
  32. { token: "paren.block-end", regex: "[\\]]" },
  33. { token: "paren.parens-start", regex: "[(]" },
  34. { token: "paren.parens-end", regex: "\\)" },
  35. { token: "keyword", regex: "/local|/external" },
  36. { token: "keyword.preprocessor", regex: "#(if|either|" +
  37. "switch|case|include|do|macrolocal|reset|process|trace)" },
  38. { token: "constant.datatype!", regex: "(?:datatype|unset|none|logic|block|paren|string|" +
  39. "file|url|char|integer|float|word|set-word|lit-word|" +
  40. "get-word|refinement|issue|native|action|op|function|" +
  41. "path|lit-path|set-path|get-path|routine|bitset|point|" +
  42. "object|typeset|error|vector|hash|pair|percent|tuple|" +
  43. "map|binary|time|tag|email|handle|date|image|event|" +
  44. "series|any-type|number|any-object|scalar|" +
  45. "any-string|any-word|any-function|any-block|any-list|" +
  46. "any-path|immediate|all-word|internal|external|default)!(?![-!?\\w~])" },
  47. { token: "keyword.function", regex: "\\b(?:collect|quote|on-parse-event|math|last|source|expand|" +
  48. "show|context|object|input|quit|dir|make-dir|cause-error|" +
  49. "error\\?|none\\?|block\\?|any-list\\?|word\\?|char\\?|" +
  50. "any-string\\?|series\\?|binary\\?|attempt|url\\?|" +
  51. "string\\?|suffix\\?|file\\?|object\\?|body-of|first|" +
  52. "second|third|mod|clean-path|dir\\?|to-red-file|" +
  53. "normalize-dir|list-dir|pad|empty\\?|dirize|offset\\?|" +
  54. "what-dir|expand-directives|load|split-path|change-dir|" +
  55. "to-file|path-thru|save|load-thru|View|float\\?|to-float|" +
  56. "charset|\\?|probe|set-word\\?|q|words-of|replace|repend|" +
  57. "react|function\\?|spec-of|unset\\?|halt|op\\?|" +
  58. "any-function\\?|to-paren|tag\\?|routine|class-of|" +
  59. "size-text|draw|handle\\?|link-tabs-to-parent|" +
  60. "link-sub-to-parent|on-face-deep-change*|" +
  61. "update-font-faces|do-actor|do-safe|do-events|pair\\?|" +
  62. "foreach-face|hex-to-rgb|issue\\?|alter|path\\?|" +
  63. "typeset\\?|datatype\\?|set-flag|layout|extract|image\\?|" +
  64. "get-word\\?|to-logic|to-set-word|to-block|center-face|" +
  65. "dump-face|request-font|request-file|request-dir|rejoin|" +
  66. "ellipsize-at|any-block\\?|any-object\\?|map\\?|keys-of|" +
  67. "a-an|also|parse-func-spec|help-string|what|routine\\?|" +
  68. "action\\?|native\\?|refinement\\?|common-substr|" +
  69. "red-complete-file|red-complete-path|unview|comment|\\?\\?|" +
  70. "fourth|fifth|values-of|bitset\\?|email\\?|get-path\\?|" +
  71. "hash\\?|integer\\?|lit-path\\?|lit-word\\?|logic\\?|" +
  72. "paren\\?|percent\\?|set-path\\?|time\\?|tuple\\?|date\\?|" +
  73. "vector\\?|any-path\\?|any-word\\?|number\\?|immediate\\?|" +
  74. "scalar\\?|all-word\\?|to-bitset|to-binary|to-char|to-email|" +
  75. "to-get-path|to-get-word|to-hash|to-integer|to-issue|" +
  76. "to-lit-path|to-lit-word|to-map|to-none|to-pair|to-path|" +
  77. "to-percent|to-refinement|to-set-path|to-string|to-tag|" +
  78. "to-time|to-typeset|to-tuple|to-unset|to-url|to-word|" +
  79. "to-image|to-date|parse-trace|modulo|eval-set-path|" +
  80. "extract-boot-args|flip-exe-flag|split|do-file|" +
  81. "exists-thru\\?|read-thru|do-thru|cos|sin|tan|acos|asin|" +
  82. "atan|atan2|sqrt|clear-reactions|dump-reactions|react\\?|" +
  83. "within\\?|overlap\\?|distance\\?|face\\?|metrics\\?|" +
  84. "get-scroller|insert-event-func|remove-event-func|" +
  85. "set-focus|help|fetch-help|about|ls|ll|pwd|cd|" +
  86. "red-complete-input|matrix)(?![-!?\\w~])" },
  87. { token: "keyword.action", regex: "\\b(?:to|remove|copy|insert|change|clear|move|poke|put|" +
  88. "random|reverse|sort|swap|take|trim|add|subtract|" +
  89. "divide|multiply|make|reflect|form|mold|modify|" +
  90. "absolute|negate|power|remainder|round|even\\?|odd\\?|" +
  91. "and~|complement|or~|xor~|append|at|back|find|skip|" +
  92. "tail|head|head\\?|index\\?|length\\?|next|pick|" +
  93. "select|tail\\?|delete|read|write)(?![-_!?\\w~])"
  94. },
  95. { token: "keyword.native", regex: "\\b(?:not|any|set|uppercase|lowercase|checksum|" +
  96. "try|catch|browse|throw|all|as|" +
  97. "remove-each|func|function|does|has|do|reduce|" +
  98. "compose|get|print|prin|equal\\?|not-equal\\?|" +
  99. "strict-equal\\?|lesser\\?|greater\\?|lesser-or-equal\\?|" +
  100. "greater-or-equal\\?|same\\?|type\\?|stats|bind|in|parse|" +
  101. "union|unique|intersect|difference|exclude|" +
  102. "complement\\?|dehex|negative\\?|positive\\?|max|min|" +
  103. "shift|to-hex|sine|cosine|tangent|arcsine|arccosine|" +
  104. "arctangent|arctangent2|NaN\\?|zero\\?|log-2|log-10|log-e|" +
  105. "exp|square-root|construct|value\\?|as-pair|" +
  106. "extend|debase|enbase|to-local-file|" +
  107. "wait|unset|new-line|new-line\\?|context\\?|set-env|" +
  108. "get-env|list-env|now|sign\\?|call|size\\?)(?![-!?\\w~])"
  109. },
  110. { token: "keyword", regex: "\\b(?:Red(?=\\s+\\[)|object|context|make|self|keep)(?![-!?\\w~])"
  111. },
  112. { token: "variable.language", regex: "this" },
  113. { token: "keyword.control", regex: "(?:while|if|return|case|unless|either|until|loop|repeat|" +
  114. "forever|foreach|forall|switch|break|continue|exit)(?![-!?\\w~])" },
  115. { token: "constant.language", regex: "\\b(?:true|false|on|off|yes|none|no)(?![-!?\\w~])" },
  116. { token: "constant.numeric", regex: /\bpi(?![^-_])/ },
  117. { token: "constant.character", regex: "\\b(space|tab|newline|cr|lf)(?![-!?\\w~])" },
  118. { token: "keyword.operator", regex: "\s(or|and|xor|is)\s" },
  119. { token: "variable.get-path", regex: /:\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
  120. { token: "variable.set-path", regex: /\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*:/ },
  121. { token: "variable.lit-path", regex: /'\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
  122. { token: "variable.path", regex: /\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
  123. { token: "variable.refinement", regex: /\/\w[-\w'*.?!]*/ },
  124. { token: "keyword.view.style", regex: "\\b(?:window|base|button|text|field|area|check|" +
  125. "radio|progress|slider|camera|text-list|" +
  126. "drop-list|drop-down|panel|group-box|" +
  127. "tab-panel|h1|h2|h3|h4|h5|box|image|init)(?![-!?\\w~])" },
  128. { token: "keyword.view.event", regex: "\\b(?:detect|on-detect|time|on-time|drawing|on-drawing|" +
  129. "scroll|on-scroll|down|on-down|up|on-up|mid-down|" +
  130. "on-mid-down|mid-up|on-mid-up|alt-down|on-alt-down|" +
  131. "alt-up|on-alt-up|aux-down|on-aux-down|aux-up|" +
  132. "on-aux-up|wheel|on-wheel|drag-start|on-drag-start|" +
  133. "drag|on-drag|drop|on-drop|click|on-click|dbl-click|" +
  134. "on-dbl-click|over|on-over|key|on-key|key-down|" +
  135. "on-key-down|key-up|on-key-up|ime|on-ime|focus|" +
  136. "on-focus|unfocus|on-unfocus|select|on-select|" +
  137. "change|on-change|enter|on-enter|menu|on-menu|close|" +
  138. "on-close|move|on-move|resize|on-resize|moving|" +
  139. "on-moving|resizing|on-resizing|zoom|on-zoom|pan|" +
  140. "on-pan|rotate|on-rotate|two-tap|on-two-tap|" +
  141. "press-tap|on-press-tap|create|on-create|created|on-created)(?![-!?\\w~])" },
  142. { token: "keyword.view.option", regex: "\\b(?:all-over|center|color|default|disabled|down|" +
  143. "flags|focus|font|font-color|font-name|" +
  144. "font-size|hidden|hint|left|loose|name|" +
  145. "no-border|now|rate|react|select|size|space)(?![-!?\\w~])" },
  146. { token: "constant.other.colour", regex: "\\b(?:Red|white|transparent|" +
  147. "black|gray|aqua|beige|blue|brick|brown|coal|coffee|" +
  148. "crimson|cyan|forest|gold|green|ivory|khaki|leaf|linen|" +
  149. "magenta|maroon|mint|navy|oldrab|olive|orange|papaya|" +
  150. "pewter|pink|purple|reblue|rebolor|sienna|silver|sky|" +
  151. "snow|tanned|teal|violet|water|wheat|yello|yellow|glass)(?![-!?\\w~])" },
  152. { token: "variable.get-word", regex: /\:\w[-\w'*.?!]*/ },
  153. { token: "variable.set-word", regex: /\w[-\w'*.?!]*\:/ },
  154. { token: "variable.lit-word", regex: /'\w[-\w'*.?!]*/ },
  155. { token: "variable.word", regex: /\b\w+[-\w'*.!?]*/ },
  156. { caseInsensitive: true }
  157. ],
  158. "string": [
  159. { token: "string", regex: /"/, next: "start" },
  160. { defaultToken: "string" }
  161. ],
  162. "string.other": [
  163. { token: "string.other", regex: /}/, next: "start" },
  164. { defaultToken: "string.other" }
  165. ],
  166. "tag": [
  167. { token: "string.tag", regex: />/, next: "start" },
  168. { defaultToken: "string.tag" }
  169. ],
  170. "comment": [
  171. { token: "comment", regex: /}/, next: "start" },
  172. { defaultToken: "comment" }
  173. ]
  174. };
  175. };
  176. oop.inherits(RedHighlightRules, TextHighlightRules);
  177. exports.RedHighlightRules = RedHighlightRules;
  178. });
  179. 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";
  180. var oop = require("../../lib/oop");
  181. var Range = require("../../range").Range;
  182. var BaseFoldMode = require("./fold_mode").FoldMode;
  183. var FoldMode = exports.FoldMode = function (commentRegex) {
  184. if (commentRegex) {
  185. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  186. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  187. }
  188. };
  189. oop.inherits(FoldMode, BaseFoldMode);
  190. (function () {
  191. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  192. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  193. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  194. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  195. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  196. this._getFoldWidgetBase = this.getFoldWidget;
  197. this.getFoldWidget = function (session, foldStyle, row) {
  198. var line = session.getLine(row);
  199. if (this.singleLineBlockCommentRe.test(line)) {
  200. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  201. return "";
  202. }
  203. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  204. if (!fw && this.startRegionRe.test(line))
  205. return "start"; // lineCommentRegionStart
  206. return fw;
  207. };
  208. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  209. var line = session.getLine(row);
  210. if (this.startRegionRe.test(line))
  211. return this.getCommentRegionBlock(session, line, row);
  212. var match = line.match(this.foldingStartMarker);
  213. if (match) {
  214. var i = match.index;
  215. if (match[1])
  216. return this.openingBracketBlock(session, match[1], row, i);
  217. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  218. if (range && !range.isMultiLine()) {
  219. if (forceMultiline) {
  220. range = this.getSectionRange(session, row);
  221. }
  222. else if (foldStyle != "all")
  223. range = null;
  224. }
  225. return range;
  226. }
  227. if (foldStyle === "markbegin")
  228. return;
  229. var match = line.match(this.foldingStopMarker);
  230. if (match) {
  231. var i = match.index + match[0].length;
  232. if (match[1])
  233. return this.closingBracketBlock(session, match[1], row, i);
  234. return session.getCommentFoldRange(row, i, -1);
  235. }
  236. };
  237. this.getSectionRange = function (session, row) {
  238. var line = session.getLine(row);
  239. var startIndent = line.search(/\S/);
  240. var startRow = row;
  241. var startColumn = line.length;
  242. row = row + 1;
  243. var endRow = row;
  244. var maxRow = session.getLength();
  245. while (++row < maxRow) {
  246. line = session.getLine(row);
  247. var indent = line.search(/\S/);
  248. if (indent === -1)
  249. continue;
  250. if (startIndent > indent)
  251. break;
  252. var subRange = this.getFoldWidgetRange(session, "all", row);
  253. if (subRange) {
  254. if (subRange.start.row <= startRow) {
  255. break;
  256. }
  257. else if (subRange.isMultiLine()) {
  258. row = subRange.end.row;
  259. }
  260. else if (startIndent == indent) {
  261. break;
  262. }
  263. }
  264. endRow = row;
  265. }
  266. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  267. };
  268. this.getCommentRegionBlock = function (session, line, row) {
  269. var startColumn = line.search(/\s*$/);
  270. var maxRow = session.getLength();
  271. var startRow = row;
  272. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  273. var depth = 1;
  274. while (++row < maxRow) {
  275. line = session.getLine(row);
  276. var m = re.exec(line);
  277. if (!m)
  278. continue;
  279. if (m[1])
  280. depth--;
  281. else
  282. depth++;
  283. if (!depth)
  284. break;
  285. }
  286. var endRow = row;
  287. if (endRow > startRow) {
  288. return new Range(startRow, startColumn, endRow, line.length);
  289. }
  290. };
  291. }).call(FoldMode.prototype);
  292. });
  293. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  294. var Range = require("../range").Range;
  295. var MatchingBraceOutdent = function () { };
  296. (function () {
  297. this.checkOutdent = function (line, input) {
  298. if (!/^\s+$/.test(line))
  299. return false;
  300. return /^\s*\}/.test(input);
  301. };
  302. this.autoOutdent = function (doc, row) {
  303. var line = doc.getLine(row);
  304. var match = line.match(/^(\s*\})/);
  305. if (!match)
  306. return 0;
  307. var column = match[1].length;
  308. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  309. if (!openBracePos || openBracePos.row == row)
  310. return 0;
  311. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  312. doc.replace(new Range(row, 0, row, column - 1), indent);
  313. };
  314. this.$getIndent = function (line) {
  315. return line.match(/^\s*/)[0];
  316. };
  317. }).call(MatchingBraceOutdent.prototype);
  318. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  319. });
  320. ace.define("ace/mode/red",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/red_highlight_rules","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent","ace/range"], function(require, exports, module){"use strict";
  321. var oop = require("../lib/oop");
  322. var TextMode = require("./text").Mode;
  323. var RedHighlightRules = require("./red_highlight_rules").RedHighlightRules;
  324. var RedFoldMode = require("./folding/cstyle").FoldMode;
  325. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  326. var Range = require("../range").Range;
  327. var Mode = function () {
  328. this.HighlightRules = RedHighlightRules;
  329. this.foldingRules = new RedFoldMode();
  330. this.$outdent = new MatchingBraceOutdent();
  331. this.$behaviour = this.$defaultBehaviour;
  332. };
  333. oop.inherits(Mode, TextMode);
  334. (function () {
  335. this.lineCommentStart = ";";
  336. this.blockComment = { start: "comment {", end: "}" };
  337. this.getNextLineIndent = function (state, line, tab) {
  338. var indent = this.$getIndent(line);
  339. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  340. var tokens = tokenizedLine.tokens;
  341. var endState = tokenizedLine.state;
  342. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  343. return indent;
  344. }
  345. if (state == "start") {
  346. var match = line.match(/^.*[\{\[\(]\s*$/);
  347. if (match) {
  348. indent += tab;
  349. }
  350. }
  351. else if (state == "doc-start") {
  352. if (endState == "start") {
  353. return "";
  354. }
  355. var match = line.match(/^\s*(\/?)\*/);
  356. if (match) {
  357. if (match[1]) {
  358. indent += " ";
  359. }
  360. indent += "* ";
  361. }
  362. }
  363. return indent;
  364. };
  365. this.checkOutdent = function (state, line, input) {
  366. return this.$outdent.checkOutdent(line, input);
  367. };
  368. this.autoOutdent = function (state, doc, row) {
  369. this.$outdent.autoOutdent(doc, row);
  370. };
  371. this.$id = "ace/mode/red";
  372. }).call(Mode.prototype);
  373. exports.Mode = Mode;
  374. }); (function() {
  375. ace.require(["ace/mode/red"], function(m) {
  376. if (typeof module == "object" && typeof exports == "object" && module) {
  377. module.exports = m;
  378. }
  379. });
  380. })();