PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/bower_components/ace-builds/src-noconflict/mode-scad.js

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