'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){h.defineMode("ruby",function(n){function p(a){for(var c={},b=0,d=a.length;b<d;++b)c[a[b]]=!0;return c}function k(a,c,b){b.tokenize.push(a);return a(c,b)}function m(a,c){if(a.sol()&&a.match("=begin")&&a.eol())return c.tokenize.push(u),"comment";if(a.eatSpace())return null;var b=a.next();if("`"==
b||"'"==b||'"'==b)return k(l(b,"string",'"'==b||"`"==b),a,c);if("/"==b){var d=a.pos;for(var f=0,e,h=!1,q=!1;null!=(e=a.next());)if(q)q=!1;else{if(-1<"[{(".indexOf(e))f++;else if(-1<"]})".indexOf(e)){if(f--,0>f)break}else if("/"==e&&0==f){h=!0;break}q="\\"==e}a.backUp(a.pos-d);return h?k(l(b,"string-2",!0),a,c):"operator"}if("%"==b){b="string";d=!0;a.eat("s")?b="atom":a.eat(/[WQ]/)?b="string":a.eat(/[r]/)?b="string-2":a.eat(/[wxq]/)&&(b="string",d=!1);f=a.eat(/[^\w\s=]/);if(!f)return"operator";t.propertyIsEnumerable(f)&&
(f=t[f]);return k(l(f,b,d,!0),a,c)}if("#"==b)return a.skipToEnd(),"comment";if("<"==b&&(d=a.match(/^<([-~])[`"']?([a-zA-Z_?]\w*)[`"']?(?:;|$)/)))return k(v(d[2],d[1]),a,c);if("0"==b)return a.eat("x")?a.eatWhile(/[\da-fA-F]/):a.eat("b")?a.eatWhile(/[01]/):a.eatWhile(/[0-7]/),"number";if(/\d/.test(b))return a.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),"number";if("?"==b){for(;a.match(/^\\[CM]-/););a.eat("\\")?a.eatWhile(/\w/):a.next();return"string"}if(":"==b)return a.eat("'")?k(l("'","atom",
!1),a,c):a.eat('"')?k(l('"',"atom",!0),a,c):a.eat(/[<>]/)?(a.eat(/[<>]/),"atom"):a.eat(/[\+\-\*\/&\|:!]/)?"atom":a.eat(/[a-zA-Z$@_\xa1-\uffff]/)?(a.eatWhile(/[\w$\xa1-\uffff]/),a.eat(/[\?!=]/),"atom"):"operator";if("@"==b&&a.match(/^@?[a-zA-Z_\xa1-\uffff]/))return a.eat("@"),a.eatWhile(/[\w\xa1-\uffff]/),"variable-2";if("$"==b)return a.eat(/[a-zA-Z_]/)?a.eatWhile(/[\w]/):a.eat(/\d/)?a.eat(/\d/):a.next(),"variable-3";if(/[a-zA-Z_\xa1-\uffff]/.test(b))return a.eatWhile(/[\w\xa1-\uffff]/),a.eat(/[\?!]/),
a.eat(":")?"atom":"ident";if("|"!=b||!c.varList&&"{"!=c.lastTok&&"do"!=c.lastTok)return/[\(\)\[\]{}\\;]/.test(b)?(g=b,null):"-"==b&&a.eat(">")?"arrow":/[=+\-\/*:\.^%<>~|]/.test(b)?(a=a.eatWhile(/[=+\-\/*:\.^%<>~|]/),"."!=b||a||(g="."),"operator"):null;g="|";return null}function r(a){a||(a=1);return function(c,b){if("}"==c.peek()){if(1==a)return b.tokenize.pop(),b.tokenize[b.tokenize.length-1](c,b);b.tokenize[b.tokenize.length-1]=r(a-1)}else"{"==c.peek()&&(b.tokenize[b.tokenize.length-1]=r(a+1));return m(c,
b)}}function w(){var a=!1;return function(c,b){if(a)return b.tokenize.pop(),b.tokenize[b.tokenize.length-1](c,b);a=!0;return m(c,b)}}function l(a,c,b,d){return function(f,e){var g=!1,h;"read-quoted-paused"===e.context.type&&(e.context=e.context.prev,f.eat("}"));for(;null!=(h=f.next());){if(h==a&&(d||!g)){e.tokenize.pop();break}if(b&&"#"==h&&!g)if(f.eat("{")){"}"==a&&(e.context={prev:e.context,type:"read-quoted-paused"});e.tokenize.push(r());break}else if(/[@\$]/.test(f.peek())){e.tokenize.push(w());
break}g=!g&&"\\"==h}return c}}function v(a,c){return function(b,d){c&&b.eatSpace();b.match(a)?d.tokenize.pop():b.skipToEnd();return"string"}}function u(a,c){a.sol()&&a.match("=end")&&a.eol()&&c.tokenize.pop();a.skipToEnd();return"comment"}var x=p("alias and BEGIN begin break case class def defined? do else elsif END end ensure false for if in module next not or redo rescue retry return self super then true undef unless until when while yield nil raise throw catch fail loop callcc caller lambda proc public protected private require load require_relative extend autoload __END__ __FILE__ __LINE__ __dir__".split(" ")),
y=p("def class case for while until module then catch loop proc begin".split(" ")),z=p(["end","until"]),t={"[":"]","{":"}","(":")"},A={"]":"[","}":"{",")":"("},g;return{startState:function(){return{tokenize:[m],indented:0,context:{type:"top",indented:-n.indentUnit},continuedLine:!1,lastTok:null,varList:!1}},token:function(a,c){g=null;a.sol()&&(c.indented=a.indentation());var b=c.tokenize[c.tokenize.length-1](a,c),d,f=g;if("ident"==b){var e=a.current();b="."==c.lastTok?"property":x.propertyIsEnumerable(a.current())?
"keyword":/^[A-Z]/.test(e)?"tag":"def"==c.lastTok||"class"==c.lastTok||c.varList?"def":"variable";"keyword"==b&&(f=e,y.propertyIsEnumerable(e)?d="indent":z.propertyIsEnumerable(e)?d="dedent":"if"!=e&&"unless"!=e||a.column()!=a.indentation()?"do"==e&&c.context.indented<c.indented&&(d="indent"):d="indent")}if(g||b&&"comment"!=b)c.lastTok=f;"|"==g&&(c.varList=!c.varList);"indent"==d||/[\(\[\{]/.test(g)?c.context={prev:c.context,type:g||b,indented:c.indented}:("dedent"==d||/[\)\]\}]/.test(g))&&c.context.prev&&
(c.context=c.context.prev);a.eol()&&(c.continuedLine="\\"==g||"operator"==b);return b},indent:function(a,c){if(a.tokenize[a.tokenize.length-1]!=m)return h.Pass;var b=c&&c.charAt(0),d=a.context;c=d.type==A[b]||"keyword"==d.type&&/^(?:end|until|else|elsif|when|rescue)\b/.test(c);return d.indented+(c?0:n.indentUnit)+(a.continuedLine?n.indentUnit:0)},electricInput:/^\s*(?:end|rescue|elsif|else|\})$/,lineComment:"#",fold:"indent"}});h.defineMIME("text/x-ruby","ruby")});
