Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/crystal
File: crystal.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("crystal", function(config) {
[13] Fix | Delete
function wordRegExp(words, end) {
[14] Fix | Delete
return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b"));
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
function chain(tokenize, stream, state) {
[18] Fix | Delete
state.tokenize.push(tokenize);
[19] Fix | Delete
return tokenize(stream, state);
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/;
[23] Fix | Delete
var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/;
[24] Fix | Delete
var indexingOperators = /^(?:\[\][?=]?)/;
[25] Fix | Delete
var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/;
[26] Fix | Delete
var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
[27] Fix | Delete
var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
[28] Fix | Delete
var keywords = wordRegExp([
[29] Fix | Delete
"abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do",
[30] Fix | Delete
"else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", "ifdef",
[31] Fix | Delete
"include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof",
[32] Fix | Delete
"private", "protected", "rescue", "return", "require", "sizeof", "struct",
[33] Fix | Delete
"super", "then", "type", "typeof", "union", "unless", "until", "when", "while", "with",
[34] Fix | Delete
"yield", "__DIR__", "__FILE__", "__LINE__"
[35] Fix | Delete
]);
[36] Fix | Delete
var atomWords = wordRegExp(["true", "false", "nil", "self"]);
[37] Fix | Delete
var indentKeywordsArray = [
[38] Fix | Delete
"def", "fun", "macro",
[39] Fix | Delete
"class", "module", "struct", "lib", "enum", "union",
[40] Fix | Delete
"if", "unless", "case", "while", "until", "begin", "then",
[41] Fix | Delete
"do",
[42] Fix | Delete
"for", "ifdef"
[43] Fix | Delete
];
[44] Fix | Delete
var indentKeywords = wordRegExp(indentKeywordsArray);
[45] Fix | Delete
var dedentKeywordsArray = [
[46] Fix | Delete
"end",
[47] Fix | Delete
"else", "elsif",
[48] Fix | Delete
"rescue", "ensure"
[49] Fix | Delete
];
[50] Fix | Delete
var dedentKeywords = wordRegExp(dedentKeywordsArray);
[51] Fix | Delete
var dedentPunctualsArray = ["\\)", "\\}", "\\]"];
[52] Fix | Delete
var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$");
[53] Fix | Delete
var nextTokenizer = {
[54] Fix | Delete
"def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef,
[55] Fix | Delete
"class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType,
[56] Fix | Delete
"lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType
[57] Fix | Delete
};
[58] Fix | Delete
var matching = {"[": "]", "{": "}", "(": ")", "<": ">"};
[59] Fix | Delete
[60] Fix | Delete
function tokenBase(stream, state) {
[61] Fix | Delete
if (stream.eatSpace()) {
[62] Fix | Delete
return null;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
// Macros
[66] Fix | Delete
if (state.lastToken != "\\" && stream.match("{%", false)) {
[67] Fix | Delete
return chain(tokenMacro("%", "%"), stream, state);
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if (state.lastToken != "\\" && stream.match("{{", false)) {
[71] Fix | Delete
return chain(tokenMacro("{", "}"), stream, state);
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
// Comments
[75] Fix | Delete
if (stream.peek() == "#") {
[76] Fix | Delete
stream.skipToEnd();
[77] Fix | Delete
return "comment";
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
// Variables and keywords
[81] Fix | Delete
var matched;
[82] Fix | Delete
if (stream.match(idents)) {
[83] Fix | Delete
stream.eat(/[?!]/);
[84] Fix | Delete
[85] Fix | Delete
matched = stream.current();
[86] Fix | Delete
if (stream.eat(":")) {
[87] Fix | Delete
return "atom";
[88] Fix | Delete
} else if (state.lastToken == ".") {
[89] Fix | Delete
return "property";
[90] Fix | Delete
} else if (keywords.test(matched)) {
[91] Fix | Delete
if (state.lastToken != "abstract" && indentKeywords.test(matched)) {
[92] Fix | Delete
if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0)) {
[93] Fix | Delete
state.blocks.push(matched);
[94] Fix | Delete
state.currentIndent += 1;
[95] Fix | Delete
}
[96] Fix | Delete
} else if (dedentKeywords.test(matched)) {
[97] Fix | Delete
state.blocks.pop();
[98] Fix | Delete
state.currentIndent -= 1;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
if (nextTokenizer.hasOwnProperty(matched)) {
[102] Fix | Delete
state.tokenize.push(nextTokenizer[matched]);
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
return "keyword";
[106] Fix | Delete
} else if (atomWords.test(matched)) {
[107] Fix | Delete
return "atom";
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
return "variable";
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
// Class variables and instance variables
[114] Fix | Delete
// or attributes
[115] Fix | Delete
if (stream.eat("@")) {
[116] Fix | Delete
if (stream.peek() == "[") {
[117] Fix | Delete
return chain(tokenNest("[", "]", "meta"), stream, state);
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
stream.eat("@");
[121] Fix | Delete
stream.match(idents) || stream.match(types);
[122] Fix | Delete
return "variable-2";
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
// Global variables
[126] Fix | Delete
if (stream.eat("$")) {
[127] Fix | Delete
stream.eat(/[0-9]+|\?/) || stream.match(idents) || stream.match(types);
[128] Fix | Delete
return "variable-3";
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
// Constants and types
[132] Fix | Delete
if (stream.match(types)) {
[133] Fix | Delete
return "tag";
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
// Symbols or ':' operator
[137] Fix | Delete
if (stream.eat(":")) {
[138] Fix | Delete
if (stream.eat("\"")) {
[139] Fix | Delete
return chain(tokenQuote("\"", "atom", false), stream, state);
[140] Fix | Delete
} else if (stream.match(idents) || stream.match(types) ||
[141] Fix | Delete
stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) {
[142] Fix | Delete
return "atom";
[143] Fix | Delete
}
[144] Fix | Delete
stream.eat(":");
[145] Fix | Delete
return "operator";
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
// Strings
[149] Fix | Delete
if (stream.eat("\"")) {
[150] Fix | Delete
return chain(tokenQuote("\"", "string", true), stream, state);
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
// Strings or regexps or macro variables or '%' operator
[154] Fix | Delete
if (stream.peek() == "%") {
[155] Fix | Delete
var style = "string";
[156] Fix | Delete
var embed = true;
[157] Fix | Delete
var delim;
[158] Fix | Delete
[159] Fix | Delete
if (stream.match("%r")) {
[160] Fix | Delete
// Regexps
[161] Fix | Delete
style = "string-2";
[162] Fix | Delete
delim = stream.next();
[163] Fix | Delete
} else if (stream.match("%w")) {
[164] Fix | Delete
embed = false;
[165] Fix | Delete
delim = stream.next();
[166] Fix | Delete
} else {
[167] Fix | Delete
if(delim = stream.match(/^%([^\w\s=])/)) {
[168] Fix | Delete
delim = delim[1];
[169] Fix | Delete
} else if (stream.match(/^%[a-zA-Z0-9_\u009F-\uFFFF]*/)) {
[170] Fix | Delete
// Macro variables
[171] Fix | Delete
return "meta";
[172] Fix | Delete
} else {
[173] Fix | Delete
// '%' operator
[174] Fix | Delete
return "operator";
[175] Fix | Delete
}
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
if (matching.hasOwnProperty(delim)) {
[179] Fix | Delete
delim = matching[delim];
[180] Fix | Delete
}
[181] Fix | Delete
return chain(tokenQuote(delim, style, embed), stream, state);
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// Characters
[185] Fix | Delete
if (stream.eat("'")) {
[186] Fix | Delete
stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/);
[187] Fix | Delete
stream.eat("'");
[188] Fix | Delete
return "atom";
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
// Numbers
[192] Fix | Delete
if (stream.eat("0")) {
[193] Fix | Delete
if (stream.eat("x")) {
[194] Fix | Delete
stream.match(/^[0-9a-fA-F]+/);
[195] Fix | Delete
} else if (stream.eat("o")) {
[196] Fix | Delete
stream.match(/^[0-7]+/);
[197] Fix | Delete
} else if (stream.eat("b")) {
[198] Fix | Delete
stream.match(/^[01]+/);
[199] Fix | Delete
}
[200] Fix | Delete
return "number";
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
if (stream.eat(/\d/)) {
[204] Fix | Delete
stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/);
[205] Fix | Delete
return "number";
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
// Operators
[209] Fix | Delete
if (stream.match(operators)) {
[210] Fix | Delete
stream.eat("="); // Operators can follow assign symbol.
[211] Fix | Delete
return "operator";
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
if (stream.match(conditionalOperators) || stream.match(anotherOperators)) {
[215] Fix | Delete
return "operator";
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
// Parens and braces
[219] Fix | Delete
if (matched = stream.match(/[({[]/, false)) {
[220] Fix | Delete
matched = matched[0];
[221] Fix | Delete
return chain(tokenNest(matched, matching[matched], null), stream, state);
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
// Escapes
[225] Fix | Delete
if (stream.eat("\\")) {
[226] Fix | Delete
stream.next();
[227] Fix | Delete
return "meta";
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
stream.next();
[231] Fix | Delete
return null;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
function tokenNest(begin, end, style, started) {
[235] Fix | Delete
return function (stream, state) {
[236] Fix | Delete
if (!started && stream.match(begin)) {
[237] Fix | Delete
state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true);
[238] Fix | Delete
state.currentIndent += 1;
[239] Fix | Delete
return style;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
var nextStyle = tokenBase(stream, state);
[243] Fix | Delete
if (stream.current() === end) {
[244] Fix | Delete
state.tokenize.pop();
[245] Fix | Delete
state.currentIndent -= 1;
[246] Fix | Delete
nextStyle = style;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
return nextStyle;
[250] Fix | Delete
};
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
function tokenMacro(begin, end, started) {
[254] Fix | Delete
return function (stream, state) {
[255] Fix | Delete
if (!started && stream.match("{" + begin)) {
[256] Fix | Delete
state.currentIndent += 1;
[257] Fix | Delete
state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true);
[258] Fix | Delete
return "meta";
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
if (stream.match(end + "}")) {
[262] Fix | Delete
state.currentIndent -= 1;
[263] Fix | Delete
state.tokenize.pop();
[264] Fix | Delete
return "meta";
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
return tokenBase(stream, state);
[268] Fix | Delete
};
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
function tokenMacroDef(stream, state) {
[272] Fix | Delete
if (stream.eatSpace()) {
[273] Fix | Delete
return null;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
var matched;
[277] Fix | Delete
if (matched = stream.match(idents)) {
[278] Fix | Delete
if (matched == "def") {
[279] Fix | Delete
return "keyword";
[280] Fix | Delete
}
[281] Fix | Delete
stream.eat(/[?!]/);
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
state.tokenize.pop();
[285] Fix | Delete
return "def";
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
function tokenFollowIdent(stream, state) {
[289] Fix | Delete
if (stream.eatSpace()) {
[290] Fix | Delete
return null;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
if (stream.match(idents)) {
[294] Fix | Delete
stream.eat(/[!?]/);
[295] Fix | Delete
} else {
[296] Fix | Delete
stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators);
[297] Fix | Delete
}
[298] Fix | Delete
state.tokenize.pop();
[299] Fix | Delete
return "def";
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
function tokenFollowType(stream, state) {
[303] Fix | Delete
if (stream.eatSpace()) {
[304] Fix | Delete
return null;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
stream.match(types);
[308] Fix | Delete
state.tokenize.pop();
[309] Fix | Delete
return "def";
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
function tokenQuote(end, style, embed) {
[313] Fix | Delete
return function (stream, state) {
[314] Fix | Delete
var escaped = false;
[315] Fix | Delete
[316] Fix | Delete
while (stream.peek()) {
[317] Fix | Delete
if (!escaped) {
[318] Fix | Delete
if (stream.match("{%", false)) {
[319] Fix | Delete
state.tokenize.push(tokenMacro("%", "%"));
[320] Fix | Delete
return style;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
if (stream.match("{{", false)) {
[324] Fix | Delete
state.tokenize.push(tokenMacro("{", "}"));
[325] Fix | Delete
return style;
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
if (embed && stream.match("#{", false)) {
[329] Fix | Delete
state.tokenize.push(tokenNest("#{", "}", "meta"));
[330] Fix | Delete
return style;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
var ch = stream.next();
[334] Fix | Delete
[335] Fix | Delete
if (ch == end) {
[336] Fix | Delete
state.tokenize.pop();
[337] Fix | Delete
return style;
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
escaped = ch == "\\";
[341] Fix | Delete
} else {
[342] Fix | Delete
stream.next();
[343] Fix | Delete
escaped = false;
[344] Fix | Delete
}
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
return style;
[348] Fix | Delete
};
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
return {
[352] Fix | Delete
startState: function () {
[353] Fix | Delete
return {
[354] Fix | Delete
tokenize: [tokenBase],
[355] Fix | Delete
currentIndent: 0,
[356] Fix | Delete
lastToken: null,
[357] Fix | Delete
blocks: []
[358] Fix | Delete
};
[359] Fix | Delete
},
[360] Fix | Delete
[361] Fix | Delete
token: function (stream, state) {
[362] Fix | Delete
var style = state.tokenize[state.tokenize.length - 1](stream, state);
[363] Fix | Delete
var token = stream.current();
[364] Fix | Delete
[365] Fix | Delete
if (style && style != "comment") {
[366] Fix | Delete
state.lastToken = token;
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
return style;
[370] Fix | Delete
},
[371] Fix | Delete
[372] Fix | Delete
indent: function (state, textAfter) {
[373] Fix | Delete
textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, "");
[374] Fix | Delete
[375] Fix | Delete
if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) {
[376] Fix | Delete
return config.indentUnit * (state.currentIndent - 1);
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
return config.indentUnit * state.currentIndent;
[380] Fix | Delete
},
[381] Fix | Delete
[382] Fix | Delete
fold: "indent",
[383] Fix | Delete
electricInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true),
[384] Fix | Delete
lineComment: '#'
[385] Fix | Delete
};
[386] Fix | Delete
});
[387] Fix | Delete
[388] Fix | Delete
CodeMirror.defineMIME("text/x-crystal", "crystal");
[389] Fix | Delete
});
[390] Fix | Delete
[391] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function