cbdf771a8121b4ee46803ff5a9cc2162.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. ace.define("ace/mode/sh_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 reservedKeywords = exports.reservedKeywords = ('!|{|}|case|do|done|elif|else|' +
  5. 'esac|fi|for|if|in|then|until|while|' +
  6. '&|;|export|local|read|typeset|unset|' +
  7. 'elif|select|set|function|declare|readonly');
  8. var languageConstructs = exports.languageConstructs = ('[|]|alias|bg|bind|break|builtin|' +
  9. 'cd|command|compgen|complete|continue|' +
  10. 'dirs|disown|echo|enable|eval|exec|' +
  11. 'exit|fc|fg|getopts|hash|help|history|' +
  12. 'jobs|kill|let|logout|popd|printf|pushd|' +
  13. 'pwd|return|set|shift|shopt|source|' +
  14. 'suspend|test|times|trap|type|ulimit|' +
  15. 'umask|unalias|wait');
  16. var ShHighlightRules = function () {
  17. var keywordMapper = this.createKeywordMapper({
  18. "keyword": reservedKeywords,
  19. "support.function.builtin": languageConstructs,
  20. "invalid.deprecated": "debugger"
  21. }, "identifier");
  22. var integer = "(?:(?:[1-9]\\d*)|(?:0))";
  23. var fraction = "(?:\\.\\d+)";
  24. var intPart = "(?:\\d+)";
  25. var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
  26. var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + ")";
  27. var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
  28. var fileDescriptor = "(?:&" + intPart + ")";
  29. var variableName = "[a-zA-Z_][a-zA-Z0-9_]*";
  30. var variable = "(?:" + variableName + "(?==))";
  31. var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";
  32. var func = "(?:" + variableName + "\\s*\\(\\))";
  33. this.$rules = {
  34. "start": [{
  35. token: "constant",
  36. regex: /\\./
  37. }, {
  38. token: ["text", "comment"],
  39. regex: /(^|\s)(#.*)$/
  40. }, {
  41. token: "string.start",
  42. regex: '"',
  43. push: [{
  44. token: "constant.language.escape",
  45. regex: /\\(?:[$`"\\]|$)/
  46. }, {
  47. include: "variables"
  48. }, {
  49. token: "keyword.operator",
  50. regex: /`/ // TODO highlight `
  51. }, {
  52. token: "string.end",
  53. regex: '"',
  54. next: "pop"
  55. }, {
  56. defaultToken: "string"
  57. }]
  58. }, {
  59. token: "string",
  60. regex: "\\$'",
  61. push: [{
  62. token: "constant.language.escape",
  63. regex: /\\(?:[abeEfnrtv\\'"]|x[a-fA-F\d]{1,2}|u[a-fA-F\d]{4}([a-fA-F\d]{4})?|c.|\d{1,3})/
  64. }, {
  65. token: "string",
  66. regex: "'",
  67. next: "pop"
  68. }, {
  69. defaultToken: "string"
  70. }]
  71. }, {
  72. regex: "<<<",
  73. token: "keyword.operator"
  74. }, {
  75. stateName: "heredoc",
  76. regex: "(<<-?)(\\s*)(['\"`]?)([\\w\\-]+)(['\"`]?)",
  77. onMatch: function (value, currentState, stack) {
  78. var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
  79. var tokens = value.split(this.splitRegex);
  80. stack.push(next, tokens[4]);
  81. return [
  82. { type: "constant", value: tokens[1] },
  83. { type: "text", value: tokens[2] },
  84. { type: "string", value: tokens[3] },
  85. { type: "support.class", value: tokens[4] },
  86. { type: "string", value: tokens[5] }
  87. ];
  88. },
  89. rules: {
  90. heredoc: [{
  91. onMatch: function (value, currentState, stack) {
  92. if (value === stack[1]) {
  93. stack.shift();
  94. stack.shift();
  95. this.next = stack[0] || "start";
  96. return "support.class";
  97. }
  98. this.next = "";
  99. return "string";
  100. },
  101. regex: ".*$",
  102. next: "start"
  103. }],
  104. indentedHeredoc: [{
  105. token: "string",
  106. regex: "^\t+"
  107. }, {
  108. onMatch: function (value, currentState, stack) {
  109. if (value === stack[1]) {
  110. stack.shift();
  111. stack.shift();
  112. this.next = stack[0] || "start";
  113. return "support.class";
  114. }
  115. this.next = "";
  116. return "string";
  117. },
  118. regex: ".*$",
  119. next: "start"
  120. }]
  121. }
  122. }, {
  123. regex: "$",
  124. token: "empty",
  125. next: function (currentState, stack) {
  126. if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
  127. return stack[0];
  128. return currentState;
  129. }
  130. }, {
  131. token: ["keyword", "text", "text", "text", "variable"],
  132. regex: /(declare|local|readonly)(\s+)(?:(-[fixar]+)(\s+))?([a-zA-Z_][a-zA-Z0-9_]*\b)/
  133. }, {
  134. token: "variable.language",
  135. regex: builtinVariable
  136. }, {
  137. token: "variable",
  138. regex: variable
  139. }, {
  140. include: "variables"
  141. }, {
  142. token: "support.function",
  143. regex: func
  144. }, {
  145. token: "support.function",
  146. regex: fileDescriptor
  147. }, {
  148. token: "string",
  149. start: "'", end: "'"
  150. }, {
  151. token: "constant.numeric",
  152. regex: floatNumber
  153. }, {
  154. token: "constant.numeric",
  155. regex: integer + "\\b"
  156. }, {
  157. token: keywordMapper,
  158. regex: "[a-zA-Z_][a-zA-Z0-9_]*\\b"
  159. }, {
  160. token: "keyword.operator",
  161. regex: "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!=|[%&|`]"
  162. }, {
  163. token: "punctuation.operator",
  164. regex: ";"
  165. }, {
  166. token: "paren.lparen",
  167. regex: "[\\[\\(\\{]"
  168. }, {
  169. token: "paren.rparen",
  170. regex: "[\\]]"
  171. }, {
  172. token: "paren.rparen",
  173. regex: "[\\)\\}]",
  174. next: "pop"
  175. }],
  176. variables: [{
  177. token: "variable",
  178. regex: /(\$)(\w+)/
  179. }, {
  180. token: ["variable", "paren.lparen"],
  181. regex: /(\$)(\()/,
  182. push: "start"
  183. }, {
  184. token: ["variable", "paren.lparen", "keyword.operator", "variable", "keyword.operator"],
  185. regex: /(\$)(\{)([#!]?)(\w+|[*@#?\-$!0_])(:[?+\-=]?|##?|%%?|,,?\/|\^\^?)?/,
  186. push: "start"
  187. }, {
  188. token: "variable",
  189. regex: /\$[*@#?\-$!0_]/
  190. }, {
  191. token: ["variable", "paren.lparen"],
  192. regex: /(\$)(\{)/,
  193. push: "start"
  194. }]
  195. };
  196. this.normalizeRules();
  197. };
  198. oop.inherits(ShHighlightRules, TextHighlightRules);
  199. exports.ShHighlightRules = ShHighlightRules;
  200. });
  201. ace.define("ace/mode/makefile_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/sh_highlight_rules"], function(require, exports, module){"use strict";
  202. var oop = require("../lib/oop");
  203. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  204. var ShHighlightFile = require("./sh_highlight_rules");
  205. var MakefileHighlightRules = function () {
  206. var keywordMapper = this.createKeywordMapper({
  207. "keyword": ShHighlightFile.reservedKeywords,
  208. "support.function.builtin": ShHighlightFile.languageConstructs,
  209. "invalid.deprecated": "debugger"
  210. }, "string");
  211. this.$rules =
  212. {
  213. "start": [
  214. {
  215. token: "string.interpolated.backtick.makefile",
  216. regex: "`",
  217. next: "shell-start"
  218. },
  219. {
  220. token: "punctuation.definition.comment.makefile",
  221. regex: /#(?=.)/,
  222. next: "comment"
  223. },
  224. {
  225. token: ["keyword.control.makefile"],
  226. regex: "^(?:\\s*\\b)(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)(?:\\b)"
  227. },
  228. {
  229. token: ["entity.name.function.makefile", "text"],
  230. regex: "^([^\\t ]+(?:\\s[^\\t ]+)*:)(\\s*.*)"
  231. }
  232. ],
  233. "comment": [
  234. {
  235. token: "punctuation.definition.comment.makefile",
  236. regex: /.+\\/
  237. },
  238. {
  239. token: "punctuation.definition.comment.makefile",
  240. regex: ".+",
  241. next: "start"
  242. }
  243. ],
  244. "shell-start": [
  245. {
  246. token: keywordMapper,
  247. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  248. },
  249. {
  250. token: "string",
  251. regex: "\\w+"
  252. },
  253. {
  254. token: "string.interpolated.backtick.makefile",
  255. regex: "`",
  256. next: "start"
  257. }
  258. ]
  259. };
  260. };
  261. oop.inherits(MakefileHighlightRules, TextHighlightRules);
  262. exports.MakefileHighlightRules = MakefileHighlightRules;
  263. });
  264. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
  265. var oop = require("../../lib/oop");
  266. var BaseFoldMode = require("./fold_mode").FoldMode;
  267. var Range = require("../../range").Range;
  268. var FoldMode = exports.FoldMode = function () { };
  269. oop.inherits(FoldMode, BaseFoldMode);
  270. (function () {
  271. this.getFoldWidgetRange = function (session, foldStyle, row) {
  272. var range = this.indentationBlock(session, row);
  273. if (range)
  274. return range;
  275. var re = /\S/;
  276. var line = session.getLine(row);
  277. var startLevel = line.search(re);
  278. if (startLevel == -1 || line[startLevel] != "#")
  279. return;
  280. var startColumn = line.length;
  281. var maxRow = session.getLength();
  282. var startRow = row;
  283. var endRow = row;
  284. while (++row < maxRow) {
  285. line = session.getLine(row);
  286. var level = line.search(re);
  287. if (level == -1)
  288. continue;
  289. if (line[level] != "#")
  290. break;
  291. endRow = row;
  292. }
  293. if (endRow > startRow) {
  294. var endColumn = session.getLine(endRow).length;
  295. return new Range(startRow, startColumn, endRow, endColumn);
  296. }
  297. };
  298. this.getFoldWidget = function (session, foldStyle, row) {
  299. var line = session.getLine(row);
  300. var indent = line.search(/\S/);
  301. var next = session.getLine(row + 1);
  302. var prev = session.getLine(row - 1);
  303. var prevIndent = prev.search(/\S/);
  304. var nextIndent = next.search(/\S/);
  305. if (indent == -1) {
  306. session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
  307. return "";
  308. }
  309. if (prevIndent == -1) {
  310. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  311. session.foldWidgets[row - 1] = "";
  312. session.foldWidgets[row + 1] = "";
  313. return "start";
  314. }
  315. }
  316. else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  317. if (session.getLine(row - 2).search(/\S/) == -1) {
  318. session.foldWidgets[row - 1] = "start";
  319. session.foldWidgets[row + 1] = "";
  320. return "";
  321. }
  322. }
  323. if (prevIndent != -1 && prevIndent < indent)
  324. session.foldWidgets[row - 1] = "start";
  325. else
  326. session.foldWidgets[row - 1] = "";
  327. if (indent < nextIndent)
  328. return "start";
  329. else
  330. return "";
  331. };
  332. }).call(FoldMode.prototype);
  333. });
  334. ace.define("ace/mode/makefile",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/makefile_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module){/*
  335. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  336. */
  337. "use strict";
  338. var oop = require("../lib/oop");
  339. var TextMode = require("./text").Mode;
  340. var MakefileHighlightRules = require("./makefile_highlight_rules").MakefileHighlightRules;
  341. var FoldMode = require("./folding/coffee").FoldMode;
  342. var Mode = function () {
  343. this.HighlightRules = MakefileHighlightRules;
  344. this.foldingRules = new FoldMode();
  345. this.$behaviour = this.$defaultBehaviour;
  346. };
  347. oop.inherits(Mode, TextMode);
  348. (function () {
  349. this.lineCommentStart = "#";
  350. this.$indentWithTabs = true;
  351. this.$id = "ace/mode/makefile";
  352. this.snippetFileId = "ace/snippets/makefile";
  353. }).call(Mode.prototype);
  354. exports.Mode = Mode;
  355. }); (function() {
  356. ace.require(["ace/mode/makefile"], function(m) {
  357. if (typeof module == "object" && typeof exports == "object" && module) {
  358. module.exports = m;
  359. }
  360. });
  361. })();