1 line
5.1 KiB
JavaScript
Vendored
1 line
5.1 KiB
JavaScript
Vendored
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2602],{62602:function(e,t,n){function r(e,t){return RegExp((t?"":"^")+"(?:"+e.join("|")+")"+(t?"$":"\\b"))}function a(e,t,n){return n.tokenize.push(e),e(t,n)}n.r(t),n.d(t,{crystal:function(){return E}});var u=/^(?:[-+/%|&^]|\*\*?|[<>]{2})/,i=/^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/,c=/^(?:\[\][?=]?)/,o=/^(?:\.(?:\.{2})?|->|[?:])/,s=/^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/,l=/^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/,f=r(["abstract","alias","as","asm","begin","break","case","class","def","do","else","elsif","end","ensure","enum","extend","for","fun","if","include","instance_sizeof","lib","macro","module","next","of","out","pointerof","private","protected","rescue","return","require","select","sizeof","struct","super","then","type","typeof","uninitialized","union","unless","until","when","while","with","yield","__DIR__","__END_LINE__","__FILE__","__LINE__"]),m=r(["true","false","nil","self"]),h=r(["def","fun","macro","class","module","struct","lib","enum","union","do","for"]),p=r(["if","unless","case","while","until","begin","then"]),k=["end","else","elsif","rescue","ensure"],d=r(k),F=["\\)","\\}","\\]"],_=RegExp("^(?:"+F.join("|")+")$"),z={def:I,fun:I,macro:function(e,t){var n;if(e.eatSpace())return null;if(n=e.match(s)){if("def"==n)return"keyword";e.eat(/[?!]/)}return t.tokenize.pop(),"def"},class:w,module:w,struct:w,lib:w,enum:w,union:w},b={"[":"]","{":"}","(":")","<":">"};function g(e,t){if(e.eatSpace())return null;if("\\"!=t.lastToken&&e.match("{%",!1))return a(y("%","%"),e,t);if("\\"!=t.lastToken&&e.match("{{",!1))return a(y("{","}"),e,t);if("#"==e.peek())return e.skipToEnd(),"comment";if(e.match(s))return(e.eat(/[?!]/),k=e.current(),e.eat(":"))?"atom":"."==t.lastToken?"property":f.test(k)?(h.test(k)?"fun"==k&&t.blocks.indexOf("lib")>=0||"def"==k&&"abstract"==t.lastToken||(t.blocks.push(k),t.currentIndent+=1):("operator"==t.lastStyle||!t.lastStyle)&&p.test(k)?(t.blocks.push(k),t.currentIndent+=1):"end"==k&&(t.blocks.pop(),t.currentIndent-=1),z.hasOwnProperty(k)&&t.tokenize.push(z[k]),"keyword"):m.test(k)?"atom":"variable";if(e.eat("@"))return"["==e.peek()?a(x("[","]","meta"),e,t):(e.eat("@"),e.match(s)||e.match(l),"propertyName");if(e.match(l))return"tag";if(e.eat(":"))return e.eat('"')?a(v('"',"atom",!1),e,t):e.match(s)||e.match(l)||e.match(u)||e.match(i)||e.match(c)?"atom":(e.eat(":"),"operator");if(e.eat('"'))return a(v('"',"string",!0),e,t);if("%"==e.peek()){var n,r,k,d,F="string",_=!0;if(e.match("%r"))F="string.special",d=e.next();else if(e.match("%w"))_=!1,d=e.next();else if(e.match("%q"))_=!1,d=e.next();else if(d=e.match(/^%([^\w\s=])/))d=d[1];else if(e.match(/^%[a-zA-Z_\u009F-\uFFFF][\w\u009F-\uFFFF]*/))return"meta";else if(e.eat("%"))return"operator";return b.hasOwnProperty(d)&&(d=b[d]),a(v(d,F,_),e,t)}return(k=e.match(/^<<-('?)([A-Z]\w*)\1/))?a((n=k[2],r=!k[1],function(e,t){if(e.sol()&&(e.eatSpace(),e.match(n)))return t.tokenize.pop(),"string";for(var a=!1;e.peek();)if(a)e.next(),a=!1;else{if(e.match("{%",!1))return t.tokenize.push(y("%","%")),"string";if(e.match("{{",!1))return t.tokenize.push(y("{","}")),"string";if(r&&e.match("#{",!1))return t.tokenize.push(x("#{","}","meta")),"string";a=r&&"\\"==e.next()}return"string"}),e,t):e.eat("'")?(e.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/),e.eat("'"),"atom"):e.eat("0")?(e.eat("x")?e.match(/^[0-9a-fA-F_]+/):e.eat("o")?e.match(/^[0-7_]+/):e.eat("b")&&e.match(/^[01_]+/),"number"):e.eat(/^\d/)?(e.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?\d+)?/),"number"):e.match(u)?(e.eat("="),"operator"):e.match(i)||e.match(o)?"operator":(k=e.match(/[({[]/,!1))?a(x(k=k[0],b[k],null),e,t):e.eat("\\")?(e.next(),"meta"):(e.next(),null)}function x(e,t,n,r){return function(a,u){if(!r&&a.match(e))return u.tokenize[u.tokenize.length-1]=x(e,t,n,!0),u.currentIndent+=1,n;var i=g(a,u);return a.current()===t&&(u.tokenize.pop(),u.currentIndent-=1,i=n),i}}function y(e,t,n){return function(r,a){return!n&&r.match("{"+e)?(a.currentIndent+=1,a.tokenize[a.tokenize.length-1]=y(e,t,!0),"meta"):r.match(t+"}")?(a.currentIndent-=1,a.tokenize.pop(),"meta"):g(r,a)}}function I(e,t){return e.eatSpace()?null:(e.match(s)?e.eat(/[!?]/):e.match(u)||e.match(i)||e.match(c),t.tokenize.pop(),"def")}function w(e,t){return e.eatSpace()?null:(e.match(l),t.tokenize.pop(),"def")}function v(e,t,n){return function(r,a){for(var u=!1;r.peek();)if(u)r.next(),u=!1;else{if(r.match("{%",!1))return a.tokenize.push(y("%","%")),t;if(r.match("{{",!1))return a.tokenize.push(y("{","}")),t;if(n&&r.match("#{",!1))return a.tokenize.push(x("#{","}","meta")),t;var i=r.next();if(i==e)return a.tokenize.pop(),t;u=n&&"\\"==i}return t}}let E={name:"crystal",startState:function(){return{tokenize:[g],currentIndent:0,lastToken:null,lastStyle:null,blocks:[]}},token:function(e,t){var n=t.tokenize[t.tokenize.length-1](e,t),r=e.current();return n&&"comment"!=n&&(t.lastToken=r,t.lastStyle=n),n},indent:function(e,t,n){return(t=t.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g,""),d.test(t)||_.test(t))?n.unit*(e.currentIndent-1):n.unit*e.currentIndent},languageData:{indentOnInput:r(F.concat(k),!0),commentTokens:{line:"#"}}}}}]); |