function words(e){for(var t={},n=e.split(" "),r=0;r<n.length;++r)t[n[r]]=!0;return t}const parserConfig={keywords:words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue debug default delegate delete deprecated export extern final finally function goto immutable import inout invariant is lazy macro module new nothrow override package pragma private protected public pure ref return shared short static super synchronized template this throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters "+(blockKeywords="body catch class do else enum for foreach foreach_reverse if in interface mixin out scope struct switch try union unittest version while with")),blockKeywords:words(blockKeywords),builtin:words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte ucent uint ulong ushort wchar wstring void size_t sizediff_t"),atoms:words("exit failure success true false null"),hooks:{"@":function(e,t){return e.eatWhile(/[\w\$_]/),"meta"}}};var curPunc,keywords=parserConfig.keywords,builtin=parserConfig.builtin,blockKeywords=parserConfig.blockKeywords,atoms=parserConfig.atoms,hooks=parserConfig.hooks,multiLineStrings=parserConfig.multiLineStrings,isOperatorChar=/[+\-*&%=<>!?|\/]/;function tokenBase(e,t){var n=e.next();if(hooks[n]){var r=hooks[n](e,t);if(!1!==r)return r}if('"'==n||"'"==n||"`"==n)return t.tokenize=tokenString(n),t.tokenize(e,t);if(/[\[\]{}\(\),;\:\.]/.test(n))return curPunc=n,null;if(/\d/.test(n))return e.eatWhile(/[\w\.]/),"number";if("/"==n){if(e.eat("+"))return t.tokenize=tokenNestedComment,tokenNestedComment(e,t);if(e.eat("*"))return t.tokenize=tokenComment,tokenComment(e,t);if(e.eat("/"))return e.skipToEnd(),"comment"}if(isOperatorChar.test(n))return e.eatWhile(isOperatorChar),"operator";e.eatWhile(/[\w\$_\xa1-\uffff]/);var o=e.current();return keywords.propertyIsEnumerable(o)?(blockKeywords.propertyIsEnumerable(o)&&(curPunc="newstatement"),"keyword"):builtin.propertyIsEnumerable(o)?(blockKeywords.propertyIsEnumerable(o)&&(curPunc="newstatement"),"builtin"):atoms.propertyIsEnumerable(o)?"atom":"variable"}function tokenString(e){return function(t,n){for(var r,o=!1,i=!1;null!=(r=t.next());){if(r==e&&!o){i=!0;break}o=!o&&"\\"==r;}return (i||!o&&!multiLineStrings)&&(n.tokenize=null),"string"}}function tokenComment(e,t){for(var n,r=!1;n=e.next();){if("/"==n&&r){t.tokenize=null;break}r="*"==n;}return "comment"}function tokenNestedComment(e,t){for(var n,r=!1;n=e.next();){if("/"==n&&r){t.tokenize=null;break}r="+"==n;}return "comment"}function Context(e,t,n,r,o){this.indented=e,this.column=t,this.type=n,this.align=r,this.prev=o;}function pushContext(e,t,n){var r=e.indented;return e.context&&"statement"==e.context.type&&(r=e.context.indented),e.context=new Context(r,t,n,null,e.context)}function popContext(e){var t=e.context.type;return ")"!=t&&"]"!=t&&"}"!=t||(e.indented=e.context.indented),e.context=e.context.prev}const d={startState:function(e){return {tokenize:null,context:new Context(-e,0,"top",!1),indented:0,startOfLine:!0}},token:function(e,t){var n=t.context;if(e.sol()&&(null==n.align&&(n.align=!1),t.indented=e.indentation(),t.startOfLine=!0),e.eatSpace())return null;curPunc=null;var r=(t.tokenize||tokenBase)(e,t);if("comment"==r||"meta"==r)return r;if(null==n.align&&(n.align=!0),";"!=curPunc&&":"!=curPunc&&","!=curPunc||"statement"!=n.type)if("{"==curPunc)pushContext(t,e.column(),"}");else if("["==curPunc)pushContext(t,e.column(),"]");else if("("==curPunc)pushContext(t,e.column(),")");else if("}"==curPunc){for(;"statement"==n.type;)n=popContext(t);for("}"==n.type&&(n=popContext(t));"statement"==n.type;)n=popContext(t);}else curPunc==n.type?popContext(t):(("}"==n.type||"top"==n.type)&&";"!=curPunc||"statement"==n.type&&"newstatement"==curPunc)&&pushContext(t,e.column(),"statement");else popContext(t);return t.startOfLine=!1,r},indent:function(e,t,n){if(e.tokenize!=tokenBase&&null!=e.tokenize)return null;var r=e.context,o=t&&t.charAt(0);"statement"==r.type&&"}"==o&&(r=r.prev);var i=o==r.type;return "statement"==r.type?r.indented+("{"==o?0:n.unit):r.align?r.column+(i?0:1):r.indented+(i?0:n.unit)},languageData:{indentOnInput:/^\s*[{}]$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}};

export { d };
