| 1 |
ace.define("ace/mode/haskell_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 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 |
}); |
| 178 |
|
| 179 |
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"; |
| 180 |
var oop = require("../../lib/oop"); |
| 181 |
var Range = require("../../range").Range; |
| 182 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 183 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 184 |
if (commentRegex) { |
| 185 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 186 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 187 |
} |
| 188 |
}; |
| 189 |
oop.inherits(FoldMode, BaseFoldMode); |
| 190 |
(function () { |
| 191 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 192 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 193 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 194 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 195 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 196 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 197 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 198 |
var line = session.getLine(row); |
| 199 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 200 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 201 |
return ""; |
| 202 |
} |
| 203 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 204 |
if (!fw && this.startRegionRe.test(line)) |
| 205 |
return "start"; |
| 206 |
return fw; |
| 207 |
}; |
| 208 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 209 |
var line = session.getLine(row); |
| 210 |
if (this.startRegionRe.test(line)) |
| 211 |
return this.getCommentRegionBlock(session, line, row); |
| 212 |
var match = line.match(this.foldingStartMarker); |
| 213 |
if (match) { |
| 214 |
var i = match.index; |
| 215 |
if (match[1]) |
| 216 |
return this.openingBracketBlock(session, match[1], row, i); |
| 217 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 218 |
if (range && !range.isMultiLine()) { |
| 219 |
if (forceMultiline) { |
| 220 |
range = this.getSectionRange(session, row); |
| 221 |
} |
| 222 |
else if (foldStyle != "all") |
| 223 |
range = null; |
| 224 |
} |
| 225 |
return range; |
| 226 |
} |
| 227 |
if (foldStyle === "markbegin") |
| 228 |
return; |
| 229 |
var match = line.match(this.foldingStopMarker); |
| 230 |
if (match) { |
| 231 |
var i = match.index + match[0].length; |
| 232 |
if (match[1]) |
| 233 |
return this.closingBracketBlock(session, match[1], row, i); |
| 234 |
return session.getCommentFoldRange(row, i, -1); |
| 235 |
} |
| 236 |
}; |
| 237 |
this.getSectionRange = function (session, row) { |
| 238 |
var line = session.getLine(row); |
| 239 |
var startIndent = line.search(/\S/); |
| 240 |
var startRow = row; |
| 241 |
var startColumn = line.length; |
| 242 |
row = row + 1; |
| 243 |
var endRow = row; |
| 244 |
var maxRow = session.getLength(); |
| 245 |
while (++row < maxRow) { |
| 246 |
line = session.getLine(row); |
| 247 |
var indent = line.search(/\S/); |
| 248 |
if (indent === -1) |
| 249 |
continue; |
| 250 |
if (startIndent > indent) |
| 251 |
break; |
| 252 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 253 |
if (subRange) { |
| 254 |
if (subRange.start.row <= startRow) { |
| 255 |
break; |
| 256 |
} |
| 257 |
else if (subRange.isMultiLine()) { |
| 258 |
row = subRange.end.row; |
| 259 |
} |
| 260 |
else if (startIndent == indent) { |
| 261 |
break; |
| 262 |
} |
| 263 |
} |
| 264 |
endRow = row; |
| 265 |
} |
| 266 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 267 |
}; |
| 268 |
this.getCommentRegionBlock = function (session, line, row) { |
| 269 |
var startColumn = line.search(/\s*$/); |
| 270 |
var maxRow = session.getLength(); |
| 271 |
var startRow = row; |
| 272 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 273 |
var depth = 1; |
| 274 |
while (++row < maxRow) { |
| 275 |
line = session.getLine(row); |
| 276 |
var m = re.exec(line); |
| 277 |
if (!m) |
| 278 |
continue; |
| 279 |
if (m[1]) |
| 280 |
depth--; |
| 281 |
else |
| 282 |
depth++; |
| 283 |
if (!depth) |
| 284 |
break; |
| 285 |
} |
| 286 |
var endRow = row; |
| 287 |
if (endRow > startRow) { |
| 288 |
return new Range(startRow, startColumn, endRow, line.length); |
| 289 |
} |
| 290 |
}; |
| 291 |
}).call(FoldMode.prototype); |
| 292 |
|
| 293 |
}); |
| 294 |
|
| 295 |
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){ |
| 296 |
|
| 297 |
|
| 298 |
"use strict"; |
| 299 |
var oop = require("../lib/oop"); |
| 300 |
var TextMode = require("./text").Mode; |
| 301 |
var HaskellHighlightRules = require("./haskell_highlight_rules").HaskellHighlightRules; |
| 302 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 303 |
var Mode = function () { |
| 304 |
this.HighlightRules = HaskellHighlightRules; |
| 305 |
this.foldingRules = new FoldMode(); |
| 306 |
this.$behaviour = this.$defaultBehaviour; |
| 307 |
}; |
| 308 |
oop.inherits(Mode, TextMode); |
| 309 |
(function () { |
| 310 |
this.lineCommentStart = "--"; |
| 311 |
this.blockComment = null; |
| 312 |
this.$id = "ace/mode/haskell"; |
| 313 |
this.snippetFileId = "ace/snippets/haskell"; |
| 314 |
}).call(Mode.prototype); |
| 315 |
exports.Mode = Mode; |
| 316 |
|
| 317 |
}); (function() { |
| 318 |
ace.require(["ace/mode/haskell"], function(m) { |
| 319 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 320 |
module.exports = m; |
| 321 |
} |
| 322 |
}); |
| 323 |
})(); |
| 324 |
|