86d777efd4d05137e05019407412503a.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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/sac_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 sacHighlightRules = function () {
  45. var keywordControls = ("break|continue|do|else|for|if|" +
  46. "return|with|while|use|class|all|void");
  47. var storageType = ("bool|char|complex|double|float|" +
  48. "byte|int|short|long|longlong|" +
  49. "ubyte|uint|ushort|ulong|ulonglong|" +
  50. "struct|typedef");
  51. var storageModifiers = ("inline|external|specialize");
  52. var keywordOperators = ("step|width");
  53. var builtinConstants = ("true|false");
  54. var keywordMapper = this.$keywords = this.createKeywordMapper({
  55. "keyword.control": keywordControls,
  56. "storage.type": storageType,
  57. "storage.modifier": storageModifiers,
  58. "keyword.operator": keywordOperators,
  59. "constant.language": builtinConstants
  60. }, "identifier");
  61. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  62. var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source;
  63. var formatRe = "%"
  64. + /(\d+\$)?/.source // field (argument #)
  65. + /[#0\- +']*/.source // flags
  66. + /[,;:_]?/.source // separator character (AltiVec)
  67. + /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width
  68. + /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision
  69. + /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier
  70. + /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type
  71. this.$rules = {
  72. "start": [
  73. {
  74. token: "comment",
  75. regex: "//$",
  76. next: "start"
  77. }, {
  78. token: "comment",
  79. regex: "//",
  80. next: "singleLineComment"
  81. },
  82. DocCommentHighlightRules.getStartRule("doc-start"),
  83. {
  84. token: "comment",
  85. regex: "\\/\\*",
  86. next: "comment"
  87. }, {
  88. token: "string",
  89. regex: "'(?:" + escapeRe + "|.)?'"
  90. }, {
  91. token: "string.start",
  92. regex: '"',
  93. stateName: "qqstring",
  94. next: [
  95. { token: "string", regex: /\\\s*$/, next: "qqstring" },
  96. { token: "constant.language.escape", regex: escapeRe },
  97. { token: "constant.language.escape", regex: formatRe },
  98. { token: "string.end", regex: '"|$', next: "start" },
  99. { defaultToken: "string" }
  100. ]
  101. }, {
  102. token: "string.start",
  103. regex: 'R"\\(',
  104. stateName: "rawString",
  105. next: [
  106. { token: "string.end", regex: '\\)"', next: "start" },
  107. { defaultToken: "string" }
  108. ]
  109. }, {
  110. token: "constant.numeric",
  111. regex: "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  112. }, {
  113. token: "constant.numeric",
  114. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  115. }, {
  116. token: "keyword",
  117. regex: "#\\s*(?:include|import|pragma|line|define|undef)\\b",
  118. next: "directive"
  119. }, {
  120. token: "keyword",
  121. regex: "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
  122. }, {
  123. token: "support.function",
  124. regex: "fold|foldfix|genarray|modarray|propagate"
  125. }, {
  126. token: keywordMapper,
  127. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*"
  128. }, {
  129. token: "keyword.operator",
  130. regex: /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
  131. }, {
  132. token: "punctuation.operator",
  133. regex: "\\?|\\:|\\,|\\;|\\."
  134. }, {
  135. token: "paren.lparen",
  136. regex: "[[({]"
  137. }, {
  138. token: "paren.rparen",
  139. regex: "[\\])}]"
  140. }, {
  141. token: "text",
  142. regex: "\\s+"
  143. }
  144. ],
  145. "comment": [
  146. {
  147. token: "comment",
  148. regex: "\\*\\/",
  149. next: "start"
  150. }, {
  151. defaultToken: "comment"
  152. }
  153. ],
  154. "singleLineComment": [
  155. {
  156. token: "comment",
  157. regex: /\\$/,
  158. next: "singleLineComment"
  159. }, {
  160. token: "comment",
  161. regex: /$/,
  162. next: "start"
  163. }, {
  164. defaultToken: "comment"
  165. }
  166. ],
  167. "directive": [
  168. {
  169. token: "constant.other.multiline",
  170. regex: /\\/
  171. },
  172. {
  173. token: "constant.other.multiline",
  174. regex: /.*\\/
  175. },
  176. {
  177. token: "constant.other",
  178. regex: "\\s*<.+?>",
  179. next: "start"
  180. },
  181. {
  182. token: "constant.other",
  183. regex: '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
  184. next: "start"
  185. },
  186. {
  187. token: "constant.other",
  188. regex: "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
  189. next: "start"
  190. },
  191. {
  192. token: "constant.other",
  193. regex: /[^\\\/]+/,
  194. next: "start"
  195. }
  196. ]
  197. };
  198. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  199. this.normalizeRules();
  200. };
  201. oop.inherits(sacHighlightRules, TextHighlightRules);
  202. exports.sacHighlightRules = sacHighlightRules;
  203. });
  204. 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";
  205. var oop = require("../../lib/oop");
  206. var Range = require("../../range").Range;
  207. var BaseFoldMode = require("./fold_mode").FoldMode;
  208. var FoldMode = exports.FoldMode = function (commentRegex) {
  209. if (commentRegex) {
  210. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  211. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  212. }
  213. };
  214. oop.inherits(FoldMode, BaseFoldMode);
  215. (function () {
  216. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  217. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  218. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  219. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  220. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  221. this._getFoldWidgetBase = this.getFoldWidget;
  222. this.getFoldWidget = function (session, foldStyle, row) {
  223. var line = session.getLine(row);
  224. if (this.singleLineBlockCommentRe.test(line)) {
  225. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  226. return "";
  227. }
  228. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  229. if (!fw && this.startRegionRe.test(line))
  230. return "start"; // lineCommentRegionStart
  231. return fw;
  232. };
  233. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  234. var line = session.getLine(row);
  235. if (this.startRegionRe.test(line))
  236. return this.getCommentRegionBlock(session, line, row);
  237. var match = line.match(this.foldingStartMarker);
  238. if (match) {
  239. var i = match.index;
  240. if (match[1])
  241. return this.openingBracketBlock(session, match[1], row, i);
  242. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  243. if (range && !range.isMultiLine()) {
  244. if (forceMultiline) {
  245. range = this.getSectionRange(session, row);
  246. }
  247. else if (foldStyle != "all")
  248. range = null;
  249. }
  250. return range;
  251. }
  252. if (foldStyle === "markbegin")
  253. return;
  254. var match = line.match(this.foldingStopMarker);
  255. if (match) {
  256. var i = match.index + match[0].length;
  257. if (match[1])
  258. return this.closingBracketBlock(session, match[1], row, i);
  259. return session.getCommentFoldRange(row, i, -1);
  260. }
  261. };
  262. this.getSectionRange = function (session, row) {
  263. var line = session.getLine(row);
  264. var startIndent = line.search(/\S/);
  265. var startRow = row;
  266. var startColumn = line.length;
  267. row = row + 1;
  268. var endRow = row;
  269. var maxRow = session.getLength();
  270. while (++row < maxRow) {
  271. line = session.getLine(row);
  272. var indent = line.search(/\S/);
  273. if (indent === -1)
  274. continue;
  275. if (startIndent > indent)
  276. break;
  277. var subRange = this.getFoldWidgetRange(session, "all", row);
  278. if (subRange) {
  279. if (subRange.start.row <= startRow) {
  280. break;
  281. }
  282. else if (subRange.isMultiLine()) {
  283. row = subRange.end.row;
  284. }
  285. else if (startIndent == indent) {
  286. break;
  287. }
  288. }
  289. endRow = row;
  290. }
  291. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  292. };
  293. this.getCommentRegionBlock = function (session, line, row) {
  294. var startColumn = line.search(/\s*$/);
  295. var maxRow = session.getLength();
  296. var startRow = row;
  297. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  298. var depth = 1;
  299. while (++row < maxRow) {
  300. line = session.getLine(row);
  301. var m = re.exec(line);
  302. if (!m)
  303. continue;
  304. if (m[1])
  305. depth--;
  306. else
  307. depth++;
  308. if (!depth)
  309. break;
  310. }
  311. var endRow = row;
  312. if (endRow > startRow) {
  313. return new Range(startRow, startColumn, endRow, line.length);
  314. }
  315. };
  316. }).call(FoldMode.prototype);
  317. });
  318. ace.define("ace/mode/sac",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sac_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  319. var oop = require("../lib/oop");
  320. var TextMode = require("./text").Mode;
  321. var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules;
  322. var FoldMode = require("./folding/cstyle").FoldMode;
  323. var Mode = function () {
  324. this.HighlightRules = SaCHighlightRules;
  325. this.foldingRules = new FoldMode();
  326. this.$behaviour = this.$defaultBehaviour;
  327. };
  328. oop.inherits(Mode, TextMode);
  329. (function () {
  330. this.lineCommentStart = "//";
  331. this.blockComment = { start: "/*", end: "*/" };
  332. this.$id = "ace/mode/sac";
  333. }).call(Mode.prototype);
  334. exports.Mode = Mode;
  335. }); (function() {
  336. ace.require(["ace/mode/sac"], function(m) {
  337. if (typeof module == "object" && typeof exports == "object" && module) {
  338. module.exports = m;
  339. }
  340. });
  341. })();