##// END OF EJS Templates
exceptions: store exception about failed exc email sending
exceptions: store exception about failed exc email sending

File last commit:

r4105:10488616 default
r4811:201c0563 default
Show More
julia.js
429 lines | 12.4 KiB | application/javascript | JavascriptLexer
project: added all source files and assets
r1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
codemirror: bumped to version 5.49.2
r4105 // Distributed under an MIT license: https://codemirror.net/LICENSE
project: added all source files and assets
r1
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
codemirror: bumped to version 5.49.2
r4105 CodeMirror.defineMode("julia", function(config, parserConf) {
function wordRegexp(words, end) {
if (typeof end === "undefined") { end = "\\b"; }
return new RegExp("^((" + words.join(")|(") + "))" + end);
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 var octChar = "\\\\[0-7]{1,3}";
var hexChar = "\\\\x[A-Fa-f0-9]{1,2}";
var sChar = "\\\\[abefnrtv0%?'\"\\\\]";
var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
var operators = parserConf.operators || wordRegexp([
"[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/",
"[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":",
"\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218",
"\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264",
"\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5",
"\\b(in|isa)\\b(?!\.?\\()"], "");
project: added all source files and assets
r1 var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
codemirror: bumped to version 5.49.2
r4105 var identifiers = parserConf.identifiers ||
/^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/;
var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'");
var openersList = ["begin", "function", "type", "struct", "immutable", "let",
"macro", "for", "while", "quote", "if", "else", "elseif", "try",
"finally", "catch", "do"];
project: added all source files and assets
r1
codemirror: bumped to version 5.49.2
r4105 var closersList = ["end", "else", "elseif", "catch", "finally"];
var keywordsList = ["if", "else", "elseif", "while", "for", "begin", "let",
"end", "do", "try", "catch", "finally", "return", "break", "continue",
"global", "local", "const", "export", "import", "importall", "using",
"function", "where", "macro", "module", "baremodule", "struct", "type",
"mutable", "immutable", "quote", "typealias", "abstract", "primitive",
"bitstype"];
var builtinsList = ["true", "false", "nothing", "NaN", "Inf"];
CodeMirror.registerHelper("hintWords", "julia", keywordsList.concat(builtinsList));
var openers = wordRegexp(openersList);
var closers = wordRegexp(closersList);
var keywords = wordRegexp(keywordsList);
var builtins = wordRegexp(builtinsList);
var macro = /^@[_A-Za-z][\w]*/;
var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
var stringPrefixes = /^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/;
project: added all source files and assets
r1
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 function inArray(state) {
codemirror: bumped to version 5.49.2
r4105 return (state.nestedArrays > 0);
}
function inGenerator(state) {
return (state.nestedGenerators > 0);
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 function currentScope(state, n) {
if (typeof(n) === "undefined") { n = 0; }
if (state.scopes.length <= n) {
project: added all source files and assets
r1 return null;
}
codemirror: bumped to version 5.49.2
r4105 return state.scopes[state.scopes.length - (n + 1)];
project: added all source files and assets
r1 }
// tokenizers
function tokenBase(stream, state) {
codemirror: bumped to version 5.49.2
r4105 // Handle multiline comments
if (stream.match(/^#=/, false)) {
state.tokenize = tokenComment;
return state.tokenize(stream, state);
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
project: added all source files and assets
r1 // Handle scope changes
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 var leavingExpr = state.leavingExpr;
if (stream.sol()) {
leavingExpr = false;
project: added all source files and assets
r1 }
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 state.leavingExpr = false;
codemirror: bumped to version 5.49.2
r4105
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 if (leavingExpr) {
if (stream.match(/^'+/)) {
codemirror: bumped to version 5.49.2
r4105 return "operator";
project: added all source files and assets
r1 }
}
codemirror: bumped to version 5.49.2
r4105 if (stream.match(/\.{4,}/)) {
return "error";
} else if (stream.match(/\.{1,3}/)) {
return "operator";
project: added all source files and assets
r1 }
if (stream.eatSpace()) {
return null;
}
var ch = stream.peek();
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346
// Handle single line comments
project: added all source files and assets
r1 if (ch === '#') {
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 stream.skipToEnd();
codemirror: bumped to version 5.49.2
r4105 return "comment";
project: added all source files and assets
r1 }
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 if (ch === '[') {
state.scopes.push('[');
codemirror: bumped to version 5.49.2
r4105 state.nestedArrays++;
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 if (ch === '(') {
state.scopes.push('(');
state.nestedGenerators++;
}
project: added all source files and assets
r1
codemirror: bumped to version 5.49.2
r4105 if (inArray(state) && ch === ']') {
if (currentScope(state) === "if") { state.scopes.pop(); }
while (currentScope(state) === "for") { state.scopes.pop(); }
project: added all source files and assets
r1 state.scopes.pop();
codemirror: bumped to version 5.49.2
r4105 state.nestedArrays--;
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 state.leavingExpr = true;
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 if (inGenerator(state) && ch === ')') {
if (currentScope(state) === "if") { state.scopes.pop(); }
while (currentScope(state) === "for") { state.scopes.pop(); }
project: added all source files and assets
r1 state.scopes.pop();
codemirror: bumped to version 5.49.2
r4105 state.nestedGenerators--;
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 state.leavingExpr = true;
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 if (inArray(state)) {
if (state.lastToken == "end" && stream.match(/^:/)) {
return "operator";
}
if (stream.match(/^end/)) {
return "number";
}
}
project: added all source files and assets
r1 var match;
codemirror: bumped to version 5.49.2
r4105 if (match = stream.match(openers, false)) {
state.scopes.push(match[0]);
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 if (stream.match(closers, false)) {
project: added all source files and assets
r1 state.scopes.pop();
}
codemirror: bumped to version 5.49.2
r4105 // Handle type annotations
if (stream.match(/^::(?![:\$])/)) {
state.tokenize = tokenAnnotation;
return state.tokenize(stream, state);
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 // Handle symbols
if (!leavingExpr && stream.match(symbol) ||
stream.match(/:([<>]:|<<=?|>>>?=?|->|\/\/|\.{2,3}|[\.\\%*+\-<>!\/^|&]=?|[~\?\$])/)) {
return "builtin";
}
// Handle parametric types
//if (stream.match(/^{[^}]*}(?=\()/)) {
// return "builtin";
//}
// Handle operators and Delimiters
if (stream.match(operators)) {
return "operator";
project: added all source files and assets
r1 }
// Handle Number Literals
codemirror: bumped to version 5.49.2
r4105 if (stream.match(/^\.?\d/, false)) {
project: added all source files and assets
r1 var imMatcher = RegExp(/^im\b/);
codemirror: bumped to version 5.49.2
r4105 var numberLiteral = false;
project: added all source files and assets
r1 // Floats
codemirror: bumped to version 5.49.2
r4105 if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; }
if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; }
project: added all source files and assets
r1 // Integers
codemirror: bumped to version 5.49.2
r4105 if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex
if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary
if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal
if (stream.match(/^[1-9][_\d]*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
project: added all source files and assets
r1 // Zero by itself with no other piece of number.
codemirror: bumped to version 5.49.2
r4105 if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
if (numberLiteral) {
project: added all source files and assets
r1 // Integer literals may be "long"
stream.match(imMatcher);
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 state.leavingExpr = true;
codemirror: bumped to version 5.49.2
r4105 return "number";
project: added all source files and assets
r1 }
}
codemirror: bumped to version 5.49.2
r4105 // Handle Chars
if (stream.match(/^'/)) {
state.tokenize = tokenChar;
return state.tokenize(stream, state);
project: added all source files and assets
r1 }
// Handle Strings
if (stream.match(stringPrefixes)) {
state.tokenize = tokenStringFactory(stream.current());
return state.tokenize(stream, state);
}
if (stream.match(macro)) {
codemirror: bumped to version 5.49.2
r4105 return "meta";
project: added all source files and assets
r1 }
if (stream.match(delimiters)) {
return null;
}
if (stream.match(keywords)) {
codemirror: bumped to version 5.49.2
r4105 return "keyword";
project: added all source files and assets
r1 }
if (stream.match(builtins)) {
codemirror: bumped to version 5.49.2
r4105 return "builtin";
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 var isDefinition = state.isDefinition || state.lastToken == "function" ||
state.lastToken == "macro" || state.lastToken == "type" ||
state.lastToken == "struct" || state.lastToken == "immutable";
project: added all source files and assets
r1
if (stream.match(identifiers)) {
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 if (isDefinition) {
if (stream.peek() === '.') {
state.isDefinition = true;
codemirror: bumped to version 5.49.2
r4105 return "variable";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
state.isDefinition = false;
codemirror: bumped to version 5.49.2
r4105 return "def";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
if (stream.match(/^({[^}]*})*\(/, false)) {
codemirror: bumped to version 5.49.2
r4105 state.tokenize = tokenCallOrDef;
return state.tokenize(stream, state);
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
state.leavingExpr = true;
codemirror: bumped to version 5.49.2
r4105 return "variable";
project: added all source files and assets
r1 }
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346
project: added all source files and assets
r1 // Handle non-detected items
stream.next();
codemirror: bumped to version 5.49.2
r4105 return "error";
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 function tokenCallOrDef(stream, state) {
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 var match = stream.match(/^(\(\s*)/);
if (match) {
if (state.firstParenPos < 0)
state.firstParenPos = state.scopes.length;
state.scopes.push('(');
state.charsAdvanced += match[1].length;
}
if (currentScope(state) == '(' && stream.match(/^\)/)) {
state.scopes.pop();
state.charsAdvanced += 1;
if (state.scopes.length <= state.firstParenPos) {
codemirror: bumped to version 5.49.2
r4105 var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false);
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 stream.backUp(state.charsAdvanced);
state.firstParenPos = -1;
state.charsAdvanced = 0;
codemirror: bumped to version 5.49.2
r4105 state.tokenize = tokenBase;
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 if (isDefinition)
codemirror: bumped to version 5.49.2
r4105 return "def";
return "builtin";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
}
// Unfortunately javascript does not support multiline strings, so we have
// to undo anything done upto here if a function call or definition splits
// over two or more lines.
if (stream.match(/^$/g, false)) {
stream.backUp(state.charsAdvanced);
codemirror: bumped to version 5.49.2
r4105 while (state.scopes.length > state.firstParenPos)
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 state.scopes.pop();
state.firstParenPos = -1;
state.charsAdvanced = 0;
codemirror: bumped to version 5.49.2
r4105 state.tokenize = tokenBase;
return "builtin";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
codemirror: bumped to version 5.49.2
r4105 return state.tokenize(stream, state);
}
function tokenAnnotation(stream, state) {
stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/);
if (stream.match(/^{/)) {
state.nestedParameters++;
} else if (stream.match(/^}/) && state.nestedParameters > 0) {
state.nestedParameters--;
}
if (state.nestedParameters > 0) {
stream.match(/.*?(?={|})/) || stream.next();
} else if (state.nestedParameters == 0) {
state.tokenize = tokenBase;
}
return "builtin";
}
function tokenComment(stream, state) {
if (stream.match(/^#=/)) {
state.nestedComments++;
}
if (!stream.match(/.*?(?=(#=|=#))/)) {
stream.skipToEnd();
}
if (stream.match(/^=#/)) {
state.nestedComments--;
if (state.nestedComments == 0)
state.tokenize = tokenBase;
}
return "comment";
}
function tokenChar(stream, state) {
var isChar = false, match;
if (stream.match(chars)) {
isChar = true;
} else if (match = stream.match(/\\u([a-f0-9]{1,4})(?=')/i)) {
var value = parseInt(match[1], 16);
if (value <= 55295 || value >= 57344) { // (U+0,U+D7FF), (U+E000,U+FFFF)
isChar = true;
stream.next();
}
} else if (match = stream.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)) {
var value = parseInt(match[1], 16);
if (value <= 1114111) { // U+10FFFF
isChar = true;
stream.next();
}
}
if (isChar) {
state.leavingExpr = true;
state.tokenize = tokenBase;
return "string";
}
if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); }
if (stream.match(/^'/)) { state.tokenize = tokenBase; }
return "error";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 }
project: added all source files and assets
r1 function tokenStringFactory(delimiter) {
codemirror: bumped to version 5.49.2
r4105 if (delimiter.substr(-3) === '"""') {
delimiter = '"""';
} else if (delimiter.substr(-1) === '"') {
delimiter = '"';
project: added all source files and assets
r1 }
function tokenString(stream, state) {
codemirror: bumped to version 5.49.2
r4105 if (stream.eat('\\')) {
stream.next();
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
state.leavingExpr = true;
return "string";
} else {
stream.eat(/[`"]/);
project: added all source files and assets
r1 }
codemirror: bumped to version 5.49.2
r4105 stream.eatWhile(/[^\\`"]/);
return "string";
project: added all source files and assets
r1 }
return tokenString;
}
var external = {
startState: function() {
return {
tokenize: tokenBase,
scopes: [],
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 lastToken: null,
leavingExpr: false,
isDefinition: false,
codemirror: bumped to version 5.49.2
r4105 nestedArrays: 0,
nestedComments: 0,
nestedGenerators: 0,
nestedParameters: 0,
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 charsAdvanced: 0,
firstParenPos: -1
project: added all source files and assets
r1 };
},
token: function(stream, state) {
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 var style = state.tokenize(stream, state);
var current = stream.current();
if (current && style) {
state.lastToken = current;
}
project: added all source files and assets
r1 return style;
},
indent: function(state, textAfter) {
var delta = 0;
codemirror: bumped to version 5.49.2
r4105 if ( textAfter === ']' || textAfter === ')' || textAfter === "end" ||
textAfter === "else" || textAfter === "catch" || textAfter === "elseif" ||
textAfter === "finally" ) {
project: added all source files and assets
r1 delta = -1;
}
codemirror: bumped to version 5.49.2
r4105 return (state.scopes.length + delta) * config.indentUnit;
project: added all source files and assets
r1 },
codemirror: bumped to version 5.49.2
r4105 electricInput: /\b(end|else|catch|finally)\b/,
blockCommentStart: "#=",
blockCommentEnd: "=#",
project: added all source files and assets
r1 lineComment: "#",
codemirror: bumped to version 5.49.2
r4105 closeBrackets: "()[]{}\"\"",
fold: "indent"
project: added all source files and assets
r1 };
return external;
});
CodeMirror.defineMIME("text/x-julia", "julia");
});