Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sql-parser.min.js 31KB

1234567
  1. /*!
  2. * SQLParser 1.2.3
  3. * Copyright 2012-2015 Andy Kent <andy@forward.co.uk>
  4. * Copyright 2015-2018 Damien "Mistic" Sorel (https://www.strangeplanet.fr)
  5. * Licensed under MIT (http://opensource.org/licenses/MIT)
  6. */
  7. !function(t){var e=function(){function t(e){return t[e]}return t["./lexer"]=new function(){var t=this;(function(){var e;e=function(){function t(t,e){var n,i;for(null==e&&(e={}),this.sql=t,this.preserveWhitespace=e.preserveWhitespace||!1,this.tokens=[],this.currentLine=1,this.currentOffset=0,i=0;this.chunk=t.slice(i);){if((n=this.keywordToken()||this.starToken()||this.booleanToken()||this.functionToken()||this.windowExtension()||this.sortOrderToken()||this.seperatorToken()||this.operatorToken()||this.numberToken()||this.mathToken()||this.dotToken()||this.conditionalToken()||this.betweenToken()||this.subSelectOpToken()||this.subSelectUnaryOpToken()||this.stringToken()||this.parameterToken()||this.parensToken()||this.whitespaceToken()||this.literalToken())<1)throw new Error("NOTHING CONSUMED: Stopped at - '"+this.chunk.slice(0,30)+"'");i+=n,this.currentOffset+=n}this.token("EOF",""),this.postProcess()}var e,n,i,r,o,s,u,a,h,c,l,p,f,k,E,T,S,g;return t.prototype.postProcess=function(){var t,e,n,i,r,o,s;for(o=this.tokens,s=[],t=i=0,r=o.length;i<r;t=++i)n=o[t],"STAR"===n[0]?(e=this.tokens[t+1],"SEPARATOR"!==e[0]&&"FROM"!==e[0]?s.push(n[0]="MATH_MULTI"):s.push(void 0)):s.push(void 0);return s},t.prototype.token=function(t,e){return this.tokens.push([t,e,this.currentLine,this.currentOffset])},t.prototype.tokenizeFromStringRegex=function(t,e,n,i,r){var o,s;return null==n&&(n=0),null==i&&(i=n),null==r&&(r=!0),(o=e.exec(this.chunk))?(s=o[n].replace(/''/g,"'"),r&&this.token(t,s),o[i].length):0},t.prototype.tokenizeFromRegex=function(t,e,n,i,r){var o,s;return null==n&&(n=0),null==i&&(i=n),null==r&&(r=!0),(o=e.exec(this.chunk))?(s=o[n],r&&this.token(t,s),o[i].length):0},t.prototype.tokenizeFromWord=function(t,e){var n,i;return null==e&&(e=t),e=this.regexEscape(e),i=/^\w+$/.test(e)?new RegExp("^("+e+")\\b","ig"):new RegExp("^("+e+")","ig"),(n=i.exec(this.chunk))?(this.token(t,n[1]),n[1].length):0},t.prototype.tokenizeFromList=function(t,e){var n,i,r,o;for(i=0,r=0,o=e.length;r<o&&(n=e[r],!((i=this.tokenizeFromWord(t,n))>0));r++);return i},t.prototype.keywordToken=function(){return this.tokenizeFromWord("SELECT")||this.tokenizeFromWord("INSERT")||this.tokenizeFromWord("INTO")||this.tokenizeFromWord("DEFAULT")||this.tokenizeFromWord("VALUES")||this.tokenizeFromWord("DISTINCT")||this.tokenizeFromWord("FROM")||this.tokenizeFromWord("WHERE")||this.tokenizeFromWord("GROUP")||this.tokenizeFromWord("ORDER")||this.tokenizeFromWord("BY")||this.tokenizeFromWord("HAVING")||this.tokenizeFromWord("LIMIT")||this.tokenizeFromWord("JOIN")||this.tokenizeFromWord("LEFT")||this.tokenizeFromWord("RIGHT")||this.tokenizeFromWord("INNER")||this.tokenizeFromWord("OUTER")||this.tokenizeFromWord("ON")||this.tokenizeFromWord("AS")||this.tokenizeFromWord("CASE")||this.tokenizeFromWord("WHEN")||this.tokenizeFromWord("THEN")||this.tokenizeFromWord("ELSE")||this.tokenizeFromWord("END")||this.tokenizeFromWord("UNION")||this.tokenizeFromWord("ALL")||this.tokenizeFromWord("LIMIT")||this.tokenizeFromWord("OFFSET")||this.tokenizeFromWord("FETCH")||this.tokenizeFromWord("ROW")||this.tokenizeFromWord("ROWS")||this.tokenizeFromWord("ONLY")||this.tokenizeFromWord("NEXT")||this.tokenizeFromWord("FIRST")},t.prototype.dotToken=function(){return this.tokenizeFromWord("DOT",".")},t.prototype.operatorToken=function(){return this.tokenizeFromList("OPERATOR",p)},t.prototype.mathToken=function(){return this.tokenizeFromList("MATH",r)||this.tokenizeFromList("MATH_MULTI",o)},t.prototype.conditionalToken=function(){return this.tokenizeFromList("CONDITIONAL",c)},t.prototype.betweenToken=function(){return this.tokenizeFromList("BETWEEN",h)},t.prototype.subSelectOpToken=function(){return this.tokenizeFromList("SUB_SELECT_OP",T)},t.prototype.subSelectUnaryOpToken=function(){return this.tokenizeFromList("SUB_SELECT_UNARY_OP",S)},t.prototype.functionToken=function(){return this.tokenizeFromList("FUNCTION",l)},t.prototype.sortOrderToken=function(){return this.tokenizeFromList("DIRECTION",f)},t.prototype.booleanToken=function(){return this.tokenizeFromList("BOOLEAN",e)},t.prototype.starToken=function(){return this.tokenizeFromRegex("STAR",k)},t.prototype.seperatorToken=function(){return this.tokenizeFromRegex("SEPARATOR",a)},t.prototype.literalToken=function(){return this.tokenizeFromRegex("LITERAL",i,1,0)},t.prototype.numberToken=function(){return this.tokenizeFromRegex("NUMBER",s)},t.prototype.parameterToken=function(){return this.tokenizeFromRegex("PARAMETER",u,1,0)},t.prototype.stringToken=function(){return this.tokenizeFromStringRegex("STRING",E,1,0)||this.tokenizeFromRegex("DBLSTRING",n,1,0)},t.prototype.parensToken=function(){return this.tokenizeFromRegex("LEFT_PAREN",/^\(/)||this.tokenizeFromRegex("RIGHT_PAREN",/^\)/)},t.prototype.windowExtension=function(){var t;return(t=/^\.(win):(length|time)/i.exec(this.chunk))?(this.token("WINDOW",t[1]),this.token("WINDOW_FUNCTION",t[2]),t[0].length):0},t.prototype.whitespaceToken=function(){var t,e,n;return(t=g.exec(this.chunk))?(n=t[0],this.preserveWhitespace&&this.token("WHITESPACE",n),e=n.match(/\n/g,""),this.currentLine+=(null!=e?e.length:void 0)||0,n.length):0},t.prototype.regexEscape=function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},l=["AVG","COUNT","MIN","MAX","SUM"],f=["ASC","DESC"],p=["=","!=",">=",">","<=","<>","<","LIKE","NOT LIKE","ILIKE","NOT ILIKE","IS NOT","IS","REGEXP","NOT REGEXP"],T=["IN","NOT IN","ANY","ALL","SOME"],S=["EXISTS"],c=["AND","OR"],h=["BETWEEN","NOT BETWEEN"],e=["TRUE","FALSE","NULL"],r=["+","-","||","&&"],o=["/","*"],k=/^\*/,a=/^,/,g=/^[ \n\r]+/,i=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i,u=/^\$([a-z0-9_]+(\:(number|float|string|date|boolean))?)/,s=/^[+-]?[0-9]+(\.[0-9]+)?/,E=/^'((?:[^\\']+?|\\.|'')*)'(?!')/,n=/^"([^\\"]*(?:\\.[^\\"]*)*)"/,t}(),t.tokenize=function(t,n){return new e(t,n).tokens}}).call(this)},t["./compiled_parser"]=new function(){var e=this,n=function(){function t(){this.yy={}}var e=function(t,e,n,i){for(n=n||{},i=t.length;i--;n[t[i]]=e);return n},n=[1,8],i=[5,26],r=[1,14],o=[1,13],s=[5,26,31,42],u=[1,17],a=[5,26,31,42,45,62],h=[1,27],c=[1,29],l=[1,40],p=[1,42],f=[1,46],k=[1,47],E=[1,43],T=[1,44],S=[1,41],g=[1,45],m=[1,25],d=[5,26,31],O=[5,26,31,42,45],y=[1,59],N=[18,43],R=[1,62],F=[1,63],b=[1,64],w=[1,65],L=[1,66],I=[5,18,23,26,31,34,37,38,41,42,43,45,62,64,65,66,67,68,70,78,81,82,83],A=[5,18,23,26,31,34,37,38,41,42,43,44,45,51,62,64,65,66,67,68,70,71,78,81,82,83,89,90,91,92,93,94,96],v=[1,74],W=[1,77],$=[2,93],C=[1,91],z=[1,92],U=[5,18,23,26,31,34,37,38,41,42,43,45,62,64,65,66,67,68,70,78,81,82,83,89,90,91,92,93,94,96],_=[78,81,83],P=[1,116],x=[5,26,31,42,43,44],H=[1,124],D=[5,26,31,42,43,45,64],B=[5,26,31,41,42,45,62],M=[1,127],G=[1,128],V=[1,129],j=[5,26,31,34,35,37,38,41,42,45,62],J=[5,18,23,26,31,34,37,38,41,42,43,45,62,64,70,78,81,82,83],Y=[5,26,31,34,37,38,41,42,45,62],q=[5,26,31,42,56,58],X={trace:function(){},yy:{},symbols_:{error:2,Root:3,Query:4,EOF:5,SelectQuery:6,Unions:7,SelectWithLimitQuery:8,BasicSelectQuery:9,Select:10,OrderClause:11,GroupClause:12,LimitClause:13,SelectClause:14,WhereClause:15,SELECT:16,Fields:17,FROM:18,Table:19,DISTINCT:20,Joins:21,Literal:22,AS:23,LEFT_PAREN:24,List:25,RIGHT_PAREN:26,WINDOW:27,WINDOW_FUNCTION:28,Number:29,Union:30,UNION:31,ALL:32,Join:33,JOIN:34,ON:35,Expression:36,LEFT:37,RIGHT:38,INNER:39,OUTER:40,WHERE:41,LIMIT:42,SEPARATOR:43,OFFSET:44,ORDER:45,BY:46,OrderArgs:47,OffsetClause:48,OrderArg:49,Value:50,DIRECTION:51,OffsetRows:52,FetchClause:53,ROW:54,ROWS:55,FETCH:56,FIRST:57,ONLY:58,NEXT:59,GroupBasicClause:60,HavingClause:61,GROUP:62,ArgumentList:63,HAVING:64,MATH:65,MATH_MULTI:66,OPERATOR:67,BETWEEN:68,BetweenExpression:69,CONDITIONAL:70,SUB_SELECT_OP:71,SubSelectExpression:72,SUB_SELECT_UNARY_OP:73,WhitepaceList:74,CaseStatement:75,CASE:76,CaseWhens:77,END:78,CaseElse:79,CaseWhen:80,WHEN:81,THEN:82,ELSE:83,String:84,Function:85,UserFunction:86,Boolean:87,Parameter:88,NUMBER:89,BOOLEAN:90,PARAMETER:91,STRING:92,DBLSTRING:93,LITERAL:94,DOT:95,FUNCTION:96,AggregateArgumentList:97,Case:98,Field:99,STAR:100,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",16:"SELECT",18:"FROM",20:"DISTINCT",23:"AS",24:"LEFT_PAREN",26:"RIGHT_PAREN",27:"WINDOW",28:"WINDOW_FUNCTION",31:"UNION",32:"ALL",34:"JOIN",35:"ON",37:"LEFT",38:"RIGHT",39:"INNER",40:"OUTER",41:"WHERE",42:"LIMIT",43:"SEPARATOR",44:"OFFSET",45:"ORDER",46:"BY",51:"DIRECTION",54:"ROW",55:"ROWS",56:"FETCH",57:"FIRST",58:"ONLY",59:"NEXT",62:"GROUP",64:"HAVING",65:"MATH",66:"MATH_MULTI",67:"OPERATOR",68:"BETWEEN",70:"CONDITIONAL",71:"SUB_SELECT_OP",73:"SUB_SELECT_UNARY_OP",76:"CASE",78:"END",81:"WHEN",82:"THEN",83:"ELSE",89:"NUMBER",90:"BOOLEAN",91:"PARAMETER",92:"STRING",93:"DBLSTRING",94:"LITERAL",95:"DOT",96:"FUNCTION",98:"Case",100:"STAR"},productions_:[0,[3,2],[4,1],[4,2],[6,1],[6,1],[9,1],[9,2],[9,2],[9,3],[8,2],[10,1],[10,2],[14,4],[14,5],[14,5],[14,6],[19,1],[19,2],[19,3],[19,3],[19,3],[19,4],[19,6],[7,1],[7,2],[30,2],[30,3],[21,1],[21,2],[33,4],[33,5],[33,5],[33,6],[33,6],[33,6],[33,6],[15,2],[13,2],[13,4],[13,4],[11,3],[11,4],[47,1],[47,3],[49,1],[49,2],[48,2],[48,3],[52,2],[52,2],[53,4],[53,4],[12,1],[12,2],[60,3],[61,2],[36,3],[36,3],[36,3],[36,3],[36,3],[36,3],[36,5],[36,3],[36,2],[36,1],[36,1],[36,1],[36,1],[69,3],[75,3],[75,4],[80,4],[77,2],[77,1],[79,2],[72,3],[50,1],[50,1],[50,1],[50,1],[50,1],[50,1],[50,1],[74,2],[74,2],[25,1],[29,1],[87,1],[88,1],[84,1],[84,1],[22,1],[22,3],[85,4],[86,3],[86,4],[86,4],[97,1],[97,2],[63,1],[63,3],[17,1],[17,3],[99,1],[99,1],[99,3]],performAction:function(t,e,n,i,r,o,s){var u=o.length-1;switch(r){case 1:return this.$=o[u-1];case 2:case 4:case 5:case 6:case 11:case 53:case 66:case 68:case 69:case 78:case 79:case 80:case 81:case 82:case 83:case 84:this.$=o[u];break;case 3:this.$=function(){return o[u-1].unions=o[u],o[u-1]}();break;case 7:this.$=function(){return o[u-1].order=o[u],o[u-1]}();break;case 8:this.$=function(){return o[u-1].group=o[u],o[u-1]}();break;case 9:this.$=function(){return o[u-2].group=o[u-1],o[u-2].order=o[u],o[u-2]}();break;case 10:this.$=function(){return o[u-1].limit=o[u],o[u-1]}();break;case 12:this.$=function(){return o[u-1].where=o[u],o[u-1]}();break;case 13:this.$=new i.Select(o[u-2],o[u],!1);break;case 14:this.$=new i.Select(o[u-2],o[u],!0);break;case 15:this.$=new i.Select(o[u-3],o[u-1],!1,o[u]);break;case 16:this.$=new i.Select(o[u-3],o[u-1],!0,o[u]);break;case 17:this.$=new i.Table(o[u]);break;case 18:this.$=new i.Table(o[u-1],o[u]);break;case 19:this.$=new i.Table(o[u-2],o[u]);break;case 20:case 49:case 50:case 51:case 52:case 57:this.$=o[u-1];break;case 21:case 77:this.$=new i.SubSelect(o[u-1]);break;case 22:this.$=new i.SubSelect(o[u-2],o[u]);break;case 23:this.$=new i.Table(o[u-5],null,o[u-4],o[u-3],o[u-1]);break;case 24:case 28:case 43:case 75:case 101:case 103:this.$=[o[u]];break;case 25:case 29:case 74:this.$=o[u-1].concat(o[u]);break;case 26:this.$=new i.Union(o[u]);break;case 27:this.$=new i.Union(o[u],!0);break;case 30:this.$=new i.Join(o[u-2],o[u]);break;case 31:this.$=new i.Join(o[u-2],o[u],"LEFT");break;case 32:this.$=new i.Join(o[u-2],o[u],"RIGHT");break;case 33:this.$=new i.Join(o[u-2],o[u],"LEFT","INNER");break;case 34:this.$=new i.Join(o[u-2],o[u],"RIGHT","INNER");break;case 35:this.$=new i.Join(o[u-2],o[u],"LEFT","OUTER");break;case 36:this.$=new i.Join(o[u-2],o[u],"RIGHT","OUTER");break;case 37:this.$=new i.Where(o[u]);break;case 38:this.$=new i.Limit(o[u]);break;case 39:this.$=new i.Limit(o[u],o[u-2]);break;case 40:this.$=new i.Limit(o[u-2],o[u]);break;case 41:this.$=new i.Order(o[u]);break;case 42:this.$=new i.Order(o[u-1],o[u]);break;case 44:case 102:case 104:this.$=o[u-2].concat(o[u]);break;case 45:this.$=new i.OrderArgument(o[u],"ASC");break;case 46:this.$=new i.OrderArgument(o[u-1],o[u]);break;case 47:this.$=new i.Offset(o[u]);break;case 48:this.$=new i.Offset(o[u-1],o[u]);break;case 54:this.$=function(){return o[u-1].having=o[u],o[u-1]}();break;case 55:this.$=new i.Group(o[u]);break;case 56:this.$=new i.Having(o[u]);break;case 58:case 59:case 60:case 61:case 62:case 64:this.$=new i.Op(o[u-1],o[u-2],o[u]);break;case 63:this.$=new i.Op(o[u-3],o[u-4],o[u-1]);break;case 65:this.$=new i.UnaryOp(o[u-1],o[u]);break;case 67:this.$=new i.WhitepaceList(o[u]);break;case 70:this.$=new i.BetweenOp([o[u-2],o[u]]);break;case 71:this.$=new i.Case(o[u-1]);break;case 72:this.$=new i.Case(o[u-2],o[u-1]);break;case 73:this.$=new i.CaseWhen(o[u-2],o[u]);break;case 76:this.$=new i.CaseElse(o[u]);break;case 85:this.$=[o[u-1],o[u]];break;case 86:this.$=function(){return o[u-1].push(o[u]),o[u-1]}();break;case 87:this.$=new i.ListValue(o[u]);break;case 88:this.$=new i.NumberValue(o[u]);break;case 89:this.$=new i.BooleanValue(o[u]);break;case 90:this.$=new i.ParameterValue(o[u]);break;case 91:this.$=new i.StringValue(o[u],"'");break;case 92:this.$=new i.StringValue(o[u],'"');break;case 93:this.$=new i.LiteralValue(o[u]);break;case 94:this.$=new i.LiteralValue(o[u-2],o[u]);break;case 95:this.$=new i.FunctionValue(o[u-3],o[u-1]);break;case 96:this.$=new i.FunctionValue(o[u-2],null,!0);break;case 97:case 98:this.$=new i.FunctionValue(o[u-3],o[u-1],!0);break;case 99:this.$=new i.ArgumentListValue(o[u]);break;case 100:this.$=new i.ArgumentListValue(o[u],!0);break;case 105:this.$=new i.Star;break;case 106:this.$=new i.Field(o[u]);break;case 107:this.$=new i.Field(o[u-2],o[u])}},table:[{3:1,4:2,6:3,8:4,9:5,10:6,14:7,16:n},{1:[3]},{5:[1,9]},e(i,[2,2],{7:10,13:11,30:12,31:r,42:o}),e(s,[2,4]),e(s,[2,5]),e(s,[2,6],{11:15,12:16,60:18,45:u,62:[1,19]}),e(a,[2,11],{15:20,41:[1,21]}),{17:22,20:[1,23],22:33,24:h,29:34,36:26,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g,99:24,100:m},{1:[2,1]},e(i,[2,3],{30:48,31:r}),e(s,[2,10]),e(d,[2,24]),{29:49,89:p},{6:50,8:4,9:5,10:6,14:7,16:n,32:[1,51]},e(s,[2,7]),e(s,[2,8],{11:52,45:u}),{46:[1,53]},e(O,[2,53],{61:54,64:[1,55]}),{46:[1,56]},e(a,[2,12]),{22:33,24:h,29:34,36:57,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{18:[1,58],43:y},{17:60,22:33,24:h,29:34,36:26,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g,99:24,100:m},e(N,[2,103]),e(N,[2,105]),e(N,[2,106],{23:[1,61],65:R,66:F,67:b,68:w,70:L}),{4:68,6:3,8:4,9:5,10:6,14:7,16:n,22:33,24:h,29:34,36:67,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(I,[2,69],{22:33,29:34,84:35,85:36,86:37,87:38,88:39,50:70,71:[1,69],89:p,90:f,91:k,92:E,93:T,94:S,96:g}),{24:[1,72],72:71},e(I,[2,66]),e(I,[2,67],{22:33,29:34,84:35,85:36,86:37,87:38,88:39,50:73,89:p,90:f,91:k,92:E,93:T,94:S,96:g}),e(I,[2,68]),e(A,[2,78],{95:v}),e(A,[2,79]),e(A,[2,80]),e(A,[2,81]),e(A,[2,82]),e(A,[2,83]),e(A,[2,84]),{77:75,80:76,81:W},e([5,18,23,26,31,34,37,38,41,42,43,44,45,51,62,64,65,66,67,68,70,71,78,81,82,83,89,90,91,92,93,94,95,96],$,{24:[1,78]}),e([5,18,23,26,31,34,37,38,41,42,43,44,45,51,54,55,62,64,65,66,67,68,70,71,78,81,82,83,89,90,91,92,93,94,96],[2,88]),e(A,[2,91]),e(A,[2,92]),{24:[1,79]},e(A,[2,89]),e(A,[2,90]),e(d,[2,25]),e(s,[2,38],{43:[1,80],44:[1,81]}),e(d,[2,26],{13:11,42:o}),{6:82,8:4,9:5,10:6,14:7,16:n},e(s,[2,9]),{22:33,29:34,47:83,49:84,50:85,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(O,[2,54]),{22:33,24:h,29:34,36:86,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:88,50:28,63:87,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(a,[2,37],{65:R,66:F,67:b,68:w,70:L}),{19:89,22:90,24:C,94:z},{22:33,24:h,29:34,36:26,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g,99:93,100:m},{18:[1,94],43:y},{22:95,94:z},{22:33,24:h,29:34,36:96,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:97,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:98,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:100,50:28,69:99,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:101,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{26:[1,102],65:R,66:F,67:b,68:w,70:L},{26:[1,103]},{24:[1,104],72:105},e(U,[2,85]),e(I,[2,65]),{4:68,6:3,8:4,9:5,10:6,14:7,16:n},e(U,[2,86]),{94:[1,106]},{78:[1,107],79:108,80:109,81:W,83:[1,110]},e(_,[2,75]),{22:33,24:h,29:34,36:111,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{20:P,22:33,24:h,26:[1,112],29:34,36:88,50:28,63:115,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g,97:113,98:[1,114]},{20:P,22:33,24:h,29:34,36:88,50:28,63:115,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g,97:117},{29:118,89:p},{29:119,89:p},e(d,[2,27],{13:11,42:o}),e(s,[2,41],{48:120,43:[1,121],44:[1,122]}),e(x,[2,43]),e(x,[2,45],{51:[1,123]}),e(O,[2,56],{65:R,66:F,67:b,68:w,70:L}),e([5,26,31,42,45,64],[2,55],{43:H}),e(D,[2,101],{65:R,66:F,67:b,68:w,70:L}),e(B,[2,13],{21:125,33:126,34:M,37:G,38:V}),e(j,[2,17],{22:130,23:[1,131],27:[1,132],94:z,95:v}),{4:134,6:3,8:4,9:5,10:6,14:7,16:n,22:33,24:h,25:133,29:34,36:88,50:28,63:135,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e([5,18,23,26,27,31,34,35,37,38,41,42,43,45,62,94,95],$),e(N,[2,104]),{19:136,22:90,24:C,94:z},e(N,[2,107],{95:v}),e([5,18,23,26,31,34,37,38,41,42,43,45,62,64,65,67,70,78,81,82,83],[2,58],{66:F,68:w}),e([5,18,23,26,31,34,37,38,41,42,43,45,62,64,65,66,67,70,78,81,82,83],[2,59],{68:w}),e([5,18,23,26,31,34,37,38,41,42,43,45,62,64,67,70,78,81,82,83],[2,60],{65:R,66:F,68:w}),e(I,[2,61]),{65:R,66:F,67:b,68:w,70:[1,137]},e(J,[2,62],{65:R,66:F,67:b,68:w}),e(I,[2,57]),e(I,[2,77]),{4:68,6:3,8:4,9:5,10:6,14:7,16:n,22:33,24:h,25:138,29:34,36:88,50:28,63:135,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(I,[2,64]),e([5,18,23,26,27,31,34,35,37,38,41,42,43,44,45,51,62,64,65,66,67,68,70,71,78,81,82,83,89,90,91,92,93,94,95,96],[2,94]),e(I,[2,71]),{78:[1,139]},e(_,[2,74]),{22:33,24:h,29:34,36:140,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{65:R,66:F,67:b,68:w,70:L,82:[1,141]},e(A,[2,96]),{26:[1,142]},{26:[1,143]},{26:[2,99],43:H},{22:33,24:h,29:34,36:88,50:28,63:144,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{26:[1,145]},e(s,[2,39]),e(s,[2,40]),e(s,[2,42]),{22:33,29:34,49:146,50:85,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{29:148,52:147,89:p},e(x,[2,46]),{22:33,24:h,29:34,36:149,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(B,[2,15],{33:150,34:M,37:G,38:V}),e(Y,[2,28]),{19:151,22:90,24:C,94:z},{34:[1,152],39:[1,153],40:[1,154]},{34:[1,155],39:[1,156],40:[1,157]},e(j,[2,18],{95:v}),{22:158,94:z},{28:[1,159]},{26:[1,160]},{26:[1,161]},{26:[2,87],43:H},e(B,[2,14],{33:126,21:162,34:M,37:G,38:V}),{22:33,24:h,29:34,36:163,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{26:[1,164]},e(I,[2,72]),{65:R,66:F,67:b,68:w,70:L,78:[2,76]},{22:33,24:h,29:34,36:165,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(A,[2,97]),e(A,[2,98]),{26:[2,100],43:H},e(A,[2,95]),e(x,[2,44]),e(s,[2,47],{53:166,56:[1,167]}),{54:[1,168],55:[1,169]},e(D,[2,102],{65:R,66:F,67:b,68:w,70:L}),e(Y,[2,29]),{35:[1,170]},{19:171,22:90,24:C,94:z},{34:[1,172]},{34:[1,173]},{19:174,22:90,24:C,94:z},{34:[1,175]},{34:[1,176]},e(j,[2,19],{95:v}),{24:[1,177]},e(j,[2,20]),e(j,[2,21],{22:178,94:z}),e(B,[2,16],{33:150,34:M,37:G,38:V}),e(J,[2,70],{65:R,66:F,67:b,68:w}),e(I,[2,63]),e(_,[2,73],{65:R,66:F,67:b,68:w,70:L}),e(s,[2,48]),{57:[1,179],59:[1,180]},e(q,[2,49]),e(q,[2,50]),{22:33,24:h,29:34,36:181,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{35:[1,182]},{19:183,22:90,24:C,94:z},{19:184,22:90,24:C,94:z},{35:[1,185]},{19:186,22:90,24:C,94:z},{19:187,22:90,24:C,94:z},{29:188,89:p},e(j,[2,22],{95:v}),{29:148,52:189,89:p},{29:148,52:190,89:p},e(Y,[2,30],{65:R,66:F,67:b,68:w,70:L}),{22:33,24:h,29:34,36:191,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{35:[1,192]},{35:[1,193]},{22:33,24:h,29:34,36:194,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{35:[1,195]},{35:[1,196]},{26:[1,197]},{58:[1,198]},{58:[1,199]},e(Y,[2,31],{65:R,66:F,67:b,68:w,70:L}),{22:33,24:h,29:34,36:200,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:201,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(Y,[2,32],{65:R,66:F,67:b,68:w,70:L}),{22:33,24:h,29:34,36:202,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},{22:33,24:h,29:34,36:203,50:28,72:30,73:c,74:31,75:32,76:l,84:35,85:36,86:37,87:38,88:39,89:p,90:f,91:k,92:E,93:T,94:S,96:g},e(j,[2,23]),e(s,[2,51]),e(s,[2,52]),e(Y,[2,33],{65:R,66:F,67:b,68:w,70:L}),e(Y,[2,35],{65:R,66:F,67:b,68:w,70:L}),e(Y,[2,34],{65:R,66:F,67:b,68:w,70:L}),e(Y,[2,36],{65:R,66:F,67:b,68:w,70:L})],defaultActions:{9:[2,1]},parseError:function(t,e){if(!e.recoverable)throw new Error(t);this.trace(t)},parse:function(t){function e(){var t;return t=f.lex()||l,"number"!=typeof t&&(t=n.symbols_[t]||t),t}var n=this,i=[0],r=[null],o=[],s=this.table,u="",a=0,h=0,c=0,l=1,p=o.slice.call(arguments,1),f=Object.create(this.lexer),k={yy:{}};for(var E in this.yy)Object.prototype.hasOwnProperty.call(this.yy,E)&&(k.yy[E]=this.yy[E]);f.setInput(t,k.yy),k.yy.lexer=f,k.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var T=f.yylloc;o.push(T);var S=f.options&&f.options.ranges;"function"==typeof k.yy.parseError?this.parseError=k.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,d,O,y,N,R,F,b,w={};;){if(d=i[i.length-1],this.defaultActions[d]?O=this.defaultActions[d]:(null!==g&&void 0!==g||(g=e()),O=s[d]&&s[d][g]),void 0===O||!O.length||!O[0]){var L="";b=[];for(N in s[d])this.terminals_[N]&&N>2&&b.push("'"+this.terminals_[N]+"'");L=f.showPosition?"Parse error on line "+(a+1)+":\n"+f.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(a+1)+": Unexpected "+(g==l?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(L,{text:f.match,token:this.terminals_[g]||g,line:f.yylineno,loc:T,expected:b})}if(O[0]instanceof Array&&O.length>1)throw new Error("Parse Error: multiple actions possible at state: "+d+", token: "+g);switch(O[0]){case 1:i.push(g),r.push(f.yytext),o.push(f.yylloc),i.push(O[1]),g=null,m?(g=m,m=null):(h=f.yyleng,u=f.yytext,a=f.yylineno,T=f.yylloc,c>0&&c--);break;case 2:if(R=this.productions_[O[1]][1],w.$=r[r.length-R],w._$={first_line:o[o.length-(R||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(R||1)].first_column,last_column:o[o.length-1].last_column},S&&(w._$.range=[o[o.length-(R||1)].range[0],o[o.length-1].range[1]]),void 0!==(y=this.performAction.apply(w,[u,h,a,k.yy,O[1],r,o].concat(p))))return y;R&&(i=i.slice(0,-1*R*2),r=r.slice(0,-1*R),o=o.slice(0,-1*R)),i.push(this.productions_[O[1]][0]),r.push(w.$),o.push(w._$),F=s[i[i.length-2]][i[i.length-1]],i.push(F);break;case 3:return!0}}return!0}};return t.prototype=X,X.Parser=t,new t}();void 0!==t&&void 0!==e&&(e.parser=n,e.Parser=n.Parser,e.parse=function(){return n.parse.apply(n,arguments)},e.main=function(n){n[1]||(console.log("Usage: "+n[0]+" FILE"),process.exit(1));var i=t("fs").readFileSync(t("path").normalize(n[1]),"utf8");return e.parser.parse(i)},"undefined"!=typeof module&&t.main===module&&e.main(process.argv.slice(1)))},t["./nodes"]=new function(){var t=this;(function(){var e;e=function(t){var e;return function(){var n,i,r,o;for(r=t.split("\n"),o=[],n=0,i=r.length;n<i;n++)e=r[n],o.push(" "+e);return o}().join("\n")},t.Select=function(){function t(t,e,n,i,r){this.fields=t,this.source=e,this.distinct=null!=n&&n,this.joins=null!=i?i:[],this.unions=null!=r?r:[],this.order=null,this.group=null,this.where=null,this.limit=null}return t.prototype.toString=function(){var t,n,i,r,o,s,u,a,h;for(n=["SELECT "+this.fields.join(", ")],n.push(e("FROM "+this.source)),a=this.joins,r=0,s=a.length;r<s;r++)t=a[r],n.push(e(t.toString()));for(this.where&&n.push(e(this.where.toString())),this.group&&n.push(e(this.group.toString())),this.order&&n.push(e(this.order.toString())),this.limit&&n.push(e(this.limit.toString())),h=this.unions,o=0,u=h.length;o<u;o++)i=h[o],n.push(i.toString());return n.join("\n")},t}(),t.SubSelect=function(){function t(t,e){this.select=t,this.name=null!=e?e:null}return t.prototype.toString=function(){var t;return t=[],t.push("("),t.push(e(this.select.toString())),t.push(this.name?") "+this.name.toString():")"),t.join("\n")},t}(),t.Join=function(){function t(t,e,n,i){this.right=t,this.conditions=null!=e?e:null,this.side=null!=n?n:null,this.mode=null!=i?i:null}return t.prototype.toString=function(){var t;return t="",null!=this.side&&(t+=this.side+" "),null!=this.mode&&(t+=this.mode+" "),t+"JOIN "+this.right+"\n"+e("ON "+this.conditions)},t}(),t.Union=function(){function t(t,e){this.query=t,this.all=null!=e&&e}return t.prototype.toString=function(){return"UNION"+(this.all?" ALL":"")+"\n"+this.query.toString()},t}(),t.LiteralValue=function(){function t(t,e){this.value=t,this.value2=null!=e?e:null,this.value2?(this.nested=!0,this.values=this.value.values,this.values.push(e)):(this.nested=!1,this.values=[this.value])}return t.prototype.toString=function(t){return null==t&&(t=!0),t?"`"+this.values.join("`.`")+"`":""+this.values.join(".")},t}(),t.StringValue=function(){function t(t,e){this.value=t,this.quoteType=null!=e?e:"''"}return t.prototype.toString=function(){var t;return t="'"===this.quoteType?this.value.replace(/(^|[^\\])'/g,"$1''"):this.value,""+this.quoteType+t+this.quoteType},t}(),t.NumberValue=function(){function t(t){this.value=Number(t)}return t.prototype.toString=function(){return this.value.toString()},t}(),t.ListValue=function(){function t(t){this.value=t}return t.prototype.toString=function(){return"("+this.value.join(", ")+")"},t}(),t.WhitepaceList=function(){function e(t){this.value=t}return e.prototype.toString=function(){return this.value.map(function(e){return e instanceof t.LiteralValue?e.toString(!1):e.toString()}).join(" ")},e}(),t.ParameterValue=function(){function t(t){this.value=t,this.index=parseInt(t.substr(1),10)-1}return t.prototype.toString=function(){return"$"+this.value},t}(),t.ArgumentListValue=function(){function t(t,e){this.value=t,this.distinct=null!=e&&e}return t.prototype.toString=function(){return this.distinct?"DISTINCT "+this.value.join(", "):""+this.value.join(", ")},t}(),t.BooleanValue=function(){function t(t){this.value=function(){switch(t.toLowerCase()){case"true":return!0;case"false":return!1;default:return null}}()}return t.prototype.toString=function(){return null!=this.value?this.value.toString().toUpperCase():"NULL"},t}(),t.FunctionValue=function(){function t(t,e,n){this.name=t,this.arguments=null!=e?e:null,this.udf=null!=n&&n}return t.prototype.toString=function(){return this.arguments?this.name.toUpperCase()+"("+this.arguments.toString()+")":this.name.toUpperCase()+"()"},t}(),t.Case=function(){function t(t,e){this.whens=t,this.else=e}return t.prototype.toString=function(){var t;return t=this.whens.map(function(t){return t.toString()}).join(" "),this.else?"CASE "+t+" "+this.else.toString()+" END":"CASE "+t+" END"},t}(),t.CaseWhen=function(){function t(t,e){this.whenCondition=t,this.resCondition=e}return t.prototype.toString=function(){return"WHEN "+this.whenCondition+" THEN "+this.resCondition},t}(),t.CaseElse=function(){function t(t){this.elseCondition=t}return t.prototype.toString=function(){return"ELSE "+this.elseCondition},t}(),t.Order=function(){function t(t,e){this.orderings=t,this.offset=e}return t.prototype.toString=function(){return"ORDER BY "+this.orderings.join(", ")+(this.offset?"\n"+this.offset.toString():"")},t}(),t.OrderArgument=function(){function t(t,e){this.value=t,this.direction=null!=e?e:"ASC"}return t.prototype.toString=function(){return this.value+" "+this.direction},t}(),t.Offset=function(){function t(t,e){this.row_count=t,this.limit=e}return t.prototype.toString=function(){return"OFFSET "+this.row_count+" ROWS"+(this.limit?"\nFETCH NEXT "+this.limit+" ROWS ONLY":"")},t}(),t.Limit=function(){function t(t,e){this.value=t,this.offset=e}return t.prototype.toString=function(){return"LIMIT "+this.value+(this.offset?"\nOFFSET "+this.offset:"")},t}(),t.Table=function(){function t(t,e,n,i,r){this.name=t,this.alias=null!=e?e:null,this.win=null!=n?n:null,this.winFn=null!=i?i:null,this.winArg=null!=r?r:null}return t.prototype.toString=function(){return this.win?this.name+"."+this.win+":"+this.winFn+"("+this.winArg+")":this.alias?this.name+" AS "+this.alias:this.name.toString()},t}(),t.Group=function(){function t(t){this.fields=t,this.having=null}return t.prototype.toString=function(){var t;return t=["GROUP BY "+this.fields.join(", ")],this.having&&t.push(this.having.toString()),t.join("\n")},t}(),t.Where=function(){function t(t){this.conditions=t}return t.prototype.toString=function(){return"WHERE "+this.conditions},t}(),t.Having=function(){function t(t){this.conditions=t}return t.prototype.toString=function(){return"HAVING "+this.conditions},t}(),t.Op=function(){function t(t,e,n){this.operation=t,this.left=e,this.right=n}return t.prototype.toString=function(){return"("+this.left+" "+this.operation.toUpperCase()+" "+this.right+")"},t}(),t.UnaryOp=function(){function t(t,e){this.operator=t,this.operand=e}return t.prototype.toString=function(){return"("+this.operator.toUpperCase()+" "+this.operand+")"},t}(),t.BetweenOp=function(){function t(t){this.value=t}return t.prototype.toString=function(){return""+this.value.join(" AND ")},t}(),t.Field=function(){function t(t,e){this.field=t,this.name=null!=e?e:null}return t.prototype.toString=function(){return this.name?this.field+" AS "+this.name:this.field.toString()},t}(),t.Star=function(){function t(){}return t.prototype.toString=function(){return"*"},t.prototype.star=!0,t}()}).call(this)},t["./parser"]=new function(){var e=this;(function(){var n;n=function(){var e;return e=t("./compiled_parser").parser,e.lexer={lex:function(){var t,e;return e=this.tokens[this.pos++]||[""],t=e[0],this.yytext=e[1],this.yylineno=e[2],t},setInput:function(t){return this.tokens=t,this.pos=0},upcomingInput:function(){return""}},e.yy=t("./nodes"),e},e.parser=n(),e.parse=function(t){return n().parse(t)}}).call(this)},t["./sql_parser"]=new function(){var e=this;(function(){e.lexer=t("./lexer"),e.parser=t("./parser"),e.nodes=t("./nodes"),e.parse=function(t){return e.parser.parse(e.lexer.tokenize(t))}}).call(this)},t["./sql_parser"]}();"function"==typeof define&&define.amd?define(function(){return e}):t.SQLParser=e}(this);