Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/mode/julia/julia.min.js |
(function(u){typeof exports=="object"&&typeof module=="object"?u(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],u):u(CodeMirror)})(function(u){"use strict";u.defineMode("julia",function(v,l){function o(n,e,i){return typeof i>"u"&&(i=""),typeof e>"u"&&(e="\\b"),new RegExp("^"+i+"(("+n.join(")|(")+"))"+e)}var k="\\\\[0-7]{1,3}",F="\\\\x[A-Fa-f0-9]{1,2}",b=`\\\\[abefnrtv0%?'"\\\\]`,g="([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])",a=["[<>]:","[<>=]=","<<=?",">>>?=?","=>","--?>","<--[->]?","\\/\\/","\\.{2,3}","[\\.\\\\%*+\\-<>!\\/^|&]=?","\\?","\\$","~",":"],y=l.operators||o(["[<>]:","[<>=]=","[!=]==","<<=?",">>>?=?","=>?","--?>","<--[->]?","\\/\\/","[\\\\%*+\\-<>!\\/^|&\\u00F7\\u22BB]=?","\\?","\\$","~",":","\\u00D7","\\u2208","\\u2209","\\u220B","\\u220C","\\u2218","\\u221A","\\u221B","\\u2229","\\u222A","\\u2260","\\u2264","\\u2265","\\u2286","\\u2288","\\u228A","\\u22C5","\\b(in|isa)\\b(?!.?\\()"],""),m=l.delimiters||/^[;,()[\]{}]/,x=l.identifiers||/^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/,z=o([k,F,b,g],"'"),E=["begin","function","type","struct","immutable","let","macro","for","while","quote","if","else","elseif","try","finally","catch","do"],A=["end","else","elseif","catch","finally"],p=["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"],h=["true","false","nothing","NaN","Inf"];u.registerHelper("hintWords","julia",p.concat(h));var C=o(E),_=o(A),w=o(p),D=o(h),T=/^@[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/,P=/^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/,j=/^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/,B=o(a,"","@"),S=o(a,"",":");function d(n){return n.nestedArrays>0}function G(n){return n.nestedGenerators>0}function s(n,e){return typeof e>"u"&&(e=0),n.scopes.length<=e?null:n.scopes[n.scopes.length-(e+1)]}function t(n,e){if(n.match("#=",!1))return e.tokenize=Z,e.tokenize(n,e);var i=e.leavingExpr;if(n.sol()&&(i=!1),e.leavingExpr=!1,i&&n.match(/^'+/))return"operator";if(n.match(/\.{4,}/))return"error";if(n.match(/\.{1,3}/))return"operator";if(n.eatSpace())return null;var r=n.peek();if(r==="#")return n.skipToEnd(),"comment";if(r==="["&&(e.scopes.push("["),e.nestedArrays++),r==="("&&(e.scopes.push("("),e.nestedGenerators++),d(e)&&r==="]"){for(;e.scopes.length&&s(e)!=="[";)e.scopes.pop();e.scopes.pop(),e.nestedArrays--,e.leavingExpr=!0}if(G(e)&&r===")"){for(;e.scopes.length&&s(e)!=="(";)e.scopes.pop();e.scopes.pop(),e.nestedGenerators--,e.leavingExpr=!0}if(d(e)){if(e.lastToken=="end"&&n.match(":"))return"operator";if(n.match("end"))return"number"}var f;if((f=n.match(C,!1))&&e.scopes.push(f[0]),n.match(_,!1)&&e.scopes.pop(),n.match(/^::(?![:\$])/))return e.tokenize=I,e.tokenize(n,e);if(!i&&(n.match(P)||n.match(S)))return"builtin";if(n.match(y))return"operator";if(n.match(/^\.?\d/,!1)){var R=RegExp(/^im\b/),c=!1;if(n.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)&&(c=!0),n.match(/^0x[0-9a-f_]+/i)&&(c=!0),n.match(/^0b[01_]+/i)&&(c=!0),n.match(/^0o[0-7_]+/i)&&(c=!0),n.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)&&(c=!0),n.match(/^\d[_\d]*(e[\+\-]?\d+)?/i)&&(c=!0),c)return n.match(R),e.leavingExpr=!0,"number"}if(n.match("'"))return e.tokenize=$,e.tokenize(n,e);if(n.match(j))return e.tokenize=q(n.current()),e.tokenize(n,e);if(n.match(T)||n.match(B))return"meta";if(n.match(m))return null;if(n.match(w))return"keyword";if(n.match(D))return"builtin";var M=e.isDefinition||e.lastToken=="function"||e.lastToken=="macro"||e.lastToken=="type"||e.lastToken=="struct"||e.lastToken=="immutable";return n.match(x)?M?n.peek()==="."?(e.isDefinition=!0,"variable"):(e.isDefinition=!1,"def"):(e.leavingExpr=!0,"variable"):(n.next(),"error")}function I(n,e){return n.match(/.*?(?=[,;{}()=\s]|$)/),n.match("{")?e.nestedParameters++:n.match("}")&&e.nestedParameters>0&&e.nestedParameters--,e.nestedParameters>0?n.match(/.*?(?={|})/)||n.next():e.nestedParameters==0&&(e.tokenize=t),"builtin"}function Z(n,e){return n.match("#=")&&e.nestedComments++,n.match(/.*?(?=(#=|=#))/)||n.skipToEnd(),n.match("=#")&&(e.nestedComments--,e.nestedComments==0&&(e.tokenize=t)),"comment"}function $(n,e){var i=!1,r;if(n.match(z))i=!0;else if(r=n.match(/\\u([a-f0-9]{1,4})(?=')/i)){var f=parseInt(r[1],16);(f<=55295||f>=57344)&&(i=!0,n.next())}else if(r=n.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)){var f=parseInt(r[1],16);f<=1114111&&(i=!0,n.next())}return i?(e.leavingExpr=!0,e.tokenize=t,"string"):(n.match(/^[^']+(?=')/)||n.skipToEnd(),n.match("'")&&(e.tokenize=t),"error")}function q(n){n.substr(-3)==='"""'?n='"""':n.substr(-1)==='"'&&(n='"');function e(i,r){if(i.eat("\\"))i.next();else{if(i.match(n))return r.tokenize=t,r.leavingExpr=!0,"string";i.eat(/[`"]/)}return i.eatWhile(/[^\\`"]/),"string"}return e}var O={startState:function(){return{tokenize:t,scopes:[],lastToken:null,leavingExpr:!1,isDefinition:!1,nestedArrays:0,nestedComments:0,nestedGenerators:0,nestedParameters:0,firstParenPos:-1}},token:function(n,e){var i=e.tokenize(n,e),r=n.current();return r&&i&&(e.lastToken=r),i},indent:function(n,e){var i=0;return(e==="]"||e===")"||/^end\b/.test(e)||/^else/.test(e)||/^catch\b/.test(e)||/^elseif\b/.test(e)||/^finally/.test(e))&&(i=-1),(n.scopes.length+i)*v.indentUnit},electricInput:/\b(end|else|catch|finally)\b/,blockCommentStart:"#=",blockCommentEnd:"=#",lineComment:"#",closeBrackets:'()[]{}""',fold:"indent"};return O}),u.defineMIME("text/x-julia","julia")});