mode-nix.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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/c_cpp_highlight_rules",["require","exports","module","ace/lib/oop","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 DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var cFunctions = exports.cFunctions = "\\b(?:hypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len))))\\b"
  47. var c_cppHighlightRules = function() {
  48. var keywordControls = (
  49. "break|case|continue|default|do|else|for|goto|if|_Pragma|" +
  50. "return|switch|while|catch|operator|try|throw|using"
  51. );
  52. var storageType = (
  53. "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
  54. "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
  55. "class|wchar_t|template|char16_t|char32_t"
  56. );
  57. var storageModifiers = (
  58. "const|extern|register|restrict|static|volatile|inline|private|" +
  59. "protected|public|friend|explicit|virtual|export|mutable|typename|" +
  60. "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
  61. );
  62. var keywordOperators = (
  63. "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" +
  64. "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
  65. );
  66. var builtinConstants = (
  67. "NULL|true|false|TRUE|FALSE|nullptr"
  68. );
  69. var keywordMapper = this.$keywords = this.createKeywordMapper({
  70. "keyword.control" : keywordControls,
  71. "storage.type" : storageType,
  72. "storage.modifier" : storageModifiers,
  73. "keyword.operator" : keywordOperators,
  74. "variable.language": "this",
  75. "constant.language": builtinConstants
  76. }, "identifier");
  77. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  78. 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;
  79. this.$rules = {
  80. "start" : [
  81. {
  82. token : "comment",
  83. regex : "//$",
  84. next : "start"
  85. }, {
  86. token : "comment",
  87. regex : "//",
  88. next : "singleLineComment"
  89. },
  90. DocCommentHighlightRules.getStartRule("doc-start"),
  91. {
  92. token : "comment", // multi line comment
  93. regex : "\\/\\*",
  94. next : "comment"
  95. }, {
  96. token : "string", // character
  97. regex : "'(?:" + escapeRe + "|.)?'"
  98. }, {
  99. token : "string.start",
  100. regex : '"',
  101. stateName: "qqstring",
  102. next: [
  103. { token: "string", regex: /\\\s*$/, next: "qqstring" },
  104. { token: "constant.language.escape", regex: escapeRe },
  105. { token: "constant.language.escape", regex: /%[^'"\\]/ },
  106. { token: "string.end", regex: '"|$', next: "start" },
  107. { defaultToken: "string"}
  108. ]
  109. }, {
  110. token : "string.start",
  111. regex : 'R"\\(',
  112. stateName: "rawString",
  113. next: [
  114. { token: "string.end", regex: '\\)"', next: "start" },
  115. { defaultToken: "string"}
  116. ]
  117. }, {
  118. token : "constant.numeric", // hex
  119. regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  120. }, {
  121. token : "constant.numeric", // float
  122. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  123. }, {
  124. token : "keyword", // pre-compiler directives
  125. regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
  126. next : "directive"
  127. }, {
  128. token : "keyword", // special case pre-compiler directive
  129. regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
  130. }, {
  131. token : "support.function.C99.c",
  132. regex : cFunctions
  133. }, {
  134. token : keywordMapper,
  135. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
  136. }, {
  137. token : "keyword.operator",
  138. regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
  139. }, {
  140. token : "punctuation.operator",
  141. regex : "\\?|\\:|\\,|\\;|\\."
  142. }, {
  143. token : "paren.lparen",
  144. regex : "[[({]"
  145. }, {
  146. token : "paren.rparen",
  147. regex : "[\\])}]"
  148. }, {
  149. token : "text",
  150. regex : "\\s+"
  151. }
  152. ],
  153. "comment" : [
  154. {
  155. token : "comment", // closing comment
  156. regex : ".*?\\*\\/",
  157. next : "start"
  158. }, {
  159. token : "comment", // comment spanning whole line
  160. regex : ".+"
  161. }
  162. ],
  163. "singleLineComment" : [
  164. {
  165. token : "comment",
  166. regex : /\\$/,
  167. next : "singleLineComment"
  168. }, {
  169. token : "comment",
  170. regex : /$/,
  171. next : "start"
  172. }, {
  173. defaultToken: "comment"
  174. }
  175. ],
  176. "directive" : [
  177. {
  178. token : "constant.other.multiline",
  179. regex : /\\/
  180. },
  181. {
  182. token : "constant.other.multiline",
  183. regex : /.*\\/
  184. },
  185. {
  186. token : "constant.other",
  187. regex : "\\s*<.+?>",
  188. next : "start"
  189. },
  190. {
  191. token : "constant.other", // single line
  192. regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
  193. next : "start"
  194. },
  195. {
  196. token : "constant.other", // single line
  197. regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
  198. next : "start"
  199. },
  200. {
  201. token : "constant.other",
  202. regex : /[^\\\/]+/,
  203. next : "start"
  204. }
  205. ]
  206. };
  207. this.embedRules(DocCommentHighlightRules, "doc-",
  208. [ DocCommentHighlightRules.getEndRule("start") ]);
  209. this.normalizeRules();
  210. };
  211. oop.inherits(c_cppHighlightRules, TextHighlightRules);
  212. exports.c_cppHighlightRules = c_cppHighlightRules;
  213. });
  214. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  215. "use strict";
  216. var Range = require("../range").Range;
  217. var MatchingBraceOutdent = function() {};
  218. (function() {
  219. this.checkOutdent = function(line, input) {
  220. if (! /^\s+$/.test(line))
  221. return false;
  222. return /^\s*\}/.test(input);
  223. };
  224. this.autoOutdent = function(doc, row) {
  225. var line = doc.getLine(row);
  226. var match = line.match(/^(\s*\})/);
  227. if (!match) return 0;
  228. var column = match[1].length;
  229. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  230. if (!openBracePos || openBracePos.row == row) return 0;
  231. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  232. doc.replace(new Range(row, 0, row, column-1), indent);
  233. };
  234. this.$getIndent = function(line) {
  235. return line.match(/^\s*/)[0];
  236. };
  237. }).call(MatchingBraceOutdent.prototype);
  238. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  239. });
  240. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  241. "use strict";
  242. var oop = require("../../lib/oop");
  243. var Range = require("../../range").Range;
  244. var BaseFoldMode = require("./fold_mode").FoldMode;
  245. var FoldMode = exports.FoldMode = function(commentRegex) {
  246. if (commentRegex) {
  247. this.foldingStartMarker = new RegExp(
  248. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  249. );
  250. this.foldingStopMarker = new RegExp(
  251. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  252. );
  253. }
  254. };
  255. oop.inherits(FoldMode, BaseFoldMode);
  256. (function() {
  257. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  258. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  259. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  260. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  261. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  262. this._getFoldWidgetBase = this.getFoldWidget;
  263. this.getFoldWidget = function(session, foldStyle, row) {
  264. var line = session.getLine(row);
  265. if (this.singleLineBlockCommentRe.test(line)) {
  266. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  267. return "";
  268. }
  269. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  270. if (!fw && this.startRegionRe.test(line))
  271. return "start"; // lineCommentRegionStart
  272. return fw;
  273. };
  274. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  275. var line = session.getLine(row);
  276. if (this.startRegionRe.test(line))
  277. return this.getCommentRegionBlock(session, line, row);
  278. var match = line.match(this.foldingStartMarker);
  279. if (match) {
  280. var i = match.index;
  281. if (match[1])
  282. return this.openingBracketBlock(session, match[1], row, i);
  283. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  284. if (range && !range.isMultiLine()) {
  285. if (forceMultiline) {
  286. range = this.getSectionRange(session, row);
  287. } else if (foldStyle != "all")
  288. range = null;
  289. }
  290. return range;
  291. }
  292. if (foldStyle === "markbegin")
  293. return;
  294. var match = line.match(this.foldingStopMarker);
  295. if (match) {
  296. var i = match.index + match[0].length;
  297. if (match[1])
  298. return this.closingBracketBlock(session, match[1], row, i);
  299. return session.getCommentFoldRange(row, i, -1);
  300. }
  301. };
  302. this.getSectionRange = function(session, row) {
  303. var line = session.getLine(row);
  304. var startIndent = line.search(/\S/);
  305. var startRow = row;
  306. var startColumn = line.length;
  307. row = row + 1;
  308. var endRow = row;
  309. var maxRow = session.getLength();
  310. while (++row < maxRow) {
  311. line = session.getLine(row);
  312. var indent = line.search(/\S/);
  313. if (indent === -1)
  314. continue;
  315. if (startIndent > indent)
  316. break;
  317. var subRange = this.getFoldWidgetRange(session, "all", row);
  318. if (subRange) {
  319. if (subRange.start.row <= startRow) {
  320. break;
  321. } else if (subRange.isMultiLine()) {
  322. row = subRange.end.row;
  323. } else if (startIndent == indent) {
  324. break;
  325. }
  326. }
  327. endRow = row;
  328. }
  329. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  330. };
  331. this.getCommentRegionBlock = function(session, line, row) {
  332. var startColumn = line.search(/\s*$/);
  333. var maxRow = session.getLength();
  334. var startRow = row;
  335. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  336. var depth = 1;
  337. while (++row < maxRow) {
  338. line = session.getLine(row);
  339. var m = re.exec(line);
  340. if (!m) continue;
  341. if (m[1]) depth--;
  342. else depth++;
  343. if (!depth) break;
  344. }
  345. var endRow = row;
  346. if (endRow > startRow) {
  347. return new Range(startRow, startColumn, endRow, line.length);
  348. }
  349. };
  350. }).call(FoldMode.prototype);
  351. });
  352. ace.define("ace/mode/c_cpp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c_cpp_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
  353. "use strict";
  354. var oop = require("../lib/oop");
  355. var TextMode = require("./text").Mode;
  356. var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
  357. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  358. var Range = require("../range").Range;
  359. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  360. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  361. var Mode = function() {
  362. this.HighlightRules = c_cppHighlightRules;
  363. this.$outdent = new MatchingBraceOutdent();
  364. this.$behaviour = new CstyleBehaviour();
  365. this.foldingRules = new CStyleFoldMode();
  366. };
  367. oop.inherits(Mode, TextMode);
  368. (function() {
  369. this.lineCommentStart = "//";
  370. this.blockComment = {start: "/*", end: "*/"};
  371. this.getNextLineIndent = function(state, line, tab) {
  372. var indent = this.$getIndent(line);
  373. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  374. var tokens = tokenizedLine.tokens;
  375. var endState = tokenizedLine.state;
  376. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  377. return indent;
  378. }
  379. if (state == "start") {
  380. var match = line.match(/^.*[\{\(\[]\s*$/);
  381. if (match) {
  382. indent += tab;
  383. }
  384. } else if (state == "doc-start") {
  385. if (endState == "start") {
  386. return "";
  387. }
  388. var match = line.match(/^\s*(\/?)\*/);
  389. if (match) {
  390. if (match[1]) {
  391. indent += " ";
  392. }
  393. indent += "* ";
  394. }
  395. }
  396. return indent;
  397. };
  398. this.checkOutdent = function(state, line, input) {
  399. return this.$outdent.checkOutdent(line, input);
  400. };
  401. this.autoOutdent = function(state, doc, row) {
  402. this.$outdent.autoOutdent(doc, row);
  403. };
  404. this.$id = "ace/mode/c_cpp";
  405. }).call(Mode.prototype);
  406. exports.Mode = Mode;
  407. });
  408. ace.define("ace/mode/nix_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  409. "use strict";
  410. var oop = require("../lib/oop");
  411. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  412. var NixHighlightRules = function() {
  413. var constantLanguage = "true|false";
  414. var keywordControl = "with|import|if|else|then|inherit";
  415. var keywordDeclaration = "let|in|rec";
  416. var keywordMapper = this.createKeywordMapper({
  417. "constant.language.nix": constantLanguage,
  418. "keyword.control.nix": keywordControl,
  419. "keyword.declaration.nix": keywordDeclaration
  420. }, "identifier");
  421. this.$rules = {
  422. "start": [{
  423. token: "comment",
  424. regex: /#.*$/
  425. }, {
  426. token: "comment",
  427. regex: /\/\*/,
  428. next: "comment"
  429. }, {
  430. token: "constant",
  431. regex: "<[^>]+>"
  432. }, {
  433. regex: "(==|!=|<=?|>=?)",
  434. token: ["keyword.operator.comparison.nix"]
  435. }, {
  436. regex: "((?:[+*/%-]|\\~)=)",
  437. token: ["keyword.operator.assignment.arithmetic.nix"]
  438. }, {
  439. regex: "=",
  440. token: "keyword.operator.assignment.nix"
  441. }, {
  442. token: "string",
  443. regex: "''",
  444. next: "qqdoc"
  445. }, {
  446. token: "string",
  447. regex: "'",
  448. next: "qstring"
  449. }, {
  450. token: "string",
  451. regex: '"',
  452. push: "qqstring"
  453. }, {
  454. token: "constant.numeric", // hex
  455. regex: "0[xX][0-9a-fA-F]+\\b"
  456. }, {
  457. token: "constant.numeric", // float
  458. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  459. }, {
  460. token: keywordMapper,
  461. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  462. }, {
  463. regex: "}",
  464. token: function(val, start, stack) {
  465. return stack[1] && stack[1].charAt(0) == "q" ? "constant.language.escape" : "text";
  466. },
  467. next: "pop"
  468. }],
  469. "comment": [{
  470. token: "comment", // closing comment
  471. regex: ".*?\\*\\/",
  472. next: "start"
  473. }, {
  474. token: "comment", // comment spanning whole line
  475. regex: ".+"
  476. }],
  477. "qqdoc": [
  478. {
  479. token: "constant.language.escape",
  480. regex: /\$\{/,
  481. push: "start"
  482. }, {
  483. token: "string",
  484. regex: "''",
  485. next: "pop"
  486. }, {
  487. defaultToken: "string"
  488. }],
  489. "qqstring": [
  490. {
  491. token: "constant.language.escape",
  492. regex: /\$\{/,
  493. push: "start"
  494. }, {
  495. token: "string",
  496. regex: '"',
  497. next: "pop"
  498. }, {
  499. defaultToken: "string"
  500. }],
  501. "qstring": [
  502. {
  503. token: "constant.language.escape",
  504. regex: /\$\{/,
  505. push: "start"
  506. }, {
  507. token: "string",
  508. regex: "'",
  509. next: "pop"
  510. }, {
  511. defaultToken: "string"
  512. }]
  513. };
  514. this.normalizeRules();
  515. };
  516. oop.inherits(NixHighlightRules, TextHighlightRules);
  517. exports.NixHighlightRules = NixHighlightRules;
  518. });
  519. ace.define("ace/mode/nix",["require","exports","module","ace/lib/oop","ace/mode/c_cpp","ace/mode/nix_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
  520. "use strict";
  521. var oop = require("../lib/oop");
  522. var CMode = require("./c_cpp").Mode;
  523. var NixHighlightRules = require("./nix_highlight_rules").NixHighlightRules;
  524. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  525. var Mode = function() {
  526. CMode.call(this);
  527. this.HighlightRules = NixHighlightRules;
  528. this.foldingRules = new CStyleFoldMode();
  529. this.$behaviour = this.$defaultBehaviour;
  530. };
  531. oop.inherits(Mode, CMode);
  532. (function() {
  533. this.lineCommentStart = "#";
  534. this.blockComment = {start: "/*", end: "*/"};
  535. this.$id = "ace/mode/nix";
  536. }).call(Mode.prototype);
  537. exports.Mode = Mode;
  538. });