function o(e){return RegExp("^(("+e.join(")|(")+"))\\b")}var h=/[\^@!\|<>#~\.\*\-\+\\/,=]/,m=/(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/,k=/(:::)|(\.\.\.)|(=<:)|(>=:)/,i=["in","then","else","of","elseof","elsecase","elseif","catch","finally","with","require","prepare","import","export","define","do"],s=["end"],p=o(["true","false","nil","unit"]),z=o(["andthen","at","attr","declare","feat","from","lex","mod","div","mode","orelse","parser","prod","prop","scanner","self","syn","token"]),g=o(["local","proc","fun","case","class","if","cond","or","dis","choice","not","thread","try","raise","lock","for","suchthat","meth","functor"]),f=o(i),l=o(s);function a(e,t){if(e.eatSpace())return null;if(e.match(/[{}]/))return"bracket";if(e.match("[]"))return"keyword";if(e.match(k)||e.match(m))return"operator";if(e.match(p))return"atom";var r=e.match(g);if(r)return t.doInCurrentLine?t.doInCurrentLine=!1:t.currentIndent++,r[0]=="proc"||r[0]=="fun"?t.tokenize=v:r[0]=="class"?t.tokenize=x:r[0]=="meth"&&(t.tokenize=I),"keyword";if(e.match(f)||e.match(z))return"keyword";if(e.match(l))return t.currentIndent--,"keyword";var n=e.next();if(n=='"'||n=="'")return t.tokenize=S(n),t.tokenize(e,t);if(/[~\d]/.test(n)){if(n=="~")if(/^[0-9]/.test(e.peek())){if(e.next()=="0"&&e.match(/^[xX][0-9a-fA-F]+/)||e.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))return"number"}else return null;return n=="0"&&e.match(/^[xX][0-9a-fA-F]+/)||e.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)?"number":null}return n=="%"?(e.skipToEnd(),"comment"):n=="/"&&e.eat("*")?(t.tokenize=d,d(e,t)):h.test(n)?"operator":(e.eatWhile(/\w/),"variable")}function x(e,t){return e.eatSpace()?null:(e.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/),t.tokenize=a,"type")}function I(e,t){return e.eatSpace()?null:(e.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/),t.tokenize=a,"def")}function v(e,t){return e.eatSpace()?null:!t.hasPassedFirstStage&&e.eat("{")?(t.hasPassedFirstStage=!0,"bracket"):t.hasPassedFirstStage?(e.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/),t.hasPassedFirstStage=!1,t.tokenize=a,"def"):(t.tokenize=a,null)}function d(e,t){for(var r=!1,n;n=e.next();){if(n=="/"&&r){t.tokenize=a;break}r=n=="*"}return"comment"}function S(e){return function(t,r){for(var n=!1,c,u=!1;(c=t.next())!=null;){if(c==e&&!n){u=!0;break}n=!n&&c=="\\"}return(u||!n)&&(r.tokenize=a),"string"}}function b(){var e=i.concat(s);return RegExp("[\\[\\]]|("+e.join("|")+")$")}const y={name:"oz",startState:function(){return{tokenize:a,currentIndent:0,doInCurrentLine:!1,hasPassedFirstStage:!1}},token:function(e,t){return e.sol()&&(t.doInCurrentLine=0),t.tokenize(e,t)},indent:function(e,t,r){var n=t.replace(/^\s+|\s+$/g,"");return n.match(l)||n.match(f)||n.match(/(\[])/)?r.unit*(e.currentIndent-1):e.currentIndent<0?0:e.currentIndent*r.unit},languageData:{indentOnInut:b(),commentTokens:{line:"%",block:{open:"/*",close:"*/"}}}};export{y as t};
