!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("ebnf",function(t){var a={slash:0,parenthesis:1},r={comment:0,_string:1,characterClass:2},c=null;return t.bracesMode&&(c=e.getMode(t,t.bracesMode)),{startState:function(){return{stringType:null,commentType:null,braced:0,lhs:!0,localState:null,stack:[],inDefinition:!1}},token:function(e,t){if(e){switch(0===t.stack.length&&('"'==e.peek()||"'"==e.peek()?(t.stringType=e.peek(),e.next(),t.stack.unshift(r._string)):e.match(/^\/\*/)?(t.stack.unshift(r.comment),t.commentType=a.slash):e.match(/^\(\*/)&&(t.stack.unshift(r.comment),t.commentType=a.parenthesis)),t.stack[0]){case r._string:for(;t.stack[0]===r._string&&!e.eol();)e.peek()===t.stringType?(e.next(),t.stack.shift()):"\\"===e.peek()?(e.next(),e.next()):e.match(/^.[^\\\"\']*/);return t.lhs?"property string":"string";case r.comment:for(;t.stack[0]===r.comment&&!e.eol();)t.commentType===a.slash&&e.match(/\*\//)?(t.stack.shift(),t.commentType=null):t.commentType===a.parenthesis&&e.match(/\*\)/)?(t.stack.shift(),t.commentType=null):e.match(/^.[^\*]*/);return"comment";case r.characterClass:for(;t.stack[0]===r.characterClass&&!e.eol();)e.match(/^[^\]\\]+/)||e.match(/^\\./)||t.stack.shift();return"operator"}var n=e.peek();if(null!==c&&(t.braced||"{"===n)){null===t.localState&&(t.localState=c.startState());var s=c.token(e,t.localState),i=e.current();if(!s)for(var o=0;o<i.length;o++)"{"===i[o]?(0===t.braced&&(s="matchingbracket"),t.braced++):"}"===i[o]&&0===--t.braced&&(s="matchingbracket");return s}switch(n){case"[":return e.next(),t.stack.unshift(r.characterClass),"bracket";case":":case"|":case";":return e.next(),"operator";case"%":if(e.match("%%"))return"header";if(e.match(/[%][A-Za-z]+/))return"keyword";if(e.match(/[%][}]/))return"matchingbracket";break;case"/":if(e.match(/[\/][A-Za-z]+/))return"keyword";case"\\":if(e.match(/[\][a-z]+/))return"string-2";case".":if(e.match("."))return"atom";case"*":case"-":case"+":case"^":if(e.match(n))return"atom";case"$":if(e.match("$$"))return"builtin";if(e.match(/[$][0-9]+/))return"variable-3";case"<":if(e.match(/<<[a-zA-Z_]+>>/))return"builtin"}return e.match(/^\/\//)?(e.skipToEnd(),"comment"):e.match(/return/)?"operator":e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)?e.match(/(?=[\(.])/)?"variable":e.match(/(?=[\s\n]*[:=])/)?"def":"variable-2":-1!=["[","]","(",")"].indexOf(e.peek())?(e.next(),"bracket"):(e.eatSpace()||e.next(),null)}}}}),e.defineMIME("text/x-ebnf","ebnf")});