49a6772f0e4c0ad12d9475bef3ec1dd4.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () {
  5. this.$rules = {
  6. "start": [{
  7. token: "comment.doc.tag",
  8. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  9. },
  10. DocCommentHighlightRules.getTagRule(),
  11. {
  12. defaultToken: "comment.doc",
  13. caseInsensitive: true
  14. }]
  15. };
  16. };
  17. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  18. DocCommentHighlightRules.getTagRule = function (start) {
  19. return {
  20. token: "comment.doc.tag.storage.type",
  21. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  22. };
  23. };
  24. DocCommentHighlightRules.getStartRule = function (start) {
  25. return {
  26. token: "comment.doc",
  27. regex: "\\/\\*(?=\\*)",
  28. next: start
  29. };
  30. };
  31. DocCommentHighlightRules.getEndRule = function (start) {
  32. return {
  33. token: "comment.doc",
  34. regex: "\\*\\/",
  35. next: start
  36. };
  37. };
  38. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  39. });
  40. ace.define("ace/mode/d_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  41. var oop = require("../lib/oop");
  42. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  43. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  44. var DHighlightRules = function () {
  45. var keywords = ("this|super|import|module|body|mixin|__traits|invariant|alias|asm|delete|" +
  46. "typeof|typeid|sizeof|cast|new|in|is|typedef|__vector|__parameters");
  47. var keywordControls = ("break|case|continue|default|do|else|for|foreach|foreach_reverse|goto|if|" +
  48. "return|switch|while|catch|try|throw|finally|version|assert|unittest|with");
  49. var types = ("auto|bool|char|dchar|wchar|byte|ubyte|float|double|real|" +
  50. "cfloat|creal|cdouble|cent|ifloat|ireal|idouble|" +
  51. "int|long|short|void|uint|ulong|ushort|ucent|" +
  52. "function|delegate|string|wstring|dstring|size_t|ptrdiff_t|hash_t|Object");
  53. var modifiers = ("abstract|align|debug|deprecated|export|extern|const|final|in|inout|out|" +
  54. "ref|immutable|lazy|nothrow|override|package|pragma|private|protected|" +
  55. "public|pure|scope|shared|__gshared|synchronized|static|volatile");
  56. var storages = ("class|struct|union|template|interface|enum|macro");
  57. var stringEscapesSeq = {
  58. token: "constant.language.escape",
  59. regex: "\\\\(?:(?:x[0-9A-F]{2})|(?:[0-7]{1,3})|(?:['\"\\?0abfnrtv\\\\])|" +
  60. "(?:u[0-9a-fA-F]{4})|(?:U[0-9a-fA-F]{8}))"
  61. };
  62. var builtinConstants = ("null|true|false|" +
  63. "__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__|" +
  64. "__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__");
  65. var operators = ("/|/\\=|&|&\\=|&&|\\|\\|\\=|\\|\\||\\-|\\-\\=|\\-\\-|\\+|" +
  66. "\\+\\=|\\+\\+|\\<|\\<\\=|\\<\\<|\\<\\<\\=|\\<\\>|\\<\\>\\=|\\>|\\>\\=|\\>\\>\\=|" +
  67. "\\>\\>\\>\\=|\\>\\>|\\>\\>\\>|\\!|\\!\\=|\\!\\<\\>|\\!\\<\\>\\=|\\!\\<|\\!\\<\\=|" +
  68. "\\!\\>|\\!\\>\\=|\\?|\\$|\\=|\\=\\=|\\*|\\*\\=|%|%\\=|" +
  69. "\\^|\\^\\=|\\^\\^|\\^\\^\\=|~|~\\=|\\=\\>|#");
  70. var keywordMapper = this.$keywords = this.createKeywordMapper({
  71. "keyword.modifier": modifiers,
  72. "keyword.control": keywordControls,
  73. "keyword.type": types,
  74. "keyword": keywords,
  75. "keyword.storage": storages,
  76. "punctation": "\\.|\\,|;|\\.\\.|\\.\\.\\.",
  77. "keyword.operator": operators,
  78. "constant.language": builtinConstants
  79. }, "identifier");
  80. var identifierRe = "[a-zA-Z_\u00a1-\uffff][a-zA-Z\\d_\u00a1-\uffff]*\\b";
  81. this.$rules = {
  82. "start": [
  83. {
  84. token: "comment",
  85. regex: "\\/\\/.*$"
  86. },
  87. DocCommentHighlightRules.getStartRule("doc-start"),
  88. {
  89. token: "comment",
  90. regex: "\\/\\*",
  91. next: "star-comment"
  92. }, {
  93. token: "comment.shebang",
  94. regex: "^\\s*#!.*"
  95. }, {
  96. token: "comment",
  97. regex: "\\/\\+",
  98. next: "plus-comment"
  99. }, {
  100. onMatch: function (value, currentState, state) {
  101. state.unshift(this.next, value.substr(2));
  102. return "string";
  103. },
  104. regex: 'q"(?:[\\[\\(\\{\\<]+)',
  105. next: 'operator-heredoc-string'
  106. }, {
  107. onMatch: function (value, currentState, state) {
  108. state.unshift(this.next, value.substr(2));
  109. return "string";
  110. },
  111. regex: 'q"(?:[a-zA-Z_]+)$',
  112. next: 'identifier-heredoc-string'
  113. }, {
  114. token: "string",
  115. regex: '[xr]?"',
  116. next: "quote-string"
  117. }, {
  118. token: "string",
  119. regex: '[xr]?`',
  120. next: "backtick-string"
  121. }, {
  122. token: "string",
  123. regex: "[xr]?['](?:(?:\\\\.)|(?:[^'\\\\]))*?['][cdw]?"
  124. }, {
  125. token: ["keyword", "text", "paren.lparen"],
  126. regex: /(asm)(\s*)({)/,
  127. next: "d-asm"
  128. }, {
  129. token: ["keyword", "text", "paren.lparen", "constant.language"],
  130. regex: "(__traits)(\\s*)(\\()(" + identifierRe + ")"
  131. }, {
  132. token: ["keyword", "text", "variable.module"],
  133. regex: "(import|module)(\\s+)((?:" + identifierRe + "\\.?)*)"
  134. }, {
  135. token: ["keyword.storage", "text", "entity.name.type"],
  136. regex: "(" + storages + ")(\\s*)(" + identifierRe + ")"
  137. }, {
  138. token: ["keyword", "text", "variable.storage", "text"],
  139. regex: "(alias|typedef)(\\s*)(" + identifierRe + ")(\\s*)"
  140. }, {
  141. token: "constant.numeric",
  142. regex: "0[xX][0-9a-fA-F_]+(l|ul|u|f|F|L|U|UL)?\\b"
  143. }, {
  144. token: "constant.numeric",
  145. regex: "[+-]?\\d[\\d_]*(?:(?:\\.[\\d_]*)?(?:[eE][+-]?[\\d_]+)?)?(l|ul|u|f|F|L|U|UL)?\\b"
  146. }, {
  147. token: "entity.other.attribute-name",
  148. regex: "@" + identifierRe
  149. }, {
  150. token: keywordMapper,
  151. regex: "[a-zA-Z_][a-zA-Z0-9_]*\\b"
  152. }, {
  153. token: "keyword.operator",
  154. regex: operators
  155. }, {
  156. token: "punctuation.operator",
  157. regex: "\\?|\\:|\\,|\\;|\\.|\\:"
  158. }, {
  159. token: "paren.lparen",
  160. regex: "[[({]"
  161. }, {
  162. token: "paren.rparen",
  163. regex: "[\\])}]"
  164. }, {
  165. token: "text",
  166. regex: "\\s+"
  167. }
  168. ],
  169. "star-comment": [
  170. {
  171. token: "comment",
  172. regex: "\\*\\/",
  173. next: "start"
  174. }, {
  175. defaultToken: 'comment'
  176. }
  177. ],
  178. "plus-comment": [
  179. {
  180. token: "comment",
  181. regex: "\\+\\/",
  182. next: "start"
  183. }, {
  184. defaultToken: 'comment'
  185. }
  186. ],
  187. "quote-string": [
  188. stringEscapesSeq,
  189. {
  190. token: "string",
  191. regex: '"[cdw]?',
  192. next: "start"
  193. }, {
  194. defaultToken: 'string'
  195. }
  196. ],
  197. "backtick-string": [
  198. stringEscapesSeq,
  199. {
  200. token: "string",
  201. regex: '`[cdw]?',
  202. next: "start"
  203. }, {
  204. defaultToken: 'string'
  205. }
  206. ],
  207. "operator-heredoc-string": [
  208. {
  209. onMatch: function (value, currentState, state) {
  210. value = value.substring(value.length - 2, value.length - 1);
  211. var map = { '>': '<', ']': '[', ')': '(', '}': '{' };
  212. if (Object.keys(map).indexOf(value) != -1)
  213. value = map[value];
  214. if (value != state[1])
  215. return "string";
  216. state.shift();
  217. state.shift();
  218. return "string";
  219. },
  220. regex: '(?:[\\]\\)}>]+)"',
  221. next: 'start'
  222. }, {
  223. token: 'string',
  224. regex: '[^\\]\\)}>]+'
  225. }
  226. ],
  227. "identifier-heredoc-string": [
  228. {
  229. onMatch: function (value, currentState, state) {
  230. value = value.substring(0, value.length - 1);
  231. if (value != state[1])
  232. return "string";
  233. state.shift();
  234. state.shift();
  235. return "string";
  236. },
  237. regex: '^(?:[A-Za-z_][a-zA-Z0-9]+)"',
  238. next: 'start'
  239. }, {
  240. token: 'string',
  241. regex: '[^\\]\\)}>]+'
  242. }
  243. ],
  244. "d-asm": [
  245. {
  246. token: "paren.rparen",
  247. regex: "\\}",
  248. next: "start"
  249. }, {
  250. token: 'keyword.instruction',
  251. regex: '[a-zA-Z]+',
  252. next: 'd-asm-instruction'
  253. }, {
  254. token: "text",
  255. regex: "\\s+"
  256. }
  257. ],
  258. 'd-asm-instruction': [
  259. {
  260. token: 'constant.language',
  261. regex: /AL|AH|AX|EAX|BL|BH|BX|EBX|CL|CH|CX|ECX|DL|DH|DX|EDX|BP|EBP|SP|ESP|DI|EDI|SI|ESI/i
  262. }, {
  263. token: 'identifier',
  264. regex: '[a-zA-Z]+'
  265. }, {
  266. token: 'string',
  267. regex: '"[^"]*"'
  268. }, {
  269. token: 'comment',
  270. regex: '//.*$'
  271. }, {
  272. token: 'constant.numeric',
  273. regex: '[0-9.xA-F]+'
  274. }, {
  275. token: 'punctuation.operator',
  276. regex: '\\,'
  277. }, {
  278. token: 'punctuation.operator',
  279. regex: ';',
  280. next: 'd-asm'
  281. }, {
  282. token: 'text',
  283. regex: '\\s+'
  284. }
  285. ]
  286. };
  287. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  288. };
  289. DHighlightRules.metaData = {
  290. comment: 'D language',
  291. fileTypes: ['d', 'di'],
  292. firstLineMatch: '^#!.*\\b[glr]?dmd\\b.',
  293. foldingStartMarker: '(?x)/\\*\\*(?!\\*)|^(?![^{]*?//|[^{]*?/\\*(?!.*?\\*/.*?\\{)).*?\\{\\s*($|//|/\\*(?!.*?\\*/.*\\S))',
  294. foldingStopMarker: '(?<!\\*)\\*\\*/|^\\s*\\}',
  295. keyEquivalent: '^~D',
  296. name: 'D',
  297. scopeName: 'source.d'
  298. };
  299. oop.inherits(DHighlightRules, TextHighlightRules);
  300. exports.DHighlightRules = DHighlightRules;
  301. });
  302. 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";
  303. var oop = require("../../lib/oop");
  304. var Range = require("../../range").Range;
  305. var BaseFoldMode = require("./fold_mode").FoldMode;
  306. var FoldMode = exports.FoldMode = function (commentRegex) {
  307. if (commentRegex) {
  308. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  309. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  310. }
  311. };
  312. oop.inherits(FoldMode, BaseFoldMode);
  313. (function () {
  314. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  315. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  316. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  317. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  318. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  319. this._getFoldWidgetBase = this.getFoldWidget;
  320. this.getFoldWidget = function (session, foldStyle, row) {
  321. var line = session.getLine(row);
  322. if (this.singleLineBlockCommentRe.test(line)) {
  323. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  324. return "";
  325. }
  326. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  327. if (!fw && this.startRegionRe.test(line))
  328. return "start"; // lineCommentRegionStart
  329. return fw;
  330. };
  331. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  332. var line = session.getLine(row);
  333. if (this.startRegionRe.test(line))
  334. return this.getCommentRegionBlock(session, line, row);
  335. var match = line.match(this.foldingStartMarker);
  336. if (match) {
  337. var i = match.index;
  338. if (match[1])
  339. return this.openingBracketBlock(session, match[1], row, i);
  340. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  341. if (range && !range.isMultiLine()) {
  342. if (forceMultiline) {
  343. range = this.getSectionRange(session, row);
  344. }
  345. else if (foldStyle != "all")
  346. range = null;
  347. }
  348. return range;
  349. }
  350. if (foldStyle === "markbegin")
  351. return;
  352. var match = line.match(this.foldingStopMarker);
  353. if (match) {
  354. var i = match.index + match[0].length;
  355. if (match[1])
  356. return this.closingBracketBlock(session, match[1], row, i);
  357. return session.getCommentFoldRange(row, i, -1);
  358. }
  359. };
  360. this.getSectionRange = function (session, row) {
  361. var line = session.getLine(row);
  362. var startIndent = line.search(/\S/);
  363. var startRow = row;
  364. var startColumn = line.length;
  365. row = row + 1;
  366. var endRow = row;
  367. var maxRow = session.getLength();
  368. while (++row < maxRow) {
  369. line = session.getLine(row);
  370. var indent = line.search(/\S/);
  371. if (indent === -1)
  372. continue;
  373. if (startIndent > indent)
  374. break;
  375. var subRange = this.getFoldWidgetRange(session, "all", row);
  376. if (subRange) {
  377. if (subRange.start.row <= startRow) {
  378. break;
  379. }
  380. else if (subRange.isMultiLine()) {
  381. row = subRange.end.row;
  382. }
  383. else if (startIndent == indent) {
  384. break;
  385. }
  386. }
  387. endRow = row;
  388. }
  389. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  390. };
  391. this.getCommentRegionBlock = function (session, line, row) {
  392. var startColumn = line.search(/\s*$/);
  393. var maxRow = session.getLength();
  394. var startRow = row;
  395. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  396. var depth = 1;
  397. while (++row < maxRow) {
  398. line = session.getLine(row);
  399. var m = re.exec(line);
  400. if (!m)
  401. continue;
  402. if (m[1])
  403. depth--;
  404. else
  405. depth++;
  406. if (!depth)
  407. break;
  408. }
  409. var endRow = row;
  410. if (endRow > startRow) {
  411. return new Range(startRow, startColumn, endRow, line.length);
  412. }
  413. };
  414. }).call(FoldMode.prototype);
  415. });
  416. ace.define("ace/mode/d",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/d_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  417. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  418. */
  419. "use strict";
  420. var oop = require("../lib/oop");
  421. var TextMode = require("./text").Mode;
  422. var DHighlightRules = require("./d_highlight_rules").DHighlightRules;
  423. var FoldMode = require("./folding/cstyle").FoldMode;
  424. var Mode = function () {
  425. this.HighlightRules = DHighlightRules;
  426. this.foldingRules = new FoldMode();
  427. this.$behaviour = this.$defaultBehaviour;
  428. };
  429. oop.inherits(Mode, TextMode);
  430. (function () {
  431. this.lineCommentStart = "//";
  432. this.blockComment = { start: "/*", end: "*/" };
  433. this.$id = "ace/mode/d";
  434. }).call(Mode.prototype);
  435. exports.Mode = Mode;
  436. }); (function() {
  437. ace.require(["ace/mode/d"], function(m) {
  438. if (typeof module == "object" && typeof exports == "object" && module) {
  439. module.exports = m;
  440. }
  441. });
  442. })();