var SqlParser=Editor.Parser=function(){function k(a){for(var b in a)a.hasOwnProperty(b)&&(g[b]=a[b])}function j(a){function g(){c=c.prev}function f(a,b,f){c={prev:c,indent:d,col:e,type:a,width:b,align:f}}var b=h(a),c=null,d=0,e=0,j={next:function(){var a=b.next(),h=a.style,j=a.content,k=a.value.length;j=="\n"?(a.indentation=i(c),d=e=0,c&&c.align==null&&(c.align=!1)):h=="whitespace"&&e==0?d=k:!c&&h!="sql-comment"&&f(";",0,!1),j!="\n"&&(e+=k),h=="sql-punctuation"?j=="("?f(")",k):j==")"&&g():h=="sql-separator"&&j==";"&&c&&!c.prev&&g();return a},copy:function(){var a=c,f=d,g=e,i=b.state;return function(k){b=h(k,i),c=a,d=f,e=g;return j}}};return j}function i(a){return function(b){var c=b&&b.charAt(0),d=a&&c==a.type;return a?a.align?a.col-(d?a.width:0):a.indent+(d?0:indentUnit):0}}function a(a){return new RegExp("^(?:"+a.join("|")+")$","i")}var b=a(["abs","acos","adddate","aes_encrypt","aes_decrypt","ascii","asin","atan","atan2","avg","benchmark","bin","bit_and","bit_count","bit_length","bit_or","cast","ceil","ceiling","char_length","character_length","coalesce","concat","concat_ws","connection_id","conv","convert","cos","cot","count","curdate","current_date","current_time","current_timestamp","current_user","curtime","database","date_add","date_format","date_sub","dayname","dayofmonth","dayofweek","dayofyear","decode","degrees","des_encrypt","des_decrypt","elt","encode","encrypt","exp","export_set","extract","field","find_in_set","floor","format","found_rows","from_days","from_unixtime","get_lock","greatest","group_unique_users","hex","ifnull","inet_aton","inet_ntoa","instr","interval","is_free_lock","isnull","last_insert_id","lcase","least","left","length","ln","load_file","locate","log","log2","log10","lower","lpad","ltrim","make_set","master_pos_wait","max","md5","mid","min","mod","monthname","now","nullif","oct","octet_length","ord","password","period_add","period_diff","pi","position","pow","power","quarter","quote","radians","rand","release_lock","repeat","reverse","right","round","rpad","rtrim","sec_to_time","session_user","sha","sha1","sign","sin","soundex","space","sqrt","std","stddev","strcmp","subdate","substring","substring_index","sum","sysdate","system_user","tan","time_format","time_to_sec","to_days","trim","ucase","unique_users","unix_timestamp","upper","user","version","week","weekday","yearweek"]),c=a(["alter","grant","revoke","primary","key","table","start","top","transaction","select","update","insert","delete","create","describe","from","into","values","where","join","inner","left","natural","and","or","in","not","xor","like","using","on","order","group","by","asc","desc","limit","offset","union","all","as","distinct","set","commit","rollback","replace","view","database","separator","if","exists","null","truncate","status","show","lock","unique","having","drop","procedure","begin","end","delimiter","call","else","leave","declare","temporary","then"]),d=a(["bigint","binary","bit","blob","bool","char","character","date","datetime","dec","decimal","double","enum","float","float4","float8","int","int1","int2","int3","int4","int8","integer","long","longblob","longtext","mediumblob","mediumint","mediumtext","middleint","nchar","numeric","real","set","smallint","text","time","timestamp","tinyblob","tinyint","tinytext","varbinary","varchar","year"]),e=a([":=","<","<=","==","<>",">",">=","like","rlike","in","xor","between"]),f=/[*+\-<>=&|:\/]/,g={},h=function(){function j(b,c){return function(d,e){while(!d.endOfLine()){if(d.lookAhead(c,!0)){e(a);break}d.next()}return b}}function i(b){return function(c,d){var e=!1;while(!c.endOfLine()){var f=c.next();if(f==b&&!e){d(a);break}e=g.extension=="T-SQL"?!e&&b==f&&c.equals(b):!e&&f=="\\"}return b=="`"?"sql-quoted-word":"sql-literal"}}function h(b){return function(b,c){while(!b.endOfLine()){var d=b.next();if(d=="]"){c(a);break}}return"sql-word"}}function a(a,g){var k=a.next();if(k=="@"||k=="$"){a.nextWhileMatches(/[\w\d]/);return"sql-var"}if(k=="["){g(h(k));return null}if(k=='"'||k=="'"||k=="`"){g(i(k));return null}if(k==","||k==";")return"sql-separator";if(k=="#"){while(!a.endOfLine())a.next();return"sql-comment"}if(k=="-"){if(a.peek()=="-"){while(!a.endOfLine())a.next();return"sql-comment"}if(/\d/.test(a.peek())){a.nextWhileMatches(/\d/),a.peek()=="."&&(a.next(),a.nextWhileMatches(/\d/));return"sql-number"}return"sql-operator"}if(f.test(k)){if(k=="/"&&a.peek()=="*"){g(j("sql-comment","*/"));return null}a.nextWhileMatches(f);return"sql-operator"}if(/\d/.test(k)){a.nextWhileMatches(/\d/),a.peek()=="."&&(a.next(),a.nextWhileMatches(/\d/));return"sql-number"}if(/[()]/.test(k))return"sql-punctuation";a.nextWhileMatches(/[_\w\d]/);var l=a.get(),m;e.test(l)?m="sql-operator":c.test(l)?m="sql-keyword":b.test(l)?m="sql-function":d.test(l)?m="sql-type":m="sql-word";return{style:m,content:l}}return function(b,c){return tokenizer(b,c||a)}}();return{make:j,electricChars:")",configure:k}}()