function switchState(t,e,r){return e(r),r(t,e)}var lowerRE=/[a-z]/,upperRE=/[A-Z]/,innerRE=/[a-zA-Z0-9_]/,digitRE=/[0-9]/,hexRE=/[0-9A-Fa-f]/,symbolRE=/[-&*+.\\/<>=?^|:]/,specialRE=/[(),[\]{}]/,spacesRE=/[ \v\f]/;function normal(){return function(t,e){if(t.eatWhile(spacesRE))return null;var r=t.next();if(specialRE.test(r))return "{"===r&&t.eat("-")?switchState(t,e,chompMultiComment(1)):"["===r&&t.match("glsl|")?switchState(t,e,chompGlsl):"builtin";if("'"===r)return switchState(t,e,chompChar);if('"'===r)return t.eat('"')?t.eat('"')?switchState(t,e,chompMultiString):"string":switchState(t,e,chompSingleString);if(upperRE.test(r))return t.eatWhile(innerRE),"type";if(lowerRE.test(r)){var n=1===t.pos;return t.eatWhile(innerRE),n?"def":"variable"}if(digitRE.test(r)){if("0"===r){if(t.eat(/[xX]/))return t.eatWhile(hexRE),"number"}else t.eatWhile(digitRE);return t.eat(".")&&t.eatWhile(digitRE),t.eat(/[eE]/)&&(t.eat(/[-+]/),t.eatWhile(digitRE)),"number"}return symbolRE.test(r)?"-"===r&&t.eat("-")?(t.skipToEnd(),"comment"):(t.eatWhile(symbolRE),"keyword"):"_"===r?"keyword":"error"}}function chompMultiComment(t){return 0==t?normal():function(e,r){for(;!e.eol();){var n=e.next();if("{"==n&&e.eat("-"))++t;else if("-"==n&&e.eat("}")&&0===--t)return r(normal()),"comment"}return r(chompMultiComment(t)),"comment"}}function chompMultiString(t,e){for(;!t.eol();){if('"'===t.next()&&t.eat('"')&&t.eat('"'))return e(normal()),"string"}return "string"}function chompSingleString(t,e){for(;t.skipTo('\\"');)t.next(),t.next();return t.skipTo('"')?(t.next(),e(normal()),"string"):(t.skipToEnd(),e(normal()),"error")}function chompChar(t,e){for(;t.skipTo("\\'");)t.next(),t.next();return t.skipTo("'")?(t.next(),e(normal()),"string"):(t.skipToEnd(),e(normal()),"error")}function chompGlsl(t,e){for(;!t.eol();){if("|"===t.next()&&t.eat("]"))return e(normal()),"string"}return "string"}var wellKnownWords={case:1,of:1,as:1,if:1,then:1,else:1,let:1,in:1,type:1,alias:1,module:1,where:1,import:1,exposing:1,port:1};const elm={startState:function(){return {f:normal()}},copyState:function(t){return {f:t.f}},token:function(t,e){var r=e.f(t,(function(t){e.f=t;})),n=t.current();return wellKnownWords.hasOwnProperty(n)?"keyword":r}};

export { elm };
