function wordRegexp(words){return new RegExp("^(("+words.join(")|(")+"))\\b")}var singleOperators=/[\^@!\|<>#~\.\*\-\+\\/,=]/,doubleOperators=/(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/,tripleOperators=/(:::)|(\.\.\.)|(=<:)|(>=:)/,middle=["in","then","else","of","elseof","elsecase","elseif","catch","finally","with","require","prepare","import","export","define","do"],end=["end"],atoms=wordRegexp(["true","false","nil","unit"]),commonKeywords=wordRegexp(["andthen","at","attr","declare","feat","from","lex","mod","div","mode","orelse","parser","prod","prop","scanner","self","syn","token"]),openingKeywords=wordRegexp(["local","proc","fun","case","class","if","cond","or","dis","choice","not","thread","try","raise","lock","for","suchthat","meth","functor"]),middleKeywords=wordRegexp(middle),endKeywords=wordRegexp(end);function tokenBase(stream,state){if(stream.eatSpace())return null;if(stream.match(/[{}]/))return"bracket";if(stream.match("[]"))return"keyword";if(stream.match(tripleOperators)||stream.match(doubleOperators))return"operator";if(stream.match(atoms))return"atom";var matched=stream.match(openingKeywords);if(matched)return state.doInCurrentLine?state.doInCurrentLine=!1:state.currentIndent++,"proc"==matched[0]||"fun"==matched[0]?state.tokenize=tokenFunProc:"class"==matched[0]?state.tokenize=tokenClass:"meth"==matched[0]&&(state.tokenize=tokenMeth),"keyword";if(stream.match(middleKeywords)||stream.match(commonKeywords))return"keyword";if(stream.match(endKeywords))return state.currentIndent--,"keyword";var quote,ch=stream.next();if('"'==ch||"'"==ch)return state.tokenize=(quote=ch,function(stream,state){for(var next,escaped=!1,end2=!1;null!=(next=stream.next());){if(next==quote&&!escaped){end2=!0;break}escaped=!escaped&&"\\"==next}return!end2&&escaped||(state.tokenize=tokenBase),"string"}),state.tokenize(stream,state);if(/[~\d]/.test(ch)){if("~"==ch){if(!/^[0-9]/.test(stream.peek()))return null;if("0"==stream.next()&&stream.match(/^[xX][0-9a-fA-F]+/)||stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))return"number"}return"0"==ch&&stream.match(/^[xX][0-9a-fA-F]+/)||stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)?"number":null}return"%"==ch?(stream.skipToEnd(),"comment"):"/"==ch&&stream.eat("*")?(state.tokenize=tokenComment,tokenComment(stream,state)):singleOperators.test(ch)?"operator":(stream.eatWhile(/\w/),"variable")}function tokenClass(stream,state){return stream.eatSpace()?null:(stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/),state.tokenize=tokenBase,"type")}function tokenMeth(stream,state){return stream.eatSpace()?null:(stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/),state.tokenize=tokenBase,"def")}function tokenFunProc(stream,state){return stream.eatSpace()?null:!state.hasPassedFirstStage&&stream.eat("{")?(state.hasPassedFirstStage=!0,"bracket"):state.hasPassedFirstStage?(stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/),state.hasPassedFirstStage=!1,state.tokenize=tokenBase,"def"):(state.tokenize=tokenBase,null)}function tokenComment(stream,state){for(var ch,maybeEnd=!1;ch=stream.next();){if("/"==ch&&maybeEnd){state.tokenize=tokenBase;break}maybeEnd="*"==ch}return"comment"}const oz={name:"oz",startState:function(){return{tokenize:tokenBase,currentIndent:0,doInCurrentLine:!1,hasPassedFirstStage:!1}},token:function(stream,state){return stream.sol()&&(state.doInCurrentLine=0),state.tokenize(stream,state)},indent:function(state,textAfter,cx){var trueText=textAfter.replace(/^\s+|\s+$/g,"");return trueText.match(endKeywords)||trueText.match(middleKeywords)||trueText.match(/(\[])/)?cx.unit*(state.currentIndent-1):state.currentIndent<0?0:state.currentIndent*cx.unit},languageData:{indentOnInut:(allClosings=middle.concat(end),new RegExp("[\\[\\]]|("+allClosings.join("|")+")$")),commentTokens:{line:"%",block:{open:"/*",close:"*/"}}}};var allClosings;export{oz};
