f4acea05f1f36de4fb003f20f7799de6.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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/scad_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","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 lang = require("../lib/lang");
  43. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  44. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  45. var scadHighlightRules = function () {
  46. var keywordMapper = this.createKeywordMapper({
  47. "variable.language": "this",
  48. "keyword": "module|if|else|for",
  49. "constant.language": "NULL"
  50. }, "identifier");
  51. this.$rules = {
  52. "start": [
  53. {
  54. token: "comment",
  55. regex: "\\/\\/.*$"
  56. },
  57. DocCommentHighlightRules.getStartRule("start"),
  58. {
  59. token: "comment",
  60. regex: "\\/\\*",
  61. next: "comment"
  62. }, {
  63. token: "string",
  64. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  65. }, {
  66. token: "string",
  67. regex: '["].*\\\\$',
  68. next: "qqstring"
  69. }, {
  70. token: "string",
  71. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  72. }, {
  73. token: "string",
  74. regex: "['].*\\\\$",
  75. next: "qstring"
  76. }, {
  77. token: "constant.numeric",
  78. regex: "0[xX][0-9a-fA-F]+\\b"
  79. }, {
  80. token: "constant.numeric",
  81. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  82. }, {
  83. token: "constant",
  84. regex: "<[a-zA-Z0-9.]+>"
  85. }, {
  86. token: "keyword",
  87. regex: "(?:use|include)"
  88. }, {
  89. token: keywordMapper,
  90. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  91. }, {
  92. token: "keyword.operator",
  93. regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
  94. }, {
  95. token: "paren.lparen",
  96. regex: "[[({]"
  97. }, {
  98. token: "paren.rparen",
  99. regex: "[\\])}]"
  100. }, {
  101. token: "text",
  102. regex: "\\s+"
  103. }
  104. ],
  105. "comment": [
  106. {
  107. token: "comment",
  108. regex: "\\*\\/",
  109. next: "start"
  110. }, {
  111. defaultToken: "comment"
  112. }
  113. ],
  114. "qqstring": [
  115. {
  116. token: "string",
  117. regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  118. next: "start"
  119. }, {
  120. token: "string",
  121. regex: '.+'
  122. }
  123. ],
  124. "qstring": [
  125. {
  126. token: "string",
  127. regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  128. next: "start"
  129. }, {
  130. token: "string",
  131. regex: '.+'
  132. }
  133. ]
  134. };
  135. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  136. };
  137. oop.inherits(scadHighlightRules, TextHighlightRules);
  138. exports.scadHighlightRules = scadHighlightRules;
  139. });
  140. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  141. var Range = require("../range").Range;
  142. var MatchingBraceOutdent = function () { };
  143. (function () {
  144. this.checkOutdent = function (line, input) {
  145. if (!/^\s+$/.test(line))
  146. return false;
  147. return /^\s*\}/.test(input);
  148. };
  149. this.autoOutdent = function (doc, row) {
  150. var line = doc.getLine(row);
  151. var match = line.match(/^(\s*\})/);
  152. if (!match)
  153. return 0;
  154. var column = match[1].length;
  155. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  156. if (!openBracePos || openBracePos.row == row)
  157. return 0;
  158. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  159. doc.replace(new Range(row, 0, row, column - 1), indent);
  160. };
  161. this.$getIndent = function (line) {
  162. return line.match(/^\s*/)[0];
  163. };
  164. }).call(MatchingBraceOutdent.prototype);
  165. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  166. });
  167. 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";
  168. var oop = require("../../lib/oop");
  169. var Range = require("../../range").Range;
  170. var BaseFoldMode = require("./fold_mode").FoldMode;
  171. var FoldMode = exports.FoldMode = function (commentRegex) {
  172. if (commentRegex) {
  173. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  174. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  175. }
  176. };
  177. oop.inherits(FoldMode, BaseFoldMode);
  178. (function () {
  179. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  180. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  181. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  182. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  183. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  184. this._getFoldWidgetBase = this.getFoldWidget;
  185. this.getFoldWidget = function (session, foldStyle, row) {
  186. var line = session.getLine(row);
  187. if (this.singleLineBlockCommentRe.test(line)) {
  188. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  189. return "";
  190. }
  191. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  192. if (!fw && this.startRegionRe.test(line))
  193. return "start"; // lineCommentRegionStart
  194. return fw;
  195. };
  196. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  197. var line = session.getLine(row);
  198. if (this.startRegionRe.test(line))
  199. return this.getCommentRegionBlock(session, line, row);
  200. var match = line.match(this.foldingStartMarker);
  201. if (match) {
  202. var i = match.index;
  203. if (match[1])
  204. return this.openingBracketBlock(session, match[1], row, i);
  205. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  206. if (range && !range.isMultiLine()) {
  207. if (forceMultiline) {
  208. range = this.getSectionRange(session, row);
  209. }
  210. else if (foldStyle != "all")
  211. range = null;
  212. }
  213. return range;
  214. }
  215. if (foldStyle === "markbegin")
  216. return;
  217. var match = line.match(this.foldingStopMarker);
  218. if (match) {
  219. var i = match.index + match[0].length;
  220. if (match[1])
  221. return this.closingBracketBlock(session, match[1], row, i);
  222. return session.getCommentFoldRange(row, i, -1);
  223. }
  224. };
  225. this.getSectionRange = function (session, row) {
  226. var line = session.getLine(row);
  227. var startIndent = line.search(/\S/);
  228. var startRow = row;
  229. var startColumn = line.length;
  230. row = row + 1;
  231. var endRow = row;
  232. var maxRow = session.getLength();
  233. while (++row < maxRow) {
  234. line = session.getLine(row);
  235. var indent = line.search(/\S/);
  236. if (indent === -1)
  237. continue;
  238. if (startIndent > indent)
  239. break;
  240. var subRange = this.getFoldWidgetRange(session, "all", row);
  241. if (subRange) {
  242. if (subRange.start.row <= startRow) {
  243. break;
  244. }
  245. else if (subRange.isMultiLine()) {
  246. row = subRange.end.row;
  247. }
  248. else if (startIndent == indent) {
  249. break;
  250. }
  251. }
  252. endRow = row;
  253. }
  254. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  255. };
  256. this.getCommentRegionBlock = function (session, line, row) {
  257. var startColumn = line.search(/\s*$/);
  258. var maxRow = session.getLength();
  259. var startRow = row;
  260. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  261. var depth = 1;
  262. while (++row < maxRow) {
  263. line = session.getLine(row);
  264. var m = re.exec(line);
  265. if (!m)
  266. continue;
  267. if (m[1])
  268. depth--;
  269. else
  270. depth++;
  271. if (!depth)
  272. break;
  273. }
  274. var endRow = row;
  275. if (endRow > startRow) {
  276. return new Range(startRow, startColumn, endRow, line.length);
  277. }
  278. };
  279. }).call(FoldMode.prototype);
  280. });
  281. ace.define("ace/mode/scad",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scad_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  282. var oop = require("../lib/oop");
  283. var TextMode = require("./text").Mode;
  284. var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules;
  285. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  286. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  287. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  288. var Mode = function () {
  289. this.HighlightRules = scadHighlightRules;
  290. this.$outdent = new MatchingBraceOutdent();
  291. this.$behaviour = new CstyleBehaviour();
  292. this.foldingRules = new CStyleFoldMode();
  293. };
  294. oop.inherits(Mode, TextMode);
  295. (function () {
  296. this.lineCommentStart = "//";
  297. this.blockComment = { start: "/*", end: "*/" };
  298. this.getNextLineIndent = function (state, line, tab) {
  299. var indent = this.$getIndent(line);
  300. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  301. var tokens = tokenizedLine.tokens;
  302. var endState = tokenizedLine.state;
  303. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  304. return indent;
  305. }
  306. if (state == "start") {
  307. var match = line.match(/^.*[\{\(\[]\s*$/);
  308. if (match) {
  309. indent += tab;
  310. }
  311. }
  312. else if (state == "doc-start") {
  313. if (endState == "start") {
  314. return "";
  315. }
  316. var match = line.match(/^\s*(\/?)\*/);
  317. if (match) {
  318. if (match[1]) {
  319. indent += " ";
  320. }
  321. indent += "* ";
  322. }
  323. }
  324. return indent;
  325. };
  326. this.checkOutdent = function (state, line, input) {
  327. return this.$outdent.checkOutdent(line, input);
  328. };
  329. this.autoOutdent = function (state, doc, row) {
  330. this.$outdent.autoOutdent(doc, row);
  331. };
  332. this.$id = "ace/mode/scad";
  333. }).call(Mode.prototype);
  334. exports.Mode = Mode;
  335. }); (function() {
  336. ace.require(["ace/mode/scad"], function(m) {
  337. if (typeof module == "object" && typeof exports == "object" && module) {
  338. module.exports = m;
  339. }
  340. });
  341. })();