function switchState(source,setState,f){return setState(f),f(source,setState)}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(source,setState){if(source.eatWhile(spacesRE))return null;var char=source.next();if(specialRE.test(char))return"{"===char&&source.eat("-")?switchState(source,setState,chompMultiComment(1)):"["===char&&source.match("glsl|")?switchState(source,setState,chompGlsl):"builtin";if("'"===char)return switchState(source,setState,chompChar);if('"'===char)return source.eat('"')?source.eat('"')?switchState(source,setState,chompMultiString):"string":switchState(source,setState,chompSingleString);if(upperRE.test(char))return source.eatWhile(innerRE),"type";if(lowerRE.test(char)){var isDef=1===source.pos;return source.eatWhile(innerRE),isDef?"def":"variable"}if(digitRE.test(char)){if("0"===char){if(source.eat(/[xX]/))return source.eatWhile(hexRE),"number"}else source.eatWhile(digitRE);return source.eat(".")&&source.eatWhile(digitRE),source.eat(/[eE]/)&&(source.eat(/[-+]/),source.eatWhile(digitRE)),"number"}return symbolRE.test(char)?"-"===char&&source.eat("-")?(source.skipToEnd(),"comment"):(source.eatWhile(symbolRE),"keyword"):"_"===char?"keyword":"error"}}function chompMultiComment(nest){return 0==nest?normal():function(source,setState){for(;!source.eol();){var char=source.next();if("{"==char&&source.eat("-"))++nest;else if("-"==char&&source.eat("}")&&0===--nest)return setState(normal()),"comment"}return setState(chompMultiComment(nest)),"comment"}}function chompMultiString(source,setState){for(;!source.eol();){if('"'===source.next()&&source.eat('"')&&source.eat('"'))return setState(normal()),"string"}return"string"}function chompSingleString(source,setState){for(;source.skipTo('\\"');)source.next(),source.next();return source.skipTo('"')?(source.next(),setState(normal()),"string"):(source.skipToEnd(),setState(normal()),"error")}function chompChar(source,setState){for(;source.skipTo("\\'");)source.next(),source.next();return source.skipTo("'")?(source.next(),setState(normal()),"string"):(source.skipToEnd(),setState(normal()),"error")}function chompGlsl(source,setState){for(;!source.eol();){if("|"===source.next()&&source.eat("]"))return setState(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={name:"elm",startState:function(){return{f:normal()}},copyState:function(s){return{f:s.f}},token:function(stream,state){var type=state.f(stream,function(s){state.f=s}),word=stream.current();return wellKnownWords.hasOwnProperty(word)?"keyword":type},languageData:{commentTokens:{line:"--"}}};export{elm};
