Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/mode/python/python.min.js |
(function(f){typeof exports=="object"&&typeof module=="object"?f(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){"use strict";function k(p){return new RegExp("^(("+p.join(")|(")+"))\\b")}var O=k(["and","or","not","is"]),z=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in","False","True"],S=["abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"];f.registerHelper("hintWords","python",z.concat(S).concat(["exec","print"]));function c(p){return p.scopes[p.scopes.length-1]}f.defineMode("python",function(p,l){for(var a="error",L=l.delimiters||l.singleDelimiters||/^[\(\)\[\]\{\}@,:`=;\.\\]/,g=[l.singleOperators,l.doubleOperators,l.doubleDelimiters,l.tripleDelimiters,l.operators||/^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/],b=0;b<g.length;b++)g[b]||g.splice(b--,1);var x=l.hangingIndent||p.indentUnit,h=z,y=S;l.extra_keywords!=null&&(h=h.concat(l.extra_keywords)),l.extra_builtins!=null&&(y=y.concat(l.extra_builtins));var _=!(l.version&&Number(l.version)<3);if(_){var s=l.identifiers||/^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;h=h.concat(["nonlocal","None","aiter","anext","async","await","breakpoint","match","case"]),y=y.concat(["ascii","bytes","exec","print"]);var E=new RegExp(`^(([rbuf]|(br)|(rb)|(fr)|(rf))?('{3}|"{3}|['"]))`,"i")}else{var s=l.identifiers||/^[_A-Za-z][_A-Za-z0-9]*/;h=h.concat(["exec","print"]),y=y.concat(["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","None"]);var E=new RegExp(`^(([rubf]|(ur)|(br))?('{3}|"{3}|['"]))`,"i")}var R=k(h),B=k(y);function F(e,n){var r=e.sol()&&n.lastToken!="\\";if(r&&(n.indent=e.indentation()),r&&c(n).type=="py"){var i=c(n).offset;if(e.eatSpace()){var t=e.indentation();return t>i?T(n):t<i&&A(e,n)&&e.peek()!="#"&&(n.errorToken=!0),null}else{var u=w(e,n);return i>0&&A(e,n)&&(u+=" "+a),u}}return w(e,n)}function w(e,n,r){if(e.eatSpace())return null;if(!r&&e.match(/^#.*/))return"comment";if(e.match(/^[0-9\.]/,!1)){var i=!1;if(e.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)&&(i=!0),e.match(/^[\d_]+\.\d*/)&&(i=!0),e.match(/^\.\d+/)&&(i=!0),i)return e.eat(/J/i),"number";var t=!1;if(e.match(/^0x[0-9a-f_]+/i)&&(t=!0),e.match(/^0b[01_]+/i)&&(t=!0),e.match(/^0o[0-7_]+/i)&&(t=!0),e.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)&&(e.eat(/J/i),t=!0),e.match(/^0(?![\dx])/i)&&(t=!0),t)return e.eat(/L/i),"number"}if(e.match(E)){var u=e.current().toLowerCase().indexOf("f")!==-1;return u?(n.tokenize=N(e.current(),n.tokenize),n.tokenize(e,n)):(n.tokenize=j(e.current(),n.tokenize),n.tokenize(e,n))}for(var o=0;o<g.length;o++)if(e.match(g[o]))return"operator";return e.match(L)?"punctuation":n.lastToken=="."&&e.match(s)?"property":e.match(R)||e.match(O)?"keyword":e.match(B)?"builtin":e.match(/^(self|cls)\b/)?"variable-2":e.match(s)?n.lastToken=="def"||n.lastToken=="class"?"def":"variable":(e.next(),r?null:a)}function N(e,n){for(;"rubf".indexOf(e.charAt(0).toLowerCase())>=0;)e=e.substr(1);var r=e.length==1,i="string";function t(o){return function(d,v){var I=w(d,v,!0);return I=="punctuation"&&(d.current()=="{"?v.tokenize=t(o+1):d.current()=="}"&&(o>1?v.tokenize=t(o-1):v.tokenize=u)),I}}function u(o,d){for(;!o.eol();)if(o.eatWhile(/[^'"\{\}\\]/),o.eat("\\")){if(o.next(),r&&o.eol())return i}else{if(o.match(e))return d.tokenize=n,i;if(o.match("{{"))return i;if(o.match("{",!1))return d.tokenize=t(0),o.current()?i:d.tokenize(o,d);if(o.match("}}"))return i;if(o.match("}"))return a;o.eat(/['"]/)}if(r){if(l.singleLineStringErrors)return a;d.tokenize=n}return i}return u.isString=!0,u}function j(e,n){for(;"rubf".indexOf(e.charAt(0).toLowerCase())>=0;)e=e.substr(1);var r=e.length==1,i="string";function t(u,o){for(;!u.eol();)if(u.eatWhile(/[^'"\\]/),u.eat("\\")){if(u.next(),r&&u.eol())return i}else{if(u.match(e))return o.tokenize=n,i;u.eat(/['"]/)}if(r){if(l.singleLineStringErrors)return a;o.tokenize=n}return i}return t.isString=!0,t}function T(e){for(;c(e).type!="py";)e.scopes.pop();e.scopes.push({offset:c(e).offset+p.indentUnit,type:"py",align:null})}function D(e,n,r){var i=e.match(/^[\s\[\{\(]*(?:#|$)/,!1)?null:e.column()+1;n.scopes.push({offset:n.indent+x,type:r,align:i})}function A(e,n){for(var r=e.indentation();n.scopes.length>1&&c(n).offset>r;){if(c(n).type!="py")return!0;n.scopes.pop()}return c(n).offset!=r}function U(e,n){e.sol()&&(n.beginningOfLine=!0,n.dedent=!1);var r=n.tokenize(e,n),i=e.current();if(n.beginningOfLine&&i=="@")return e.match(s,!1)?"meta":_?"operator":a;if(/\S/.test(i)&&(n.beginningOfLine=!1),(r=="variable"||r=="builtin")&&n.lastToken=="meta"&&(r="meta"),(i=="pass"||i=="return")&&(n.dedent=!0),i=="lambda"&&(n.lambda=!0),i==":"&&!n.lambda&&c(n).type=="py"&&e.match(/^\s*(?:#|$)/,!1)&&T(n),i.length==1&&!/string|comment/.test(r)){var t="[({".indexOf(i);if(t!=-1&&D(e,n,"])}".slice(t,t+1)),t="])}".indexOf(i),t!=-1)if(c(n).type==i)n.indent=n.scopes.pop().offset-x;else return a}return n.dedent&&e.eol()&&c(n).type=="py"&&n.scopes.length>1&&n.scopes.pop(),r}var Z={startState:function(e){return{tokenize:F,scopes:[{offset:e||0,type:"py",align:null}],indent:e||0,lastToken:null,lambda:!1,dedent:0}},token:function(e,n){var r=n.errorToken;r&&(n.errorToken=!1);var i=U(e,n);return i&&i!="comment"&&(n.lastToken=i=="keyword"||i=="punctuation"?e.current():i),i=="punctuation"&&(i=null),e.eol()&&n.lambda&&(n.lambda=!1),r?i+" "+a:i},indent:function(e,n){if(e.tokenize!=F)return e.tokenize.isString?f.Pass:0;var r=c(e),i=r.type==n.charAt(0)||r.type=="py"&&!e.dedent&&/^(else:|elif |except |finally:)/.test(n);return r.align!=null?r.align-(i?1:0):r.offset-(i?x:0)},electricInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/,closeBrackets:{triples:`'"`},lineComment:"#",fold:"indent"};return Z}),f.defineMIME("text/x-python","python");var m=function(p){return p.split(" ")};f.defineMIME("text/x-cython",{name:"python",extra_keywords:m("by cdef cimport cpdef ctypedef enum except extern gil include nogil property public readonly struct union DEF IF ELIF ELSE")})});