CodeMirror.defineMode("python",function(e,t){function n(e){return RegExp("^(("+e.join(")|(")+"))\\b")}function i(e,t){if(e.sol()){var n=t.scopes[0].offset;if(e.eatSpace()){var i=e.indentation();return i>n?C="indent":n>i&&(C="dedent"),null}n>0&&o(e,t)}if(e.eatSpace())return null;var a=e.peek();if("#"===a)return e.skipToEnd(),"comment";if(e.match(/^[0-9\.]/,!1)){var s=!1;if(e.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)&&(s=!0),e.match(/^\d+\.\d*/)&&(s=!0),e.match(/^\.\d+/)&&(s=!0),s)return e.eat(/J/i),"number";var f=!1;if(e.match(/^0x[0-9a-f]+/i)&&(f=!0),e.match(/^0b[01]+/i)&&(f=!0),e.match(/^0o[0-7]+/i)&&(f=!0),e.match(/^[1-9]\d*(e[\+\-]?\d+)?/)&&(e.eat(/J/i),f=!0),e.match(/^0(?![\dx])/i)&&(f=!0),f)return e.eat(/L/i),"number"}return e.match(_)?(t.tokenize=r(e.current()),t.tokenize(e,t)):e.match(m)||e.match(p)?null:e.match(d)||e.match(c)||e.match(g)?"operator":e.match(u)?null:e.match(k)?"keyword":e.match(E)?"builtin":e.match(h)?"variable":(e.next(),l)}function r(e){function n(n,o){for(;!n.eol();)if(n.eatWhile(/[^'"\\]/),n.eat("\\")){if(n.next(),r&&n.eol())return a}else{if(n.match(e))return o.tokenize=i,a;n.eat(/['"]/)}if(r){if(t.singleLineStringErrors)return l;o.tokenize=i}return a}for(;"rub".indexOf(e.charAt(0).toLowerCase())>=0;)e=e.substr(1);var r=1==e.length,a="string";return n.isString=!0,n}function a(t,n,i){i=i||"py";var r=0;if("py"===i){if("py"!==n.scopes[0].type)return n.scopes[0].offset=t.indentation(),void 0;for(var a=0;n.scopes.length>a;++a)if("py"===n.scopes[a].type){r=n.scopes[a].offset+e.indentUnit;break}}else r=t.column()+t.current().length;n.scopes.unshift({offset:r,type:i})}function o(e,t,n){if(n=n||"py",1!=t.scopes.length){if("py"===t.scopes[0].type){for(var i=e.indentation(),r=-1,a=0;t.scopes.length>a;++a)if(i===t.scopes[a].offset){r=a;break}if(-1===r)return!0;for(;t.scopes[0].offset!==i;)t.scopes.shift();return!1}return"py"===n?(t.scopes[0].offset=e.indentation(),!1):t.scopes[0].type!=n?!0:(t.scopes.shift(),!1)}}function s(e,t){C=null;var n=t.tokenize(e,t),i=e.current();if("."===i)return n=e.match(h,!1)?null:l,null===n&&"meta"===t.lastToken&&(n="meta"),n;if("@"===i)return e.match(h,!1)?"meta":l;"variable"!==n&&"builtin"!==n||"meta"!==t.lastToken||(n="meta"),("pass"===i||"return"===i)&&(t.dedent+=1),"lambda"===i&&(t.lambda=!0),(":"===i&&!t.lambda&&"py"==t.scopes[0].type||"indent"===C)&&a(e,t);var r="[({".indexOf(i);return-1!==r&&a(e,t,"])}".slice(r,r+1)),"dedent"===C&&o(e,t)?l:(r="])}".indexOf(i),-1!==r&&o(e,t,i)?l:(t.dedent>0&&e.eol()&&"py"==t.scopes[0].type&&(t.scopes.length>1&&t.scopes.shift(),t.dedent-=1),n))}var l="error",c=RegExp("^[\\+\\-\\*/%&|\\^~<>!]"),u=RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),d=RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"),p=RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),m=RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"),h=RegExp("^[_A-Za-z][_A-Za-z0-9]*"),g=n(["and","or","not","is","in"]),f=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield"],b=["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__"],v={builtins:["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","False","True","None"],keywords:["exec","print"]},y={builtins:["ascii","bytes","exec","print"],keywords:["nonlocal","False","True","None"]};if(t.version&&3===parseInt(t.version,10)){f=f.concat(y.keywords),b=b.concat(y.builtins);var _=RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))","i")}else{f=f.concat(v.keywords),b=b.concat(v.builtins);var _=RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))","i")}var k=n(f),E=n(b),C=null,T={startState:function(e){return{tokenize:i,scopes:[{offset:e||0,type:"py"}],lastToken:null,lambda:!1,dedent:0}},token:function(e,t){var n=s(e,t);return t.lastToken=n,e.eol()&&e.lambda&&(t.lambda=!1),n},indent:function(e){return e.tokenize!=i?e.tokenize.isString?CodeMirror.Pass:0:e.scopes[0].offset}};return T}),CodeMirror.defineMIME("text/x-python","python");