|
|
function s(a){var c=a.client||{},g=a.atoms||{false:!0,true:!0,null:!0},p=a.builtin||e(z),C=a.keywords||e(d),_=a.operatorChars||/^[*+\-%<>!=&|~^\/]/,o=a.support||{},y=a.hooks||{},S=a.dateSQL||{date:!0,time:!0,timestamp:!0},Q=a.backslashStringEscapes!==!1,N=a.brackets||/^[\{}\(\)\[\]]/,v=a.punctuation||/^[;.,:]/;function h(t,n){var r=t.next();if(y[r]){var i=y[r](t,n);if(i!==!1)return i}if(o.hexNumber&&(r=="0"&&t.match(/^[xX][0-9a-fA-F]+/)||(r=="x"||r=="X")&&t.match(/^'[0-9a-fA-F]*'/))||o.binaryNumber&&((r=="b"||r=="B")&&t.match(/^'[01]+'/)||r=="0"&&t.match(/^b[01]*/)))return"number";if(r.charCodeAt(0)>47&&r.charCodeAt(0)<58)return t.match(/^[0-9]*(\.[0-9]+)?([eE][-+]?[0-9]+)?/),o.decimallessFloat&&t.match(/^\.(?!\.)/),"number";if(r=="?"&&(t.eatSpace()||t.eol()||t.eat(";")))return"macroName";if(r=="'"||r=='"'&&o.doubleQuote)return n.tokenize=x(r),n.tokenize(t,n);if((o.nCharCast&&(r=="n"||r=="N")||o.charsetCast&&r=="_"&&t.match(/[a-z][a-z0-9]*/i))&&(t.peek()=="'"||t.peek()=='"'))return"keyword";if(o.escapeConstant&&(r=="e"||r=="E")&&(t.peek()=="'"||t.peek()=='"'&&o.doubleQuote))return n.tokenize=function(m,k){return(k.tokenize=x(m.next(),!0))(m,k)},"keyword";if(o.commentSlashSlash&&r=="/"&&t.eat("/")||o.commentHash&&r=="#"||r=="-"&&t.eat("-")&&(!o.commentSpaceRequired||t.eat(" ")))return t.skipToEnd(),"comment";if(r=="/"&&t.eat("*"))return n.tokenize=b(1),n.tokenize(t,n);if(r=="."){if(o.zerolessFloat&&t.match(/^(?:\d+(?:e[+-]?\d+)?)/i))return"number";if(t.match(/^\.+/))return null;if(o.ODBCdotTable&&t.match(/^[\w\d_$#]+/))return"type"}else{if(_.test(r))return t.eatWhile(_),"operator";if(N.test(r))return"bracket";if(v.test(r))return t.eatWhile(v),"punctuation";if(r=="{"&&(t.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/)||t.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/)))return"number";t.eatWhile(/^[_\w\d]/);var l=t.current().toLowerCase();return S.hasOwnProperty(l)&&(t.match(/^( )+'[^']*'/)||t.match(/^( )+"[^"]*"/))?"number":g.hasOwnProperty(l)?"atom":p.hasOwnProperty(l)?"type":C.hasOwnProperty(l)?"keyword":c.hasOwnProperty(l)?"builtin":null}}function x(t,n){return function(r,i){for(var l=!1,m;(m=r.next())!=null;){if(m==t&&!l){i.tokenize=h;break}l=(Q||n)&&!l&&m=="\\"}return"string"}}function b(t){return function(n,r){var i=n.match(/^.*?(\/\*|\*\/)/);return i?i[1]=="/*"?r.tokenize=b(t+1):t>1?r.tokenize=b(t-1):r.tokenize=h:n.skipToEnd(),"comment"}}function w(t,n,r){n.context={prev:n.context,indent:t.indentation(),col:t.column(),type:r}}function j(t){t.indent=t.context.indent,t.context=t.context.prev}return{name:"sql",startState:function(){return{tokenize:h,context:null}},token:function(t,n){if(t.sol()&&n.context&&n.context.align==null&&(n.context.align=!1),n.tokenize==h&&t.eatSpace())return null;var r=n.tokenize(t,n);if(r=="comment")return r;n.context&&n.context.align==null&&(n.context.align=!0);var i=t.current();return i=="("?w(t,n,")"):i=="["?w(t,n,"]"):n.context&&n.context.type==i&&j(n),r},indent:function(t,n,r){var i=t.context;if(!i)return null;var l=n.charAt(0)==i.type;return i.align?i.col+(l?0:1):i.indent+(l?0:r.unit)},languageData:{commentTokens:{line:o.commentSlashSlash?"//":o.commentHash?"#":"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}}}function f(a){for(var c;(c=a.next())!=null;)if(c=="`"&&!a.eat("`"))return"string.special";return a.backUp(a.current().length-1),a.eatWhile(/\w/)?"string.special":null}function L(a){for(var c;(c=a.next())!=null;)if(c=='"'&&!a.eat('"'))return"string.special";return a.backUp(a.current().length-1),a.eatWhile(/\w/)?"string.special":null}function u(a){return a.eat("@")&&(a.match("session."),a.match("local."),a.match("global.")),a.eat("'")?(a.match(/^.*'/),"string.special"):a.eat('"')?(a.match(/^.*"/),"string.special"):a.eat("`")?(a.match(/^.*`/),"string.special"):a.match(/^[0-9a-zA-Z$\.\_]+/)?"string.special":null}function q(a){return a.eat("N")?"atom":a.match(/^[a-zA-Z.#!?]/)?"string.special":null}var d="alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table uni
|