'use strict';(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){e.defineMode("q",function(e){function g(a,b){var d=a.sol(),c=a.next();f=null;if(d){if("/"==c)return(b.tokenize=l)(a,b);if("\\"==c)return a.eol()||/\s/.test(a.peek())?(a.skipToEnd(),/^\\\s*$/.test(a.current())?(b.tokenize=m)(a):b.tokenize=g,"comment"):(b.tokenize=g,"builtin")}if(/\s/.test(c))return"/"==
a.peek()?(a.skipToEnd(),"comment"):"whitespace";if('"'==c)return(b.tokenize=n)(a,b);if("`"==c)return a.eatWhile(/[A-Za-z\d_:\/.]/),"symbol";if("."==c&&/\d/.test(a.peek())||/\d/.test(c)){b=null;a.backUp(1);if(a.match(/^\d{4}\.\d{2}(m|\.\d{2}([DT](\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)?)?)/)||a.match(/^\d+D(\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)/)||a.match(/^\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?/)||a.match(/^\d+[ptuv]{1}/))b="temporal";else if(a.match(/^0[NwW]{1}/)||a.match(/^0x[\da-fA-F]*/)||a.match(/^[01]+[b]{1}/)||
a.match(/^\d+[chijn]{1}/)||a.match(/-?\d*(\.\d*)?(e[+\-]?\d+)?(e|f)?/))b="number";return!b||(c=a.peek())&&!p.test(c)?(a.next(),"error"):b}return/[A-Za-z]|\./.test(c)?(a.eatWhile(/[A-Za-z._\d]/),q.test(a.current())?"keyword":"variable"):/[|/&^!+:\\\-*%$=~#;@><\.,?_']/.test(c)||/[{}\(\[\]\)]/.test(c)?null:"error"}function l(a,b){return a.skipToEnd(),/\/\s*$/.test(a.current())?(b.tokenize=r)(a,b):b.tokenize=g,"comment"}function r(a,b){var d=a.sol()&&"\\"==a.peek();a.skipToEnd();d&&/^\\\s*$/.test(a.current())&&
(b.tokenize=g);return"comment"}function m(a){return a.skipToEnd(),"comment"}function n(a,b){for(var d=!1,c,e=!1;c=a.next();){if('"'==c&&!d){e=!0;break}d=!d&&"\\"==c}e&&(b.tokenize=g);return"string"}function h(a,b,d){a.context={prev:a.context,indent:a.indent,col:d,type:b}}function k(a){a.indent=a.context.indent;a.context=a.context.prev}var t=e.indentUnit,f,q=/^(abs|acos|aj|aj0|all|and|any|asc|asin|asof|atan|attr|avg|avgs|bin|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|each|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|idesc|if|ij|in|insert|inter|inv|key|keys|last|like|list|lj|load|log|lower|lsq|ltime|ltrim|mavg|max|maxs|mcount|md5|mdev|med|meta|min|mins|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prd|prds|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reverse|rload|rotate|rsave|rtrim|save|scan|select|set|setenv|show|signum|sin|sqrt|ss|ssr|string|sublist|sum|sums|sv|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|view|views|vs|wavg|where|where|while|within|wj|wj1|wsum|xasc|xbar|xcol|xcols|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)$/,
p=/[|/&^!+:\\\-*%$=~#;@><,?_'"\[\(\]\)\s{}]/;return{startState:function(){return{tokenize:g,context:null,indent:0,col:0}},token:function(a,b){a.sol()&&(b.context&&null==b.context.align&&(b.context.align=!1),b.indent=a.indentation());var d=b.tokenize(a,b);"comment"!=d&&b.context&&null==b.context.align&&"pattern"!=b.context.type&&(b.context.align=!0);if("("==f)h(b,")",a.column());else if("["==f)h(b,"]",a.column());else if("{"==f)h(b,"}",a.column());else if(/[\]\}\)]/.test(f)){for(;b.context&&"pattern"==
b.context.type;)k(b);b.context&&f==b.context.type&&k(b)}else"."==f&&b.context&&"pattern"==b.context.type?k(b):/atom|string|variable/.test(d)&&b.context&&(/[\}\]]/.test(b.context.type)?h(b,"pattern",a.column()):"pattern"!=b.context.type||b.context.align||(b.context.align=!0,b.context.col=a.column()));return d},indent:function(a,b){b=b&&b.charAt(0);a=a.context;if(/[\]\}]/.test(b))for(;a&&"pattern"==a.type;)a=a.prev;b=a&&b==a.type;return a?"pattern"==a.type?a.col:a.align?a.col+(b?0:1):a.indent+(b?0:
t):0}}});e.defineMIME("text/x-q","q")});
