var c={slash:0,parenthesis:1},a={comment:0,_string:1,characterClass:2};const r={name:"ebnf",startState:function(){return{stringType:null,commentType:null,braced:0,lhs:!0,localState:null,stack:[],inDefinition:!1}},token:function(e,t){if(e){switch(t.stack.length===0&&(e.peek()=='"'||e.peek()=="'"?(t.stringType=e.peek(),e.next(),t.stack.unshift(a._string)):e.match("/*")?(t.stack.unshift(a.comment),t.commentType=c.slash):e.match("(*")&&(t.stack.unshift(a.comment),t.commentType=c.parenthesis)),t.stack[0]){case a._string:for(;t.stack[0]===a._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";case a.comment:for(;t.stack[0]===a.comment&&!e.eol();)t.commentType===c.slash&&e.match("*/")||t.commentType===c.parenthesis&&e.match("*)")?(t.stack.shift(),t.commentType=null):e.match(/^.[^\*]*/);return"comment";case a.characterClass:for(;t.stack[0]===a.characterClass&&!e.eol();)e.match(/^[^\]\\]+/)||e.match(".")||t.stack.shift();return"operator"}var s=e.peek();switch(s){case"[":return e.next(),t.stack.unshift(a.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"bracket";break;case"/":if(e.match(/[\/][A-Za-z]+/))return"keyword";case"\\":if(e.match(/[\][a-z]+/))return"string.special";case".":if(e.match("."))return"atom";case"*":case"-":case"+":case"^":if(e.match(s))return"atom";case"$":if(e.match("$$"))return"builtin";if(e.match(/[$][0-9]+/))return"variableName.special";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":"variableName.special":["[","]","(",")"].indexOf(e.peek())==-1?(e.eatSpace()||e.next(),null):(e.next(),"bracket")}}};export{r as ebnf};
