function words(e){for(var t={},n=e.split(" "),i=0;i<n.length;++i)t[n[i]]=!0;return t}var keywords=words("algorithm and annotation assert block break class connect connector constant constrainedby der discrete each else elseif elsewhen encapsulated end enumeration equation expandable extends external false final flow for function if import impure in initial inner input loop model not operator or outer output package parameter partial protected public pure record redeclare replaceable return stream then true type when while within"),builtin=words("abs acos actualStream asin atan atan2 cardinality ceil cos cosh delay div edge exp floor getInstanceName homotopy inStream integer log log10 mod pre reinit rem semiLinear sign sin sinh spatialDistribution sqrt tan tanh"),atoms=words("Real Boolean Integer String"),completions=[].concat(Object.keys(keywords),Object.keys(builtin),Object.keys(atoms)),isSingleOperatorChar=/[;=\(:\),{}.*<>+\-\/^\[\]]/,isDoubleOperatorChar=/(:=|<=|>=|==|<>|\.\+|\.\-|\.\*|\.\/|\.\^)/,isDigit=/[0-9]/,isNonDigit=/[_a-zA-Z]/;function tokenLineComment(e,t){return e.skipToEnd(),t.tokenize=null,"comment"}function tokenBlockComment(e,t){for(var n,i=!1;n=e.next();){if(i&&"/"==n){t.tokenize=null;break}i="*"==n;}return "comment"}function tokenString(e,t){for(var n,i=!1;null!=(n=e.next());){if('"'==n&&!i){t.tokenize=null,t.sol=!1;break}i=!i&&"\\"==n;}return "string"}function tokenIdent(e,t){for(e.eatWhile(isDigit);e.eat(isDigit)||e.eat(isNonDigit););var n=e.current();return !t.sol||"package"!=n&&"model"!=n&&"when"!=n&&"connector"!=n?t.sol&&"end"==n&&t.level>0&&t.level--:t.level++,t.tokenize=null,t.sol=!1,keywords.propertyIsEnumerable(n)?"keyword":builtin.propertyIsEnumerable(n)?"builtin":atoms.propertyIsEnumerable(n)?"atom":"variable"}function tokenQIdent(e,t){for(;e.eat(/[^']/););return t.tokenize=null,t.sol=!1,e.eat("'")?"variable":"error"}function tokenUnsignedNumber(e,t){return e.eatWhile(isDigit),e.eat(".")&&e.eatWhile(isDigit),(e.eat("e")||e.eat("E"))&&(e.eat("-")||e.eat("+"),e.eatWhile(isDigit)),t.tokenize=null,t.sol=!1,"number"}const modelica={startState:function(){return {tokenize:null,level:0,sol:!0}},token:function(e,t){if(null!=t.tokenize)return t.tokenize(e,t);if(e.sol()&&(t.sol=!0),e.eatSpace())return t.tokenize=null,null;var n=e.next();if("/"==n&&e.eat("/"))t.tokenize=tokenLineComment;else if("/"==n&&e.eat("*"))t.tokenize=tokenBlockComment;else {if(isDoubleOperatorChar.test(n+e.peek()))return e.next(),t.tokenize=null,"operator";if(isSingleOperatorChar.test(n))return t.tokenize=null,"operator";if(isNonDigit.test(n))t.tokenize=tokenIdent;else if("'"==n&&e.peek()&&"'"!=e.peek())t.tokenize=tokenQIdent;else if('"'==n)t.tokenize=tokenString;else {if(!isDigit.test(n))return t.tokenize=null,"error";t.tokenize=tokenUnsignedNumber;}}return t.tokenize(e,t)},indent:function(e,t,n){if(null!=e.tokenize)return null;var i=e.level;return /(algorithm)/.test(t)&&i--,/(equation)/.test(t)&&i--,/(initial algorithm)/.test(t)&&i--,/(initial equation)/.test(t)&&i--,/(end)/.test(t)&&i--,i>0?n.unit*i:0},languageData:{commentTokens:{line:"//",block:{open:"/*",close:"*/"}},autocomplete:completions}};

export { modelica };
