fc6ba43496896432983dff35a140ed34.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. ace.define("ace/mode/haskell_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was autogenerated from tm bundles\haskell.tmbundle\Syntaxes\Haskell.plist (uuid: ) */
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var HaskellHighlightRules = function () {
  6. this.$rules = { start: [{ token: ['punctuation.definition.entity.haskell',
  7. 'keyword.operator.function.infix.haskell',
  8. 'punctuation.definition.entity.haskell'],
  9. regex: '(`)([a-zA-Z_\']*?)(`)',
  10. comment: 'In case this regex seems unusual for an infix operator, note that Haskell allows any ordinary function application (elem 4 [1..10]) to be rewritten as an infix expression (4 `elem` [1..10]).' },
  11. { token: 'constant.language.unit.haskell', regex: '\\(\\)' },
  12. { token: 'constant.language.empty-list.haskell',
  13. regex: '\\[\\]' },
  14. { token: 'keyword.other.haskell',
  15. regex: '\\b(module|signature)\\b',
  16. push: [{ token: 'keyword.other.haskell', regex: '\\bwhere\\b', next: 'pop' },
  17. { include: '#module_name' },
  18. { include: '#module_exports' },
  19. { token: 'invalid', regex: '[a-z]+' },
  20. { defaultToken: 'meta.declaration.module.haskell' }] },
  21. { token: 'keyword.other.haskell',
  22. regex: '\\bclass\\b',
  23. push: [{ token: 'keyword.other.haskell',
  24. regex: '\\bwhere\\b',
  25. next: 'pop' },
  26. { token: 'support.class.prelude.haskell',
  27. regex: '\\b(?:Monad|Functor|Eq|Ord|Read|Show|Num|(?:Frac|Ra)tional|Enum|Bounded|Real(?:Frac|Float)?|Integral|Floating)\\b' },
  28. { token: 'entity.other.inherited-class.haskell',
  29. regex: '[A-Z][A-Za-z_\']*' },
  30. { token: 'variable.other.generic-type.haskell',
  31. regex: '\\b[a-z][a-zA-Z0-9_\']*\\b' },
  32. { defaultToken: 'meta.declaration.class.haskell' }] },
  33. { token: 'keyword.other.haskell',
  34. regex: '\\binstance\\b',
  35. push: [{ token: 'keyword.other.haskell',
  36. regex: '\\bwhere\\b|$',
  37. next: 'pop' },
  38. { include: '#type_signature' },
  39. { defaultToken: 'meta.declaration.instance.haskell' }] },
  40. { token: 'keyword.other.haskell',
  41. regex: 'import',
  42. push: [{ token: 'meta.import.haskell', regex: '$|;|^', next: 'pop' },
  43. { token: 'keyword.other.haskell', regex: 'qualified|as|hiding' },
  44. { include: '#module_name' },
  45. { include: '#module_exports' },
  46. { defaultToken: 'meta.import.haskell' }] },
  47. { token: ['keyword.other.haskell', 'meta.deriving.haskell'],
  48. regex: '(deriving)(\\s*\\()',
  49. push: [{ token: 'meta.deriving.haskell', regex: '\\)', next: 'pop' },
  50. { token: 'entity.other.inherited-class.haskell',
  51. regex: '\\b[A-Z][a-zA-Z_\']*' },
  52. { defaultToken: 'meta.deriving.haskell' }] },
  53. { token: 'keyword.other.haskell',
  54. regex: '\\b(?:deriving|where|data|type|case|of|let|in|newtype|default)\\b' },
  55. { token: 'keyword.operator.haskell', regex: '\\binfix[lr]?\\b' },
  56. { token: 'keyword.control.haskell',
  57. regex: '\\b(?:do|if|then|else)\\b' },
  58. { token: 'constant.numeric.float.haskell',
  59. regex: '\\b(?:[0-9]+\\.[0-9]+(?:[eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b',
  60. comment: 'Floats are always decimal' },
  61. { token: 'constant.numeric.haskell',
  62. regex: '\\b(?:[0-9]+|0(?:[xX][0-9a-fA-F]+|[oO][0-7]+))\\b' },
  63. { token: ['meta.preprocessor.c',
  64. 'punctuation.definition.preprocessor.c',
  65. 'meta.preprocessor.c'],
  66. regex: '^(\\s*)(#)(\\s*\\w+)',
  67. comment: 'In addition to Haskell\'s "native" syntax, GHC permits the C preprocessor to be run on a source file.' },
  68. { include: '#pragma' },
  69. { token: 'punctuation.definition.string.begin.haskell',
  70. regex: '"',
  71. push: [{ token: 'punctuation.definition.string.end.haskell',
  72. regex: '"',
  73. next: 'pop' },
  74. { token: 'constant.character.escape.haskell',
  75. regex: '\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&])' },
  76. { token: 'constant.character.escape.octal.haskell',
  77. regex: '\\\\o[0-7]+|\\\\x[0-9A-Fa-f]+|\\\\[0-9]+' },
  78. { token: 'constant.character.escape.control.haskell',
  79. regex: '\\^[A-Z@\\[\\]\\\\\\^_]' },
  80. { defaultToken: 'string.quoted.double.haskell' }] },
  81. { token: ['punctuation.definition.string.begin.haskell',
  82. 'string.quoted.single.haskell',
  83. 'constant.character.escape.haskell',
  84. 'constant.character.escape.octal.haskell',
  85. 'constant.character.escape.hexadecimal.haskell',
  86. 'constant.character.escape.control.haskell',
  87. 'punctuation.definition.string.end.haskell'],
  88. regex: '(\')(?:([\\ -\\[\\]-~])|(\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&]))|(\\\\o[0-7]+)|(\\\\x[0-9A-Fa-f]+)|(\\^[A-Z@\\[\\]\\\\\\^_]))(\')' },
  89. { token: ['meta.function.type-declaration.haskell',
  90. 'entity.name.function.haskell',
  91. 'meta.function.type-declaration.haskell',
  92. 'keyword.other.double-colon.haskell'],
  93. regex: '^(\\s*)([a-z_][a-zA-Z0-9_\']*|\\([|!%$+\\-.,=</>]+\\))(\\s*)(::)',
  94. push: [{ token: 'meta.function.type-declaration.haskell',
  95. regex: '$',
  96. next: 'pop' },
  97. { include: '#type_signature' },
  98. { defaultToken: 'meta.function.type-declaration.haskell' }] },
  99. { token: 'support.constant.haskell',
  100. regex: '\\b(?:Just|Nothing|Left|Right|True|False|LT|EQ|GT|\\(\\)|\\[\\])\\b' },
  101. { token: 'constant.other.haskell', regex: '\\b[A-Z]\\w*\\b' },
  102. { include: '#comments' },
  103. { token: 'support.function.prelude.haskell',
  104. regex: '\\b(?:abs|acos|acosh|all|and|any|appendFile|applyM|asTypeOf|asin|asinh|atan|atan2|atanh|break|catch|ceiling|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|div|divMod|drop|dropWhile|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromEnum|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|head|id|init|interact|ioError|isDenormalized|isIEEE|isInfinite|isNaN|isNegativeZero|iterate|last|lcm|length|lex|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|odd|or|otherwise|pi|pred|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|read|readFile|readIO|readList|readLn|readParen|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showList|showParen|showString|shows|showsPrec|significand|signum|sin|sinh|snd|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|toEnum|toInteger|toRational|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\\b' },
  105. { include: '#infix_op' },
  106. { token: 'keyword.operator.haskell',
  107. regex: '[|!%$?~+:\\-.=</>\\\\]+',
  108. comment: 'In case this regex seems overly general, note that Haskell permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*.' },
  109. { token: 'punctuation.separator.comma.haskell', regex: ',' }],
  110. '#block_comment': [{ token: 'punctuation.definition.comment.haskell',
  111. regex: '\\{-(?!#)',
  112. push: [{ include: '#block_comment' },
  113. { token: 'punctuation.definition.comment.haskell',
  114. regex: '-\\}',
  115. next: 'pop' },
  116. { defaultToken: 'comment.block.haskell' }] }],
  117. '#comments': [{ token: 'punctuation.definition.comment.haskell',
  118. regex: '--.*',
  119. push_: [{ token: 'comment.line.double-dash.haskell',
  120. regex: '$',
  121. next: 'pop' },
  122. { defaultToken: 'comment.line.double-dash.haskell' }] },
  123. { include: '#block_comment' }],
  124. '#infix_op': [{ token: 'entity.name.function.infix.haskell',
  125. regex: '\\([|!%$+:\\-.=</>]+\\)|\\(,+\\)' }],
  126. '#module_exports': [{ token: 'meta.declaration.exports.haskell',
  127. regex: '\\(',
  128. push: [{ token: 'meta.declaration.exports.haskell.end',
  129. regex: '\\)',
  130. next: 'pop' },
  131. { token: 'entity.name.function.haskell',
  132. regex: '\\b[a-z][a-zA-Z_\']*' },
  133. { token: 'storage.type.haskell', regex: '\\b[A-Z][A-Za-z_\']*' },
  134. { token: 'punctuation.separator.comma.haskell', regex: ',' },
  135. { include: '#infix_op' },
  136. { token: 'meta.other.unknown.haskell',
  137. regex: '\\(.*?\\)',
  138. comment: 'So named because I don\'t know what to call this.' },
  139. { defaultToken: 'meta.declaration.exports.haskell.end' }] }],
  140. '#module_name': [{ token: 'support.other.module.haskell',
  141. regex: '[A-Z][A-Za-z._\']*' }],
  142. '#pragma': [{ token: 'meta.preprocessor.haskell',
  143. regex: '\\{-#',
  144. push: [{ token: 'meta.preprocessor.haskell',
  145. regex: '#-\\}',
  146. next: 'pop' },
  147. { token: 'keyword.other.preprocessor.haskell',
  148. regex: '\\b(?:LANGUAGE|UNPACK|INLINE)\\b' },
  149. { defaultToken: 'meta.preprocessor.haskell' }] }],
  150. '#type_signature': [{ token: ['meta.class-constraint.haskell',
  151. 'entity.other.inherited-class.haskell',
  152. 'meta.class-constraint.haskell',
  153. 'variable.other.generic-type.haskell',
  154. 'meta.class-constraint.haskell',
  155. 'keyword.other.big-arrow.haskell'],
  156. regex: '(\\(\\s*)([A-Z][A-Za-z]*)(\\s+)([a-z][A-Za-z_\']*)(\\)\\s*)(=>)' },
  157. { include: '#pragma' },
  158. { token: 'keyword.other.arrow.haskell', regex: '->' },
  159. { token: 'keyword.other.big-arrow.haskell', regex: '=>' },
  160. { token: 'support.type.prelude.haskell',
  161. regex: '\\b(?:Int(?:eger)?|Maybe|Either|Bool|Float|Double|Char|String|Ordering|ShowS|ReadS|FilePath|IO(?:Error)?)\\b' },
  162. { token: 'variable.other.generic-type.haskell',
  163. regex: '\\b[a-z][a-zA-Z0-9_\']*\\b' },
  164. { token: 'storage.type.haskell',
  165. regex: '\\b[A-Z][a-zA-Z0-9_\']*\\b' },
  166. { token: 'support.constant.unit.haskell', regex: '\\(\\)' },
  167. { include: '#comments' }] };
  168. this.normalizeRules();
  169. };
  170. HaskellHighlightRules.metaData = { fileTypes: ['hs'],
  171. keyEquivalent: '^~H',
  172. name: 'Haskell',
  173. scopeName: 'source.haskell' };
  174. oop.inherits(HaskellHighlightRules, TextHighlightRules);
  175. exports.HaskellHighlightRules = HaskellHighlightRules;
  176. });
  177. 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";
  178. var oop = require("../../lib/oop");
  179. var Range = require("../../range").Range;
  180. var BaseFoldMode = require("./fold_mode").FoldMode;
  181. var FoldMode = exports.FoldMode = function (commentRegex) {
  182. if (commentRegex) {
  183. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  184. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  185. }
  186. };
  187. oop.inherits(FoldMode, BaseFoldMode);
  188. (function () {
  189. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  190. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  191. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  192. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  193. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  194. this._getFoldWidgetBase = this.getFoldWidget;
  195. this.getFoldWidget = function (session, foldStyle, row) {
  196. var line = session.getLine(row);
  197. if (this.singleLineBlockCommentRe.test(line)) {
  198. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  199. return "";
  200. }
  201. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  202. if (!fw && this.startRegionRe.test(line))
  203. return "start"; // lineCommentRegionStart
  204. return fw;
  205. };
  206. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  207. var line = session.getLine(row);
  208. if (this.startRegionRe.test(line))
  209. return this.getCommentRegionBlock(session, line, row);
  210. var match = line.match(this.foldingStartMarker);
  211. if (match) {
  212. var i = match.index;
  213. if (match[1])
  214. return this.openingBracketBlock(session, match[1], row, i);
  215. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  216. if (range && !range.isMultiLine()) {
  217. if (forceMultiline) {
  218. range = this.getSectionRange(session, row);
  219. }
  220. else if (foldStyle != "all")
  221. range = null;
  222. }
  223. return range;
  224. }
  225. if (foldStyle === "markbegin")
  226. return;
  227. var match = line.match(this.foldingStopMarker);
  228. if (match) {
  229. var i = match.index + match[0].length;
  230. if (match[1])
  231. return this.closingBracketBlock(session, match[1], row, i);
  232. return session.getCommentFoldRange(row, i, -1);
  233. }
  234. };
  235. this.getSectionRange = function (session, row) {
  236. var line = session.getLine(row);
  237. var startIndent = line.search(/\S/);
  238. var startRow = row;
  239. var startColumn = line.length;
  240. row = row + 1;
  241. var endRow = row;
  242. var maxRow = session.getLength();
  243. while (++row < maxRow) {
  244. line = session.getLine(row);
  245. var indent = line.search(/\S/);
  246. if (indent === -1)
  247. continue;
  248. if (startIndent > indent)
  249. break;
  250. var subRange = this.getFoldWidgetRange(session, "all", row);
  251. if (subRange) {
  252. if (subRange.start.row <= startRow) {
  253. break;
  254. }
  255. else if (subRange.isMultiLine()) {
  256. row = subRange.end.row;
  257. }
  258. else if (startIndent == indent) {
  259. break;
  260. }
  261. }
  262. endRow = row;
  263. }
  264. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  265. };
  266. this.getCommentRegionBlock = function (session, line, row) {
  267. var startColumn = line.search(/\s*$/);
  268. var maxRow = session.getLength();
  269. var startRow = row;
  270. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  271. var depth = 1;
  272. while (++row < maxRow) {
  273. line = session.getLine(row);
  274. var m = re.exec(line);
  275. if (!m)
  276. continue;
  277. if (m[1])
  278. depth--;
  279. else
  280. depth++;
  281. if (!depth)
  282. break;
  283. }
  284. var endRow = row;
  285. if (endRow > startRow) {
  286. return new Range(startRow, startColumn, endRow, line.length);
  287. }
  288. };
  289. }).call(FoldMode.prototype);
  290. });
  291. ace.define("ace/mode/haskell",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haskell_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  292. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  293. */
  294. "use strict";
  295. var oop = require("../lib/oop");
  296. var TextMode = require("./text").Mode;
  297. var HaskellHighlightRules = require("./haskell_highlight_rules").HaskellHighlightRules;
  298. var FoldMode = require("./folding/cstyle").FoldMode;
  299. var Mode = function () {
  300. this.HighlightRules = HaskellHighlightRules;
  301. this.foldingRules = new FoldMode();
  302. this.$behaviour = this.$defaultBehaviour;
  303. };
  304. oop.inherits(Mode, TextMode);
  305. (function () {
  306. this.lineCommentStart = "--";
  307. this.blockComment = null;
  308. this.$id = "ace/mode/haskell";
  309. this.snippetFileId = "ace/snippets/haskell";
  310. }).call(Mode.prototype);
  311. exports.Mode = Mode;
  312. }); (function() {
  313. ace.require(["ace/mode/haskell"], function(m) {
  314. if (typeof module == "object" && typeof exports == "object" && module) {
  315. module.exports = m;
  316. }
  317. });
  318. })();