!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("oz",function(r){function e(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var t,o=/[\^@!\|<>#~\.\*\-\+\\/,=]/,i=/(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/,a=/(:::)|(\.\.\.)|(=<:)|(>=:)/,n=["in","then","else","of","elseof","elsecase","elseif","catch","finally","with","require","prepare","import","export","define","do"],c=["end"],u=e(["true","false","nil","unit"]),f=e(["andthen","at","attr","declare","feat","from","lex","mod","div","mode","orelse","parser","prod","prop","scanner","self","syn","token"]),d=e(["local","proc","fun","case","class","if","cond","or","dis","choice","not","thread","try","raise","lock","for","suchthat","meth","functor"]),s=e(n),l=e(c);function m(e,t){if(e.eatSpace())return null;if(e.match(/[{}]/))return"bracket";if(e.match(/(\[])/))return"keyword";if(e.match(a)||e.match(i))return"operator";if(e.match(u))return"atom";var n=e.match(d);if(n)return t.doInCurrentLine?t.doInCurrentLine=!1:t.currentIndent++,"proc"==n[0]||"fun"==n[0]?t.tokenize=p:"class"==n[0]?t.tokenize=h:"meth"==n[0]&&(t.tokenize=k),"keyword";if(e.match(s)||e.match(f))return"keyword";if(e.match(l))return t.currentIndent--,"keyword";var r=e.next();if('"'==r||"'"==r)return t.tokenize=function(i){return function(e,t){for(var n,r=!1,o=!1;null!=(n=e.next());){if(n==i&&!r){o=!0;break}r=!r&&"\\"==n}return!o&&r||(t.tokenize=m),"string"}}(r),t.tokenize(e,t);if(/[~\d]/.test(r)){if("~"==r){if(!/^[0-9]/.test(e.peek()))return null;if("0"==e.next()&&e.match(/^[xX][0-9a-fA-F]+/)||e.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))return"number"}return"0"==r&&e.match(/^[xX][0-9a-fA-F]+/)||e.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)?"number":null}return"%"==r?(e.skipToEnd(),"comment"):"/"==r&&e.eat("*")?(t.tokenize=z)(e,t):o.test(r)?"operator":(e.eatWhile(/\w/),"variable")}function h(e,t){return e.eatSpace()?null:(e.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/),t.tokenize=m,"variable-3")}function k(e,t){return e.eatSpace()?null:(e.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/),t.tokenize=m,"def")}function p(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=m,"def"):(t.tokenize=m,null)}function z(e,t){for(var n,r=!1;n=e.next();){if("/"==n&&r){t.tokenize=m;break}r="*"==n}return"comment"}return{startState:function(){return{tokenize:m,currentIndent:0,doInCurrentLine:!1,hasPassedFirstStage:!1}},token:function(e,t){return e.sol()&&(t.doInCurrentLine=0),t.tokenize(e,t)},indent:function(e,t){var n=t.replace(/^\s+|\s+$/g,"");return n.match(l)||n.match(s)||n.match(/(\[])/)?r.indentUnit*(e.currentIndent-1):e.currentIndent<0?0:e.currentIndent*r.indentUnit},fold:"indent",electricInput:(t=n.concat(c),new RegExp("[\\[\\]]|("+t.join("|")+")$")),lineComment:"%",blockCommentStart:"/*",blockCommentEnd:"*/"}}),e.defineMIME("text/x-oz","oz")});