Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/julia
File: julia.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("julia", function(_conf, parserConf) {
[13] Fix | Delete
var ERRORCLASS = 'error';
[14] Fix | Delete
[15] Fix | Delete
function wordRegexp(words, end) {
[16] Fix | Delete
if (typeof end === 'undefined') { end = "\\b"; }
[17] Fix | Delete
return new RegExp("^((" + words.join(")|(") + "))" + end);
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
var octChar = "\\\\[0-7]{1,3}";
[21] Fix | Delete
var hexChar = "\\\\x[A-Fa-f0-9]{1,2}";
[22] Fix | Delete
var specialChar = "\\\\[abfnrtv0%?'\"\\\\]";
[23] Fix | Delete
var singleChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
[24] Fix | Delete
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/;
[25] Fix | Delete
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
[26] Fix | Delete
var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
[27] Fix | Delete
var charsList = [octChar, hexChar, specialChar, singleChar];
[28] Fix | Delete
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
[29] Fix | Delete
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
[30] Fix | Delete
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype'];
[31] Fix | Delete
var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf'];
[32] Fix | Delete
[33] Fix | Delete
//var stringPrefixes = new RegExp("^[br]?('|\")")
[34] Fix | Delete
var stringPrefixes = /^(`|"{3}|([brv]?"))/;
[35] Fix | Delete
var chars = wordRegexp(charsList, "'");
[36] Fix | Delete
var keywords = wordRegexp(keywordList);
[37] Fix | Delete
var builtins = wordRegexp(builtinList);
[38] Fix | Delete
var openers = wordRegexp(blockOpeners);
[39] Fix | Delete
var closers = wordRegexp(blockClosers);
[40] Fix | Delete
var macro = /^@[_A-Za-z][\w]*/;
[41] Fix | Delete
var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
[42] Fix | Delete
var typeAnnotation = /^::[^,;"{()=$\s]+({[^}]*}+)*/;
[43] Fix | Delete
[44] Fix | Delete
function inArray(state) {
[45] Fix | Delete
var ch = currentScope(state);
[46] Fix | Delete
if (ch == '[') {
[47] Fix | Delete
return true;
[48] Fix | Delete
}
[49] Fix | Delete
return false;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
function currentScope(state) {
[53] Fix | Delete
if (state.scopes.length == 0) {
[54] Fix | Delete
return null;
[55] Fix | Delete
}
[56] Fix | Delete
return state.scopes[state.scopes.length - 1];
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
// tokenizers
[60] Fix | Delete
function tokenBase(stream, state) {
[61] Fix | Delete
// Handle multiline comments
[62] Fix | Delete
if (stream.match(/^#=/, false)) {
[63] Fix | Delete
state.tokenize = tokenComment;
[64] Fix | Delete
return state.tokenize(stream, state);
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
// Handle scope changes
[68] Fix | Delete
var leavingExpr = state.leavingExpr;
[69] Fix | Delete
if (stream.sol()) {
[70] Fix | Delete
leavingExpr = false;
[71] Fix | Delete
}
[72] Fix | Delete
state.leavingExpr = false;
[73] Fix | Delete
if (leavingExpr) {
[74] Fix | Delete
if (stream.match(/^'+/)) {
[75] Fix | Delete
return 'operator';
[76] Fix | Delete
}
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
if (stream.match(/^\.{2,3}/)) {
[80] Fix | Delete
return 'operator';
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
if (stream.eatSpace()) {
[84] Fix | Delete
return null;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
var ch = stream.peek();
[88] Fix | Delete
[89] Fix | Delete
// Handle single line comments
[90] Fix | Delete
if (ch === '#') {
[91] Fix | Delete
stream.skipToEnd();
[92] Fix | Delete
return 'comment';
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
if (ch === '[') {
[96] Fix | Delete
state.scopes.push('[');
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
if (ch === '(') {
[100] Fix | Delete
state.scopes.push('(');
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
var scope = currentScope(state);
[104] Fix | Delete
[105] Fix | Delete
if (scope == '[' && ch === ']') {
[106] Fix | Delete
state.scopes.pop();
[107] Fix | Delete
state.leavingExpr = true;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if (scope == '(' && ch === ')') {
[111] Fix | Delete
state.scopes.pop();
[112] Fix | Delete
state.leavingExpr = true;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
var match;
[116] Fix | Delete
if (!inArray(state) && (match=stream.match(openers, false))) {
[117] Fix | Delete
state.scopes.push(match);
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
if (!inArray(state) && stream.match(closers, false)) {
[121] Fix | Delete
state.scopes.pop();
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if (inArray(state)) {
[125] Fix | Delete
if (state.lastToken == 'end' && stream.match(/^:/)) {
[126] Fix | Delete
return 'operator';
[127] Fix | Delete
}
[128] Fix | Delete
if (stream.match(/^end/)) {
[129] Fix | Delete
return 'number';
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
if (stream.match(/^=>/)) {
[134] Fix | Delete
return 'operator';
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
// Handle Number Literals
[138] Fix | Delete
if (stream.match(/^[0-9\.]/, false)) {
[139] Fix | Delete
var imMatcher = RegExp(/^im\b/);
[140] Fix | Delete
var numberLiteral = false;
[141] Fix | Delete
// Floats
[142] Fix | Delete
if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; }
[143] Fix | Delete
if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; }
[144] Fix | Delete
if (stream.match(/^\.\d+/)) { numberLiteral = true; }
[145] Fix | Delete
if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; }
[146] Fix | Delete
// Integers
[147] Fix | Delete
if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex
[148] Fix | Delete
if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary
[149] Fix | Delete
if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal
[150] Fix | Delete
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
[151] Fix | Delete
// Zero by itself with no other piece of number.
[152] Fix | Delete
if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
[153] Fix | Delete
if (numberLiteral) {
[154] Fix | Delete
// Integer literals may be "long"
[155] Fix | Delete
stream.match(imMatcher);
[156] Fix | Delete
state.leavingExpr = true;
[157] Fix | Delete
return 'number';
[158] Fix | Delete
}
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
if (stream.match(/^<:/)) {
[162] Fix | Delete
return 'operator';
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
if (stream.match(typeAnnotation)) {
[166] Fix | Delete
return 'builtin';
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
// Handle symbols
[170] Fix | Delete
if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) {
[171] Fix | Delete
return 'builtin';
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
// Handle parametric types
[175] Fix | Delete
if (stream.match(/^{[^}]*}(?=\()/)) {
[176] Fix | Delete
return 'builtin';
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
// Handle operators and Delimiters
[180] Fix | Delete
if (stream.match(operators)) {
[181] Fix | Delete
return 'operator';
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// Handle Chars
[185] Fix | Delete
if (stream.match(/^'/)) {
[186] Fix | Delete
state.tokenize = tokenChar;
[187] Fix | Delete
return state.tokenize(stream, state);
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
// Handle Strings
[191] Fix | Delete
if (stream.match(stringPrefixes)) {
[192] Fix | Delete
state.tokenize = tokenStringFactory(stream.current());
[193] Fix | Delete
return state.tokenize(stream, state);
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
if (stream.match(macro)) {
[197] Fix | Delete
return 'meta';
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
if (stream.match(delimiters)) {
[201] Fix | Delete
return null;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
if (stream.match(keywords)) {
[205] Fix | Delete
return 'keyword';
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
if (stream.match(builtins)) {
[209] Fix | Delete
return 'builtin';
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
var isDefinition = state.isDefinition ||
[213] Fix | Delete
state.lastToken == 'function' ||
[214] Fix | Delete
state.lastToken == 'macro' ||
[215] Fix | Delete
state.lastToken == 'type' ||
[216] Fix | Delete
state.lastToken == 'immutable';
[217] Fix | Delete
[218] Fix | Delete
if (stream.match(identifiers)) {
[219] Fix | Delete
if (isDefinition) {
[220] Fix | Delete
if (stream.peek() === '.') {
[221] Fix | Delete
state.isDefinition = true;
[222] Fix | Delete
return 'variable';
[223] Fix | Delete
}
[224] Fix | Delete
state.isDefinition = false;
[225] Fix | Delete
return 'def';
[226] Fix | Delete
}
[227] Fix | Delete
if (stream.match(/^({[^}]*})*\(/, false)) {
[228] Fix | Delete
return callOrDef(stream, state);
[229] Fix | Delete
}
[230] Fix | Delete
state.leavingExpr = true;
[231] Fix | Delete
return 'variable';
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
// Handle non-detected items
[235] Fix | Delete
stream.next();
[236] Fix | Delete
return ERRORCLASS;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
function callOrDef(stream, state) {
[240] Fix | Delete
var match = stream.match(/^(\(\s*)/);
[241] Fix | Delete
if (match) {
[242] Fix | Delete
if (state.firstParenPos < 0)
[243] Fix | Delete
state.firstParenPos = state.scopes.length;
[244] Fix | Delete
state.scopes.push('(');
[245] Fix | Delete
state.charsAdvanced += match[1].length;
[246] Fix | Delete
}
[247] Fix | Delete
if (currentScope(state) == '(' && stream.match(/^\)/)) {
[248] Fix | Delete
state.scopes.pop();
[249] Fix | Delete
state.charsAdvanced += 1;
[250] Fix | Delete
if (state.scopes.length <= state.firstParenPos) {
[251] Fix | Delete
var isDefinition = stream.match(/^\s*?=(?!=)/, false);
[252] Fix | Delete
stream.backUp(state.charsAdvanced);
[253] Fix | Delete
state.firstParenPos = -1;
[254] Fix | Delete
state.charsAdvanced = 0;
[255] Fix | Delete
if (isDefinition)
[256] Fix | Delete
return 'def';
[257] Fix | Delete
return 'builtin';
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
// Unfortunately javascript does not support multiline strings, so we have
[261] Fix | Delete
// to undo anything done upto here if a function call or definition splits
[262] Fix | Delete
// over two or more lines.
[263] Fix | Delete
if (stream.match(/^$/g, false)) {
[264] Fix | Delete
stream.backUp(state.charsAdvanced);
[265] Fix | Delete
while (state.scopes.length > state.firstParenPos)
[266] Fix | Delete
state.scopes.pop();
[267] Fix | Delete
state.firstParenPos = -1;
[268] Fix | Delete
state.charsAdvanced = 0;
[269] Fix | Delete
return 'builtin';
[270] Fix | Delete
}
[271] Fix | Delete
state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
[272] Fix | Delete
return callOrDef(stream, state);
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
function tokenComment(stream, state) {
[276] Fix | Delete
if (stream.match(/^#=/)) {
[277] Fix | Delete
state.weakScopes++;
[278] Fix | Delete
}
[279] Fix | Delete
if (!stream.match(/.*?(?=(#=|=#))/)) {
[280] Fix | Delete
stream.skipToEnd();
[281] Fix | Delete
}
[282] Fix | Delete
if (stream.match(/^=#/)) {
[283] Fix | Delete
state.weakScopes--;
[284] Fix | Delete
if (state.weakScopes == 0)
[285] Fix | Delete
state.tokenize = tokenBase;
[286] Fix | Delete
}
[287] Fix | Delete
return 'comment';
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
function tokenChar(stream, state) {
[291] Fix | Delete
var isChar = false, match;
[292] Fix | Delete
if (stream.match(chars)) {
[293] Fix | Delete
isChar = true;
[294] Fix | Delete
} else if (match = stream.match(/\\u([a-f0-9]{1,4})(?=')/i)) {
[295] Fix | Delete
var value = parseInt(match[1], 16);
[296] Fix | Delete
if (value <= 55295 || value >= 57344) { // (U+0,U+D7FF), (U+E000,U+FFFF)
[297] Fix | Delete
isChar = true;
[298] Fix | Delete
stream.next();
[299] Fix | Delete
}
[300] Fix | Delete
} else if (match = stream.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)) {
[301] Fix | Delete
var value = parseInt(match[1], 16);
[302] Fix | Delete
if (value <= 1114111) { // U+10FFFF
[303] Fix | Delete
isChar = true;
[304] Fix | Delete
stream.next();
[305] Fix | Delete
}
[306] Fix | Delete
}
[307] Fix | Delete
if (isChar) {
[308] Fix | Delete
state.leavingExpr = true;
[309] Fix | Delete
state.tokenize = tokenBase;
[310] Fix | Delete
return 'string';
[311] Fix | Delete
}
[312] Fix | Delete
if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); }
[313] Fix | Delete
if (stream.match(/^'/)) { state.tokenize = tokenBase; }
[314] Fix | Delete
return ERRORCLASS;
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
function tokenStringFactory(delimiter) {
[318] Fix | Delete
while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
[319] Fix | Delete
delimiter = delimiter.substr(1);
[320] Fix | Delete
}
[321] Fix | Delete
var OUTCLASS = 'string';
[322] Fix | Delete
[323] Fix | Delete
function tokenString(stream, state) {
[324] Fix | Delete
while (!stream.eol()) {
[325] Fix | Delete
stream.eatWhile(/[^"\\]/);
[326] Fix | Delete
if (stream.eat('\\')) {
[327] Fix | Delete
stream.next();
[328] Fix | Delete
} else if (stream.match(delimiter)) {
[329] Fix | Delete
state.tokenize = tokenBase;
[330] Fix | Delete
state.leavingExpr = true;
[331] Fix | Delete
return OUTCLASS;
[332] Fix | Delete
} else {
[333] Fix | Delete
stream.eat(/["]/);
[334] Fix | Delete
}
[335] Fix | Delete
}
[336] Fix | Delete
return OUTCLASS;
[337] Fix | Delete
}
[338] Fix | Delete
tokenString.isString = true;
[339] Fix | Delete
return tokenString;
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
var external = {
[343] Fix | Delete
startState: function() {
[344] Fix | Delete
return {
[345] Fix | Delete
tokenize: tokenBase,
[346] Fix | Delete
scopes: [],
[347] Fix | Delete
weakScopes: 0,
[348] Fix | Delete
lastToken: null,
[349] Fix | Delete
leavingExpr: false,
[350] Fix | Delete
isDefinition: false,
[351] Fix | Delete
charsAdvanced: 0,
[352] Fix | Delete
firstParenPos: -1
[353] Fix | Delete
};
[354] Fix | Delete
},
[355] Fix | Delete
[356] Fix | Delete
token: function(stream, state) {
[357] Fix | Delete
var style = state.tokenize(stream, state);
[358] Fix | Delete
var current = stream.current();
[359] Fix | Delete
[360] Fix | Delete
if (current && style) {
[361] Fix | Delete
state.lastToken = current;
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
// Handle '.' connected identifiers
[365] Fix | Delete
if (current === '.') {
[366] Fix | Delete
style = stream.match(identifiers, false) || stream.match(macro, false) ||
[367] Fix | Delete
stream.match(/\(/, false) ? 'operator' : ERRORCLASS;
[368] Fix | Delete
}
[369] Fix | Delete
return style;
[370] Fix | Delete
},
[371] Fix | Delete
[372] Fix | Delete
indent: function(state, textAfter) {
[373] Fix | Delete
var delta = 0;
[374] Fix | Delete
if (textAfter == "]" || textAfter == ")" || textAfter == "end" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") {
[375] Fix | Delete
delta = -1;
[376] Fix | Delete
}
[377] Fix | Delete
return (state.scopes.length + delta) * _conf.indentUnit;
[378] Fix | Delete
},
[379] Fix | Delete
[380] Fix | Delete
electricInput: /(end|else(if)?|catch|finally)$/,
[381] Fix | Delete
lineComment: "#",
[382] Fix | Delete
fold: "indent"
[383] Fix | Delete
};
[384] Fix | Delete
return external;
[385] Fix | Delete
});
[386] Fix | Delete
[387] Fix | Delete
[388] Fix | Delete
CodeMirror.defineMIME("text/x-julia", "julia");
[389] Fix | Delete
[390] Fix | Delete
});
[391] Fix | Delete
[392] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function