Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/haskell
File: haskell.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
CodeMirror.defineMode("haskell", function(_config, modeConfig) {
[13] Fix | Delete
[14] Fix | Delete
function switchState(source, setState, f) {
[15] Fix | Delete
setState(f);
[16] Fix | Delete
return f(source, setState);
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
// These should all be Unicode extended, as per the Haskell 2010 report
[20] Fix | Delete
var smallRE = /[a-z_]/;
[21] Fix | Delete
var largeRE = /[A-Z]/;
[22] Fix | Delete
var digitRE = /\d/;
[23] Fix | Delete
var hexitRE = /[0-9A-Fa-f]/;
[24] Fix | Delete
var octitRE = /[0-7]/;
[25] Fix | Delete
var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
[26] Fix | Delete
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
[27] Fix | Delete
var specialRE = /[(),;[\]`{}]/;
[28] Fix | Delete
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
[29] Fix | Delete
[30] Fix | Delete
function normal(source, setState) {
[31] Fix | Delete
if (source.eatWhile(whiteCharRE)) {
[32] Fix | Delete
return null;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
var ch = source.next();
[36] Fix | Delete
if (specialRE.test(ch)) {
[37] Fix | Delete
if (ch == '{' && source.eat('-')) {
[38] Fix | Delete
var t = "comment";
[39] Fix | Delete
if (source.eat('#')) {
[40] Fix | Delete
t = "meta";
[41] Fix | Delete
}
[42] Fix | Delete
return switchState(source, setState, ncomment(t, 1));
[43] Fix | Delete
}
[44] Fix | Delete
return null;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
if (ch == '\'') {
[48] Fix | Delete
if (source.eat('\\')) {
[49] Fix | Delete
source.next(); // should handle other escapes here
[50] Fix | Delete
}
[51] Fix | Delete
else {
[52] Fix | Delete
source.next();
[53] Fix | Delete
}
[54] Fix | Delete
if (source.eat('\'')) {
[55] Fix | Delete
return "string";
[56] Fix | Delete
}
[57] Fix | Delete
return "error";
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
if (ch == '"') {
[61] Fix | Delete
return switchState(source, setState, stringLiteral);
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
if (largeRE.test(ch)) {
[65] Fix | Delete
source.eatWhile(idRE);
[66] Fix | Delete
if (source.eat('.')) {
[67] Fix | Delete
return "qualifier";
[68] Fix | Delete
}
[69] Fix | Delete
return "variable-2";
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if (smallRE.test(ch)) {
[73] Fix | Delete
source.eatWhile(idRE);
[74] Fix | Delete
return "variable";
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if (digitRE.test(ch)) {
[78] Fix | Delete
if (ch == '0') {
[79] Fix | Delete
if (source.eat(/[xX]/)) {
[80] Fix | Delete
source.eatWhile(hexitRE); // should require at least 1
[81] Fix | Delete
return "integer";
[82] Fix | Delete
}
[83] Fix | Delete
if (source.eat(/[oO]/)) {
[84] Fix | Delete
source.eatWhile(octitRE); // should require at least 1
[85] Fix | Delete
return "number";
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
source.eatWhile(digitRE);
[89] Fix | Delete
var t = "number";
[90] Fix | Delete
if (source.match(/^\.\d+/)) {
[91] Fix | Delete
t = "number";
[92] Fix | Delete
}
[93] Fix | Delete
if (source.eat(/[eE]/)) {
[94] Fix | Delete
t = "number";
[95] Fix | Delete
source.eat(/[-+]/);
[96] Fix | Delete
source.eatWhile(digitRE); // should require at least 1
[97] Fix | Delete
}
[98] Fix | Delete
return t;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
if (ch == "." && source.eat("."))
[102] Fix | Delete
return "keyword";
[103] Fix | Delete
[104] Fix | Delete
if (symbolRE.test(ch)) {
[105] Fix | Delete
if (ch == '-' && source.eat(/-/)) {
[106] Fix | Delete
source.eatWhile(/-/);
[107] Fix | Delete
if (!source.eat(symbolRE)) {
[108] Fix | Delete
source.skipToEnd();
[109] Fix | Delete
return "comment";
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
var t = "variable";
[113] Fix | Delete
if (ch == ':') {
[114] Fix | Delete
t = "variable-2";
[115] Fix | Delete
}
[116] Fix | Delete
source.eatWhile(symbolRE);
[117] Fix | Delete
return t;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
return "error";
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
function ncomment(type, nest) {
[124] Fix | Delete
if (nest == 0) {
[125] Fix | Delete
return normal;
[126] Fix | Delete
}
[127] Fix | Delete
return function(source, setState) {
[128] Fix | Delete
var currNest = nest;
[129] Fix | Delete
while (!source.eol()) {
[130] Fix | Delete
var ch = source.next();
[131] Fix | Delete
if (ch == '{' && source.eat('-')) {
[132] Fix | Delete
++currNest;
[133] Fix | Delete
}
[134] Fix | Delete
else if (ch == '-' && source.eat('}')) {
[135] Fix | Delete
--currNest;
[136] Fix | Delete
if (currNest == 0) {
[137] Fix | Delete
setState(normal);
[138] Fix | Delete
return type;
[139] Fix | Delete
}
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
setState(ncomment(type, currNest));
[143] Fix | Delete
return type;
[144] Fix | Delete
};
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
function stringLiteral(source, setState) {
[148] Fix | Delete
while (!source.eol()) {
[149] Fix | Delete
var ch = source.next();
[150] Fix | Delete
if (ch == '"') {
[151] Fix | Delete
setState(normal);
[152] Fix | Delete
return "string";
[153] Fix | Delete
}
[154] Fix | Delete
if (ch == '\\') {
[155] Fix | Delete
if (source.eol() || source.eat(whiteCharRE)) {
[156] Fix | Delete
setState(stringGap);
[157] Fix | Delete
return "string";
[158] Fix | Delete
}
[159] Fix | Delete
if (source.eat('&')) {
[160] Fix | Delete
}
[161] Fix | Delete
else {
[162] Fix | Delete
source.next(); // should handle other escapes here
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
setState(normal);
[167] Fix | Delete
return "error";
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
function stringGap(source, setState) {
[171] Fix | Delete
if (source.eat('\\')) {
[172] Fix | Delete
return switchState(source, setState, stringLiteral);
[173] Fix | Delete
}
[174] Fix | Delete
source.next();
[175] Fix | Delete
setState(normal);
[176] Fix | Delete
return "error";
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
[180] Fix | Delete
var wellKnownWords = (function() {
[181] Fix | Delete
var wkw = {};
[182] Fix | Delete
function setType(t) {
[183] Fix | Delete
return function () {
[184] Fix | Delete
for (var i = 0; i < arguments.length; i++)
[185] Fix | Delete
wkw[arguments[i]] = t;
[186] Fix | Delete
};
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
setType("keyword")(
[190] Fix | Delete
"case", "class", "data", "default", "deriving", "do", "else", "foreign",
[191] Fix | Delete
"if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
[192] Fix | Delete
"module", "newtype", "of", "then", "type", "where", "_");
[193] Fix | Delete
[194] Fix | Delete
setType("keyword")(
[195] Fix | Delete
"\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
[196] Fix | Delete
[197] Fix | Delete
setType("builtin")(
[198] Fix | Delete
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
[199] Fix | Delete
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
[200] Fix | Delete
[201] Fix | Delete
setType("builtin")(
[202] Fix | Delete
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
[203] Fix | Delete
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
[204] Fix | Delete
"IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left",
[205] Fix | Delete
"Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
[206] Fix | Delete
"ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
[207] Fix | Delete
"String", "True");
[208] Fix | Delete
[209] Fix | Delete
setType("builtin")(
[210] Fix | Delete
"abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
[211] Fix | Delete
"asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
[212] Fix | Delete
"compare", "concat", "concatMap", "const", "cos", "cosh", "curry",
[213] Fix | Delete
"cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either",
[214] Fix | Delete
"elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo",
[215] Fix | Delete
"enumFromTo", "error", "even", "exp", "exponent", "fail", "filter",
[216] Fix | Delete
"flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap",
[217] Fix | Delete
"foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger",
[218] Fix | Delete
"fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents",
[219] Fix | Delete
"getLine", "head", "id", "init", "interact", "ioError", "isDenormalized",
[220] Fix | Delete
"isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last",
[221] Fix | Delete
"lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map",
[222] Fix | Delete
"mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound",
[223] Fix | Delete
"minimum", "mod", "negate", "not", "notElem", "null", "odd", "or",
[224] Fix | Delete
"otherwise", "pi", "pred", "print", "product", "properFraction",
[225] Fix | Delete
"putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile",
[226] Fix | Delete
"readIO", "readList", "readLn", "readParen", "reads", "readsPrec",
[227] Fix | Delete
"realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse",
[228] Fix | Delete
"round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq",
[229] Fix | Delete
"sequence", "sequence_", "show", "showChar", "showList", "showParen",
[230] Fix | Delete
"showString", "shows", "showsPrec", "significand", "signum", "sin",
[231] Fix | Delete
"sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum",
[232] Fix | Delete
"tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger",
[233] Fix | Delete
"toRational", "truncate", "uncurry", "undefined", "unlines", "until",
[234] Fix | Delete
"unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
[235] Fix | Delete
"zip3", "zipWith", "zipWith3");
[236] Fix | Delete
[237] Fix | Delete
var override = modeConfig.overrideKeywords;
[238] Fix | Delete
if (override) for (var word in override) if (override.hasOwnProperty(word))
[239] Fix | Delete
wkw[word] = override[word];
[240] Fix | Delete
[241] Fix | Delete
return wkw;
[242] Fix | Delete
})();
[243] Fix | Delete
[244] Fix | Delete
[245] Fix | Delete
[246] Fix | Delete
return {
[247] Fix | Delete
startState: function () { return { f: normal }; },
[248] Fix | Delete
copyState: function (s) { return { f: s.f }; },
[249] Fix | Delete
[250] Fix | Delete
token: function(stream, state) {
[251] Fix | Delete
var t = state.f(stream, function(s) { state.f = s; });
[252] Fix | Delete
var w = stream.current();
[253] Fix | Delete
return wellKnownWords.hasOwnProperty(w) ? wellKnownWords[w] : t;
[254] Fix | Delete
},
[255] Fix | Delete
[256] Fix | Delete
blockCommentStart: "{-",
[257] Fix | Delete
blockCommentEnd: "-}",
[258] Fix | Delete
lineComment: "--"
[259] Fix | Delete
};
[260] Fix | Delete
[261] Fix | Delete
});
[262] Fix | Delete
[263] Fix | Delete
CodeMirror.defineMIME("text/x-haskell", "haskell");
[264] Fix | Delete
[265] Fix | Delete
});
[266] Fix | Delete
[267] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function