mode-nix.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. ace.define("ace/mode/doc_comment_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",[], 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. var formatRe = "%"
  80. + /(\d+\$)?/.source // field (argument #)
  81. + /[#0\- +']*/.source // flags
  82. + /[,;:_]?/.source // separator character (AltiVec)
  83. + /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width
  84. + /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision
  85. + /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier
  86. + /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type
  87. this.$rules = {
  88. "start" : [
  89. {
  90. token : "comment",
  91. regex : "//$",
  92. next : "start"
  93. }, {
  94. token : "comment",
  95. regex : "//",
  96. next : "singleLineComment"
  97. },
  98. DocCommentHighlightRules.getStartRule("doc-start"),
  99. {
  100. token : "comment", // multi line comment
  101. regex : "\\/\\*",
  102. next : "comment"
  103. }, {
  104. token : "string", // character
  105. regex : "'(?:" + escapeRe + "|.)?'"
  106. }, {
  107. token : "string.start",
  108. regex : '"',
  109. stateName: "qqstring",
  110. next: [
  111. { token: "string", regex: /\\\s*$/, next: "qqstring" },
  112. { token: "constant.language.escape", regex: escapeRe },
  113. { token: "constant.language.escape", regex: formatRe },
  114. { token: "string.end", regex: '"|$', next: "start" },
  115. { defaultToken: "string"}
  116. ]
  117. }, {
  118. token : "string.start",
  119. regex : 'R"\\(',
  120. stateName: "rawString",
  121. next: [
  122. { token: "string.end", regex: '\\)"', next: "start" },
  123. { defaultToken: "string"}
  124. ]
  125. }, {
  126. token : "constant.numeric", // hex
  127. regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  128. }, {
  129. token : "constant.numeric", // float
  130. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  131. }, {
  132. token : "keyword", // pre-compiler directives
  133. regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
  134. next : "directive"
  135. }, {
  136. token : "keyword", // special case pre-compiler directive
  137. regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
  138. }, {
  139. token : "support.function.C99.c",
  140. regex : cFunctions
  141. }, {
  142. token : keywordMapper,
  143. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
  144. }, {
  145. token : "keyword.operator",
  146. regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
  147. }, {
  148. token : "punctuation.operator",
  149. regex : "\\?|\\:|\\,|\\;|\\."
  150. }, {
  151. token : "paren.lparen",
  152. regex : "[[({]"
  153. }, {
  154. token : "paren.rparen",
  155. regex : "[\\])}]"
  156. }, {
  157. token : "text",
  158. regex : "\\s+"
  159. }
  160. ],
  161. "comment" : [
  162. {
  163. token : "comment", // closing comment
  164. regex : "\\*\\/",
  165. next : "start"
  166. }, {
  167. defaultToken : "comment"
  168. }
  169. ],
  170. "singleLineComment" : [
  171. {
  172. token : "comment",
  173. regex : /\\$/,
  174. next : "singleLineComment"
  175. }, {
  176. token : "comment",
  177. regex : /$/,
  178. next : "start"
  179. }, {
  180. defaultToken: "comment"
  181. }
  182. ],
  183. "directive" : [
  184. {
  185. token : "constant.other.multiline",
  186. regex : /\\/
  187. },
  188. {
  189. token : "constant.other.multiline",
  190. regex : /.*\\/
  191. },
  192. {
  193. token : "constant.other",
  194. regex : "\\s*<.+?>",
  195. next : "start"
  196. },
  197. {
  198. token : "constant.other", // single line
  199. regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
  200. next : "start"
  201. },
  202. {
  203. token : "constant.other", // single line
  204. regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
  205. next : "start"
  206. },
  207. {
  208. token : "constant.other",
  209. regex : /[^\\\/]+/,
  210. next : "start"
  211. }
  212. ]
  213. };
  214. this.embedRules(DocCommentHighlightRules, "doc-",
  215. [ DocCommentHighlightRules.getEndRule("start") ]);
  216. this.normalizeRules();
  217. };
  218. oop.inherits(c_cppHighlightRules, TextHighlightRules);
  219. exports.c_cppHighlightRules = c_cppHighlightRules;
  220. });
  221. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  222. "use strict";
  223. var Range = require("../range").Range;
  224. var MatchingBraceOutdent = function() {};
  225. (function() {
  226. this.checkOutdent = function(line, input) {
  227. if (! /^\s+$/.test(line))
  228. return false;
  229. return /^\s*\}/.test(input);
  230. };
  231. this.autoOutdent = function(doc, row) {
  232. var line = doc.getLine(row);
  233. var match = line.match(/^(\s*\})/);
  234. if (!match) return 0;
  235. var column = match[1].length;
  236. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  237. if (!openBracePos || openBracePos.row == row) return 0;
  238. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  239. doc.replace(new Range(row, 0, row, column-1), indent);
  240. };
  241. this.$getIndent = function(line) {
  242. return line.match(/^\s*/)[0];
  243. };
  244. }).call(MatchingBraceOutdent.prototype);
  245. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  246. });
  247. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  248. "use strict";
  249. var oop = require("../../lib/oop");
  250. var Range = require("../../range").Range;
  251. var BaseFoldMode = require("./fold_mode").FoldMode;
  252. var FoldMode = exports.FoldMode = function(commentRegex) {
  253. if (commentRegex) {
  254. this.foldingStartMarker = new RegExp(
  255. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  256. );
  257. this.foldingStopMarker = new RegExp(
  258. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  259. );
  260. }
  261. };
  262. oop.inherits(FoldMode, BaseFoldMode);
  263. (function() {
  264. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  265. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  266. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  267. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  268. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  269. this._getFoldWidgetBase = this.getFoldWidget;
  270. this.getFoldWidget = function(session, foldStyle, row) {
  271. var line = session.getLine(row);
  272. if (this.singleLineBlockCommentRe.test(line)) {
  273. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  274. return "";
  275. }
  276. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  277. if (!fw && this.startRegionRe.test(line))
  278. return "start"; // lineCommentRegionStart
  279. return fw;
  280. };
  281. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  282. var line = session.getLine(row);
  283. if (this.startRegionRe.test(line))
  284. return this.getCommentRegionBlock(session, line, row);
  285. var match = line.match(this.foldingStartMarker);
  286. if (match) {
  287. var i = match.index;
  288. if (match[1])
  289. return this.openingBracketBlock(session, match[1], row, i);
  290. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  291. if (range && !range.isMultiLine()) {
  292. if (forceMultiline) {
  293. range = this.getSectionRange(session, row);
  294. } else if (foldStyle != "all")
  295. range = null;
  296. }
  297. return range;
  298. }
  299. if (foldStyle === "markbegin")
  300. return;
  301. var match = line.match(this.foldingStopMarker);
  302. if (match) {
  303. var i = match.index + match[0].length;
  304. if (match[1])
  305. return this.closingBracketBlock(session, match[1], row, i);
  306. return session.getCommentFoldRange(row, i, -1);
  307. }
  308. };
  309. this.getSectionRange = function(session, row) {
  310. var line = session.getLine(row);
  311. var startIndent = line.search(/\S/);
  312. var startRow = row;
  313. var startColumn = line.length;
  314. row = row + 1;
  315. var endRow = row;
  316. var maxRow = session.getLength();
  317. while (++row < maxRow) {
  318. line = session.getLine(row);
  319. var indent = line.search(/\S/);
  320. if (indent === -1)
  321. continue;
  322. if (startIndent > indent)
  323. break;
  324. var subRange = this.getFoldWidgetRange(session, "all", row);
  325. if (subRange) {
  326. if (subRange.start.row <= startRow) {
  327. break;
  328. } else if (subRange.isMultiLine()) {
  329. row = subRange.end.row;
  330. } else if (startIndent == indent) {
  331. break;
  332. }
  333. }
  334. endRow = row;
  335. }
  336. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  337. };
  338. this.getCommentRegionBlock = function(session, line, row) {
  339. var startColumn = line.search(/\s*$/);
  340. var maxRow = session.getLength();
  341. var startRow = row;
  342. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  343. var depth = 1;
  344. while (++row < maxRow) {
  345. line = session.getLine(row);
  346. var m = re.exec(line);
  347. if (!m) continue;
  348. if (m[1]) depth--;
  349. else depth++;
  350. if (!depth) break;
  351. }
  352. var endRow = row;
  353. if (endRow > startRow) {
  354. return new Range(startRow, startColumn, endRow, line.length);
  355. }
  356. };
  357. }).call(FoldMode.prototype);
  358. });
  359. ace.define("ace/mode/c_cpp",[], function(require, exports, module) {
  360. "use strict";
  361. var oop = require("../lib/oop");
  362. var TextMode = require("./text").Mode;
  363. var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
  364. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  365. var Range = require("../range").Range;
  366. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  367. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  368. var Mode = function() {
  369. this.HighlightRules = c_cppHighlightRules;
  370. this.$outdent = new MatchingBraceOutdent();
  371. this.$behaviour = new CstyleBehaviour();
  372. this.foldingRules = new CStyleFoldMode();
  373. };
  374. oop.inherits(Mode, TextMode);
  375. (function() {
  376. this.lineCommentStart = "//";
  377. this.blockComment = {start: "/*", end: "*/"};
  378. this.getNextLineIndent = function(state, line, tab) {
  379. var indent = this.$getIndent(line);
  380. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  381. var tokens = tokenizedLine.tokens;
  382. var endState = tokenizedLine.state;
  383. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  384. return indent;
  385. }
  386. if (state == "start") {
  387. var match = line.match(/^.*[\{\(\[]\s*$/);
  388. if (match) {
  389. indent += tab;
  390. }
  391. } else if (state == "doc-start") {
  392. if (endState == "start") {
  393. return "";
  394. }
  395. var match = line.match(/^\s*(\/?)\*/);
  396. if (match) {
  397. if (match[1]) {
  398. indent += " ";
  399. }
  400. indent += "* ";
  401. }
  402. }
  403. return indent;
  404. };
  405. this.checkOutdent = function(state, line, input) {
  406. return this.$outdent.checkOutdent(line, input);
  407. };
  408. this.autoOutdent = function(state, doc, row) {
  409. this.$outdent.autoOutdent(doc, row);
  410. };
  411. this.$id = "ace/mode/c_cpp";
  412. }).call(Mode.prototype);
  413. exports.Mode = Mode;
  414. });
  415. ace.define("ace/mode/nix_highlight_rules",[], function(require, exports, module) {
  416. "use strict";
  417. var oop = require("../lib/oop");
  418. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  419. var NixHighlightRules = function() {
  420. var constantLanguage = "true|false";
  421. var keywordControl = "with|import|if|else|then|inherit";
  422. var keywordDeclaration = "let|in|rec";
  423. var keywordMapper = this.createKeywordMapper({
  424. "constant.language.nix": constantLanguage,
  425. "keyword.control.nix": keywordControl,
  426. "keyword.declaration.nix": keywordDeclaration
  427. }, "identifier");
  428. this.$rules = {
  429. "start": [{
  430. token: "comment",
  431. regex: /#.*$/
  432. }, {
  433. token: "comment",
  434. regex: /\/\*/,
  435. next: "comment"
  436. }, {
  437. token: "constant",
  438. regex: "<[^>]+>"
  439. }, {
  440. regex: "(==|!=|<=?|>=?)",
  441. token: ["keyword.operator.comparison.nix"]
  442. }, {
  443. regex: "((?:[+*/%-]|\\~)=)",
  444. token: ["keyword.operator.assignment.arithmetic.nix"]
  445. }, {
  446. regex: "=",
  447. token: "keyword.operator.assignment.nix"
  448. }, {
  449. token: "string",
  450. regex: "''",
  451. next: "qqdoc"
  452. }, {
  453. token: "string",
  454. regex: "'",
  455. next: "qstring"
  456. }, {
  457. token: "string",
  458. regex: '"',
  459. push: "qqstring"
  460. }, {
  461. token: "constant.numeric", // hex
  462. regex: "0[xX][0-9a-fA-F]+\\b"
  463. }, {
  464. token: "constant.numeric", // float
  465. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  466. }, {
  467. token: keywordMapper,
  468. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  469. }, {
  470. regex: "}",
  471. token: function(val, start, stack) {
  472. return stack[1] && stack[1].charAt(0) == "q" ? "constant.language.escape" : "text";
  473. },
  474. next: "pop"
  475. }],
  476. "comment": [{
  477. token: "comment", // closing comment
  478. regex: "\\*\\/",
  479. next: "start"
  480. }, {
  481. defaultToken: "comment"
  482. }],
  483. "qqdoc": [
  484. {
  485. token: "constant.language.escape",
  486. regex: /\$\{/,
  487. push: "start"
  488. }, {
  489. token: "string",
  490. regex: "''",
  491. next: "pop"
  492. }, {
  493. defaultToken: "string"
  494. }],
  495. "qqstring": [
  496. {
  497. token: "constant.language.escape",
  498. regex: /\$\{/,
  499. push: "start"
  500. }, {
  501. token: "string",
  502. regex: '"',
  503. next: "pop"
  504. }, {
  505. defaultToken: "string"
  506. }],
  507. "qstring": [
  508. {
  509. token: "constant.language.escape",
  510. regex: /\$\{/,
  511. push: "start"
  512. }, {
  513. token: "string",
  514. regex: "'",
  515. next: "pop"
  516. }, {
  517. defaultToken: "string"
  518. }]
  519. };
  520. this.normalizeRules();
  521. };
  522. oop.inherits(NixHighlightRules, TextHighlightRules);
  523. exports.NixHighlightRules = NixHighlightRules;
  524. });
  525. ace.define("ace/mode/nix",[], function(require, exports, module) {
  526. "use strict";
  527. var oop = require("../lib/oop");
  528. var CMode = require("./c_cpp").Mode;
  529. var NixHighlightRules = require("./nix_highlight_rules").NixHighlightRules;
  530. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  531. var Mode = function() {
  532. CMode.call(this);
  533. this.HighlightRules = NixHighlightRules;
  534. this.foldingRules = new CStyleFoldMode();
  535. this.$behaviour = this.$defaultBehaviour;
  536. };
  537. oop.inherits(Mode, CMode);
  538. (function() {
  539. this.lineCommentStart = "#";
  540. this.blockComment = {start: "/*", end: "*/"};
  541. this.$id = "ace/mode/nix";
  542. }).call(Mode.prototype);
  543. exports.Mode = Mode;
  544. });
  545. (function() {
  546. ace.require(["ace/mode/nix"], function(m) {
  547. if (typeof module == "object" && typeof exports == "object" && module) {
  548. module.exports = m;
  549. }
  550. });
  551. })();