'use strict';(function(p){"object"==typeof exports&&"object"==typeof module?p(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],p):p(CodeMirror)})(function(p){p.defineMode("haxe",function(f,q){function c(a){return{type:a,style:"keyword"}}function p(a,d){for(var b=!1,k;null!=(k=a.next());){if(k==d&&!b)return!0;b=!b&&"\\"==k}}function n(a,d,b){l=a;M=b;return d}function A(a,d){var b=a.next();if('"'==b||"'"==b)return b=X(b),d.tokenize=b,b(a,d);if(/[\[\]{}\(\),;:\.]/.test(b))return n(b);
if("0"==b&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),n("number","number");if(/\d/.test(b)||"-"==b&&a.eat(/\d/))return a.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/),n("number","number");if(d.reAllowed&&"~"==b&&a.eat(/\//))return p(a,"/"),a.eatWhile(/[gimsu]/),n("regexp","string-2");if("/"==b){if(a.eat("*"))return b=Y,d.tokenize=b,b(a,d);if(a.eat("/"))return a.skipToEnd(),n("comment","comment");a.eatWhile(F);return n("operator",null,a.current())}if("#"==b)return a.skipToEnd(),n("conditional","meta");
if("@"==b)return a.eat(/:/),a.eatWhile(/[\w_]/),n("metadata","meta");if(F.test(b))return a.eatWhile(F),n("operator",null,a.current());if(/[A-Z]/.test(b))return a.eatWhile(/[\w_<>]/),a=a.current(),n("type","variable-3",a);a.eatWhile(/[\w_]/);a=a.current();return(b=N.propertyIsEnumerable(a)&&N[a])&&d.kwAllowed?n(b.type,b.style,a):n("variable","variable",a)}function X(a){return function(b,c){p(b,a)&&(c.tokenize=A);return n("string","string")}}function Y(a,b){for(var d=!1,k;k=a.next();){if("/"==k&&d){b.tokenize=
A;break}d="*"==k}return n("comment","comment")}function O(a,b,c,k,g,f){this.indented=a;this.column=b;this.type=c;this.prev=g;this.info=f;null!=k&&(this.align=k)}function P(a){for(var b=g.state,c=b.importedtypes;c;c=c.next)if(c.name==a)return;b.importedtypes={name:a,next:b.importedtypes}}function t(){for(var a=arguments.length-1;0<=a;a--)g.cc.push(arguments[a])}function b(){t.apply(null,arguments);return!0}function Q(a,b){for(;b;b=b.next)if(b.name==a)return!0;return!1}function B(a){var b=g.state;b.context?
(g.marked="def",Q(a,b.localVars)||(b.localVars={name:a,next:b.localVars})):b.globalVars&&!Q(a,b.globalVars)&&(b.globalVars={name:a,next:b.globalVars})}function G(){g.state.context||(g.state.localVars=Z);g.state.context={prev:g.state.context,vars:g.state.localVars}}function C(){g.state.localVars=g.state.context.vars;g.state.context=g.state.context.prev}function h(a,b){var d=function(){var d=g.state;d.lexical=new O(d.indented,g.stream.column(),a,null,d.lexical,b)};d.lex=!0;return d}function e(){var a=
g.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function m(a){function d(c){return c==a?b():";"==a?t():b(d)}return d}function u(a){return"@"==a?b(R):"var"==a?b(h("vardef"),H,m(";"),e):"keyword a"==a?b(h("form"),r,u,e):"keyword b"==a?b(h("form"),u,e):"{"==a?b(h("}"),G,I,e,C):";"==a?b():"attribute"==a?b(S):"function"==a?b(x):"for"==a?b(h("form"),m("("),h(")"),aa,m(")"),e,u,e):"variable"==a?b(h("stat"),ba):"switch"==a?b(h("form"),r,h("}","switch"),
m("{"),I,e,e):"case"==a?b(r,m(":")):"default"==a?b(m(":")):"catch"==a?b(h("form"),G,m("("),T,m(")"),u,e,C):"import"==a?b(U,m(";")):"typedef"==a?b(ca):t(h("stat"),r,m(";"),e)}function r(a){return V.hasOwnProperty(a)||"type"==a?b(v):"function"==a?b(x):"keyword c"==a?b(J):"("==a?b(h(")"),J,m(")"),e,v):"operator"==a?b(r):"["==a?b(h("]"),w(J,"]"),e,v):"{"==a?b(h("}"),w(da,"}"),e,v):b()}function J(a){return a.match(/[;\}\)\],]/)?t():t(r)}function v(a,d){if("operator"==a&&/\+\+|--/.test(d))return b(v);if("operator"==
a||":"==a)return b(r);if(";"!=a){if("("==a)return b(h(")"),w(r,")"),e,v);if("."==a)return b(ea,v);if("["==a)return b(h("]"),r,m("]"),e,v)}}function S(a){if("attribute"==a)return b(S);if("function"==a)return b(x);if("var"==a)return b(H)}function R(a){if(":"==a||"variable"==a)return b(R);if("("==a)return b(h(")"),w(fa,")"),e,u)}function fa(a){if("variable"==a)return b()}function U(a,d){if("variable"==a&&/[A-Z]/.test(d.charAt(0)))return P(d),b();if("variable"==a||"property"==a||"."==a||"*"==d)return b(U)}
function ca(a,d){if("variable"==a&&/[A-Z]/.test(d.charAt(0)))return P(d),b();if("type"==a&&/[A-Z]/.test(d.charAt(0)))return b()}function ba(a){return":"==a?b(e,u):t(v,m(";"),e)}function ea(a){if("variable"==a)return g.marked="property",b()}function da(a){"variable"==a&&(g.marked="property");if(V.hasOwnProperty(a))return b(m(":"),r)}function w(a,d){function c(k){return","==k?b(a,c):k==d?b():b(m(d))}return function(k){return k==d?b():t(a,c)}}function I(a){return"}"==a?b():t(u,I)}function H(a,d){return"variable"==
a?(B(d),b(D,W)):b()}function W(a,d){if("="==d)return b(r,W);if(","==a)return b(H)}function aa(a,d){return"variable"==a?(B(d),b(ha,r)):t()}function ha(a,d){if("in"==d)return b()}function x(a,d){if("variable"==a||"type"==a)return B(d),b(x);if("new"==d)return b(x);if("("==a)return b(h(")"),G,w(T,")"),e,D,u,C)}function D(a){if(":"==a)return b(ia)}function ia(a){if("type"==a||"variable"==a)return b();if("{"==a)return b(h("}"),w(ja,"}"),e)}function ja(a){if("variable"==a)return b(D)}function T(a,d){if("variable"==
a)return B(d),b(D)}var y=f.indentUnit;f=c("keyword a");var K=c("keyword b"),z=c("keyword c"),ka=c("operator"),L={type:"atom",style:"atom"},E={type:"attribute",style:"attribute"},l=c("typedef"),N={"if":f,"while":f,"else":K,"do":K,"try":K,"return":z,"break":z,"continue":z,"new":z,"throw":z,"var":c("var"),inline:E,"static":E,using:c("import"),"public":E,"private":E,cast:c("cast"),"import":c("import"),macro:c("macro"),"function":c("function"),"catch":c("catch"),untyped:c("untyped"),callback:c("cb"),"for":c("for"),
"switch":c("switch"),"case":c("case"),"default":c("default"),"in":ka,never:c("property_access"),trace:c("trace"),"class":l,"abstract":l,"enum":l,"interface":l,typedef:l,"extends":l,"implements":l,dynamic:l,"true":L,"false":L,"null":L},F=/[+\-*&%=<>!?|]/,M,V={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},g={state:null,column:null,marked:null,cc:null},Z={name:"this",next:null};C.lex=!0;e.lex=!0;return{startState:function(a){a={tokenize:A,reAllowed:!0,kwAllowed:!0,cc:[],lexical:new O((a||0)-y,0,
"block",!1),localVars:q.localVars,importedtypes:"Int Float String Void Std Bool Dynamic Array".split(" "),context:q.localVars&&{vars:q.localVars},indented:0};q.globalVars&&"object"==typeof q.globalVars&&(a.globalVars=q.globalVars);return a},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation());if(a.eatSpace())return null;var d=b.tokenize(a,b);if("comment"==l)return d;b.reAllowed=!("operator"!=l&&"keyword c"!=l&&!l.match(/^[\[{}\(,;:]$/));
b.kwAllowed="."!=l;a:{var c=l,f=M,e=b.cc;g.state=b;g.stream=a;g.marked=null;g.cc=e;b.lexical.hasOwnProperty("align")||(b.lexical.align=!0);for(;;)if((e.length?e.pop():u)(c,f)){for(;e.length&&e[e.length-1].lex;)e.pop()();if(g.marked){d=g.marked;break a}if(a="variable"==c)b:{for(a=b.localVars;a;a=a.next)if(a.name==f){a=!0;break b}a=void 0}if(a){d="variable-2";break a}if(c="variable"==c)b:if(/[a-z]/.test(f.charAt(0)))c=!1;else{c=b.importedtypes.length;for(a=0;a<c;a++)if(b.importedtypes[a]==f){c=!0;break b}c=
void 0}if(c){d="variable-3";break a}break a}}return d},indent:function(a,b){if(a.tokenize!=A)return 0;var d=b&&b.charAt(0);a=a.lexical;"stat"==a.type&&"}"==d&&(a=a.prev);var c=a.type,e=d==c;return"vardef"==c?a.indented+4:"form"==c&&"{"==d?a.indented:"stat"==c||"form"==c?a.indented+y:"switch"!=a.info||e?a.align?a.column+(e?0:1):a.indented+(e?0:y):a.indented+(/^(?:case|default)\b/.test(b)?y:2*y)},electricChars:"{}",blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//"}});p.defineMIME("text/x-haxe",
"haxe");p.defineMode("hxml",function(){return{startState:function(){return{define:!1,inString:!1}},token:function(f,q){var c=f.peek(),p=f.sol();if("#"==c)return f.skipToEnd(),"comment";if(p&&"-"==c)return c="variable-2",f.eat(/-/),"-"==f.peek()&&(f.eat(/-/),c="keyword a"),"D"==f.peek()&&(f.eat(/[D]/),c="keyword c",q.define=!0),f.eatWhile(/[A-Z]/i),c;c=f.peek();0==q.inString&&"'"==c&&(q.inString=!0,f.next());if(1==q.inString)return f.skipTo("'")||f.skipToEnd(),"'"==f.peek()&&(f.next(),q.inString=!1),
"string";f.next();return null},lineComment:"#"}});p.defineMIME("text/x-hxml","hxml")});
