?
Path : /home/admin/public_html/old/media/editors/codemirror/mode/ruby/ |
Current File : /home/admin/public_html/old/media/editors/codemirror/mode/ruby/ruby.min.js |
!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("ruby",function(a){function b(a){for(var b={},c=0,d=a.length;d>c;++c)b[a[c]]=!0;return b}function c(a,b,c){return c.tokenize.push(a),a(b,c)}function d(a,b){if(j=null,a.sol()&&a.match("=begin")&&a.eol())return b.tokenize.push(i),"comment";if(a.eatSpace())return null;var d,e=a.next();if("`"==e||"'"==e||'"'==e)return c(g(e,"string",'"'==e||"`"==e),a,b);if("/"==e){var f=a.current().length;if(a.skipTo("/")){var k=a.current().length;a.backUp(a.current().length-f);for(var l=0;a.current().length<k;){var m=a.next();if("("==m?l+=1:")"==m&&(l-=1),0>l)break}if(a.backUp(a.current().length-f),0==l)return c(g(e,"string-2",!0),a,b)}return"operator"}if("%"==e){var o="string",p=!0;a.eat("s")?o="atom":a.eat(/[WQ]/)?o="string":a.eat(/[r]/)?o="string-2":a.eat(/[wxq]/)&&(o="string",p=!1);var q=a.eat(/[^\w\s=]/);return q?(n.propertyIsEnumerable(q)&&(q=n[q]),c(g(q,o,p,!0),a,b)):"operator"}if("#"==e)return a.skipToEnd(),"comment";if("<"==e&&(d=a.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/)))return c(h(d[1]),a,b);if("0"==e)return a.eat("x")?a.eatWhile(/[\da-fA-F]/):a.eat("b")?a.eatWhile(/[01]/):a.eatWhile(/[0-7]/),"number";if(/\d/.test(e))return a.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),"number";if("?"==e){for(;a.match(/^\\[CM]-/););return a.eat("\\")?a.eatWhile(/\w/):a.next(),"string"}if(":"==e)return a.eat("'")?c(g("'","atom",!1),a,b):a.eat('"')?c(g('"',"atom",!0),a,b):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("@"==e&&a.match(/^@?[a-zA-Z_\xa1-\uffff]/))return a.eat("@"),a.eatWhile(/[\w\xa1-\uffff]/),"variable-2";if("$"==e)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(e))return a.eatWhile(/[\w\xa1-\uffff]/),a.eat(/[\?\!]/),a.eat(":")?"atom":"ident";if("|"!=e||!b.varList&&"{"!=b.lastTok&&"do"!=b.lastTok){if(/[\(\)\[\]{}\\;]/.test(e))return j=e,null;if("-"==e&&a.eat(">"))return"arrow";if(/[=+\-\/*:\.^%<>~|]/.test(e)){var r=a.eatWhile(/[=+\-\/*:\.^%<>~|]/);return"."!=e||r||(j="."),"operator"}return null}return j="|",null}function e(a){return a||(a=1),function(b,c){if("}"==b.peek()){if(1==a)return c.tokenize.pop(),c.tokenize[c.tokenize.length-1](b,c);c.tokenize[c.tokenize.length-1]=e(a-1)}else"{"==b.peek()&&(c.tokenize[c.tokenize.length-1]=e(a+1));return d(b,c)}}function f(){var a=!1;return function(b,c){return a?(c.tokenize.pop(),c.tokenize[c.tokenize.length-1](b,c)):(a=!0,d(b,c))}}function g(a,b,c,d){return function(g,h){var i,j=!1;for("read-quoted-paused"===h.context.type&&(h.context=h.context.prev,g.eat("}"));null!=(i=g.next());){if(i==a&&(d||!j)){h.tokenize.pop();break}if(c&&"#"==i&&!j){if(g.eat("{")){"}"==a&&(h.context={prev:h.context,type:"read-quoted-paused"}),h.tokenize.push(e());break}if(/[@\$]/.test(g.peek())){h.tokenize.push(f());break}}j=!j&&"\\"==i}return b}}function h(a){return function(b,c){return b.match(a)?c.tokenize.pop():b.skipToEnd(),"string"}}function i(a,b){return a.sol()&&a.match("=end")&&a.eol()&&b.tokenize.pop(),a.skipToEnd(),"comment"}var j,k=b(["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__"]),l=b(["def","class","case","for","while","module","then","catch","loop","proc","begin"]),m=b(["end","until"]),n={"[":"]","{":"}","(":")"};return{startState:function(){return{tokenize:[d],indented:0,context:{type:"top",indented:-a.indentUnit},continuedLine:!1,lastTok:null,varList:!1}},token:function(a,b){a.sol()&&(b.indented=a.indentation());var c,d=b.tokenize[b.tokenize.length-1](a,b),e=j;if("ident"==d){var f=a.current();d="."==b.lastTok?"property":k.propertyIsEnumerable(a.current())?"keyword":/^[A-Z]/.test(f)?"tag":"def"==b.lastTok||"class"==b.lastTok||b.varList?"def":"variable","keyword"==d&&(e=f,l.propertyIsEnumerable(f)?c="indent":m.propertyIsEnumerable(f)?c="dedent":"if"!=f&&"unless"!=f||a.column()!=a.indentation()?"do"==f&&b.context.indented<b.indented&&(c="indent"):c="indent")}return(j||d&&"comment"!=d)&&(b.lastTok=e),"|"==j&&(b.varList=!b.varList),"indent"==c||/[\(\[\{]/.test(j)?b.context={prev:b.context,type:j||d,indented:b.indented}:("dedent"==c||/[\)\]\}]/.test(j))&&b.context.prev&&(b.context=b.context.prev),a.eol()&&(b.continuedLine="\\"==j||"operator"==d),d},indent:function(b,c){if(b.tokenize[b.tokenize.length-1]!=d)return 0;var e=c&&c.charAt(0),f=b.context,g=f.type==n[e]||"keyword"==f.type&&/^(?:end|until|else|elsif|when|rescue)\b/.test(c);return f.indented+(g?0:a.indentUnit)+(b.continuedLine?a.indentUnit:0)},electricChars:"}de",lineComment:"#"}}),a.defineMIME("text/x-ruby","ruby")});