UNPKG

alasql

Version:

AlaSQL.js - JavaScript SQL database library for relational and graph data manipulation with support of localStorage, IndexedDB, and Excel

1,097 lines (1,039 loc) 469 kB
// // alasql.js // AlaSQL - JavaScript SQL database // Date: 16.04.2015 // Version: 0.0.47 // (ñ) 2014-2015, Andrey Gershun // /* The MIT License (MIT) Copyright (c) 2014-2015 Andrey Gershun (agershun@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** UMD envelope */ (function (root, factory) { if (typeof define === 'function' && define.amd) { define([], factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.alasql = factory(); } }(this, function () { /** alasql - Main Alasql class @param {string | Object} sql SQL-statement or data object for fuent interface @param {Object} params SQL parameters @param {Function} cb callback function @param {Object} scope Scope for nested queries @return {array} Result data object Standard sync call: alasql('CREATE TABLE one'); Query: var res = alasql('SELECT * FROM one'); Call with parameters: var res = alasql('SELECT * FROM ?',[data]); Standard async call with callback function: alasql('SELECT * FROM ?',[data],function(res){ console.log(data); }); Call with scope for subquery (to pass common values): var scope = {one:{a:2,b;20}} alasql('SELECT * FROM ? two WHERE two.a = one.a',[data],null,scope); Call for fluent interface with data object: alasql(data).Where(function(x){return x.a == 10}).exec(); Call for fluent interface without data object: alasql().From(data).Where(function(x){return x.a == 10}).exec(); */ var alasql = function(sql, params, cb, scope) { if(typeof importScripts != 'function' && alasql.webworker) { var id = alasql.lastid++; alasql.buffer[id] = cb; alasql.webworker.postMessage({id:id,sql:sql,params:params}); } else { if(arguments.length == 0) { // Without arguments - Fluent interface return new yy.Select({ columns:[new yy.Column({columnid:'*'})], from: [new yy.ParamValue({param:0})] }); } else if (arguments.length == 1 && typeof sql == "object" && sql instanceof Array) { // One argument data object - fluent interface var select = new yy.Select({ columns:[new yy.Column({columnid:'*'})], from: [new yy.ParamValue({param:0})] }); select.preparams = [sql]; return select; } else { // Standard interface // alasql('#sql'); if(typeof sql == 'string' && sql[0]=='#' && typeof document == "object") { sql = document.querySelector(sql).textContent; } else if(typeof sql == 'object' && sql instanceof HTMElement) { sql = sql.textContent; } else if(typeof sql == 'function') { // to run multiline functions sql = sql.toString().slice(14,-3); } // Run SQL return alasql.exec(sql, params, cb, scope); } }; }; /** Current version of alasql */ alasql.version = "0.0.47"; /* parser generated by jison 0.4.15 */ /* Returns a Parser object of the following structure: Parser: { yy: {} } Parser.prototype: { yy: {}, trace: function(), symbols_: {associative list: name ==> number}, terminals_: {associative list: number ==> name}, productions_: [...], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), table: [...], defaultActions: {...}, parseError: function(str, hash), parse: function(input), lexer: { EOF: 1, parseError: function(str, hash), setInput: function(input), input: function(), unput: function(str), more: function(), less: function(n), pastInput: function(), upcomingInput: function(), showPosition: function(), test_match: function(regex_match_array, rule_index), next: function(), lex: function(), begin: function(condition), popState: function(), _currentRules: function(), topState: function(), pushState: function(condition), options: { ranges: boolean (optional: true ==> token location info will include a .range[] member) flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) }, performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), rules: [...], conditions: {associative list: name ==> set}, } } token location info (@$, _$, etc.): { first_line: n, last_line: n, first_column: n, last_column: n, range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) } the parseError function receives a 'hash' object with these members for lexer and parser errors: { text: (matched text) token: (the produced terminal token, if any) line: (yylineno) } while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { loc: (yylloc) expected: (string describing the set of expected tokens) recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) } */ var parser = (function(){ var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,11],$V1=[1,6],$V2=[1,35],$V3=[1,61],$V4=[1,80],$V5=[1,70],$V6=[1,68],$V7=[1,78],$V8=[1,54],$V9=[1,57],$Va=[1,52],$Vb=[1,49],$Vc=[1,56],$Vd=[1,50],$Ve=[1,58],$Vf=[1,51],$Vg=[1,55],$Vh=[1,67],$Vi=[1,62],$Vj=[1,69],$Vk=[1,71],$Vl=[1,72],$Vm=[1,65],$Vn=[1,66],$Vo=[1,64],$Vp=[1,73],$Vq=[1,74],$Vr=[1,75],$Vs=[1,76],$Vt=[1,77],$Vu=[1,53],$Vv=[1,63],$Vw=[1,60],$Vx=[1,82],$Vy=[1,83],$Vz=[8,9,11,202],$VA=[8,9,11,202,206],$VB=[1,138],$VC=[1,139],$VD=[1,103],$VE=[1,114],$VF=[1,111],$VG=[1,110],$VH=[1,128],$VI=[1,124],$VJ=[1,125],$VK=[1,129],$VL=[1,130],$VM=[1,131],$VN=[1,132],$VO=[1,133],$VP=[1,134],$VQ=[1,135],$VR=[1,136],$VS=[1,137],$VT=[1,112],$VU=[1,113],$VV=[1,115],$VW=[1,116],$VX=[1,121],$VY=[1,122],$VZ=[1,117],$V_=[1,118],$V$=[1,119],$V01=[1,120],$V11=[1,123],$V21=[1,109],$V31=[1,108],$V41=[1,107],$V51=[1,127],$V61=[1,140],$V71=[1,151],$V81=[4,5],$V91=[8,9,11,65,97,124,125,135,136,137,139,145,202,206],$Va1=[1,167],$Vb1=[1,175],$Vc1=[1,174],$Vd1=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Ve1=[1,206],$Vf1=[1,199],$Vg1=[4,5,64,96,152,155,166,167,168,170,179,180,181,182,183,184,185,186,187,189,190,191,192,193,194,195,196,197,198,199,209,210,229,315,319],$Vh1=[2,74],$Vi1=[1,220],$Vj1=[4,5,64,75,78,79,88,96,152,155,166,167,168,170,179,180,181,182,183,184,185,186,187,189,190,191,192,193,194,195,196,197,198,199,209,210,229,315,319],$Vk1=[1,236],$Vl1=[1,232],$Vm1=[1,233],$Vn1=[1,234],$Vo1=[1,235],$Vp1=[1,237],$Vq1=[1,238],$Vr1=[1,239],$Vs1=[1,240],$Vt1=[1,241],$Vu1=[1,242],$Vv1=[1,243],$Vw1=[1,244],$Vx1=[1,245],$Vy1=[1,246],$Vz1=[1,247],$VA1=[1,248],$VB1=[1,249],$VC1=[1,250],$VD1=[1,252],$VE1=[1,253],$VF1=[1,255],$VG1=[1,254],$VH1=[1,256],$VI1=[1,257],$VJ1=[1,258],$VK1=[1,259],$VL1=[2,197],$VM1=[1,263],$VN1=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,192,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,247,251,259,264,275,276,279,280,292,293,295,296,300,302,304,305,310,312,313,321,323,329,331,332,334,335,336,337,338,340,343,344,356],$VO1=[2,255],$VP1=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,120,122,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,192,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,247,251,259,264,275,276,279,280,292,293,295,296,300,302,304,305,310,312,313,321,323,329,331,332,334,335,336,337,338,340,343,344,356],$VQ1=[1,271],$VR1=[1,281],$VS1=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,321,323,329,331,332,334,335,336,337,338,340,343,344,356],$VT1=[1,297],$VU1=[4,5,8,9,11,45,59,61,63,64,65,78,80,86,91,96,97,102,104,106,112,113,114,115,116,117,118,119,120,122,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,192,196,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,245,247,251,258,259,260,264,275,276,277,279,280,288,289,292,293,295,296,297,298,299,300,301,302,304,305,306,310,312,313,321,323,328,329,331,332,334,335,336,337,338,340,343,344,356],$VV1=[1,304],$VW1=[1,305],$VX1=[2,368],$VY1=[1,310],$VZ1=[8,9,11,61,202,206],$V_1=[2,420],$V$1=[1,321],$V02=[8,9,11,65,124,125,135,136,137,139,145,202,206],$V12=[8,9,11,61,65,102,104,112,113,114,115,116,117,118,119,120,122,124,125,135,136,137,139,145,202,206],$V22=[2,110],$V32=[1,349],$V42=[61,80],$V52=[8,9,11,61,65,192,202,206,229,247,259,275,276,279,280,292],$V62=[79,236,237],$V72=[1,414],$V82=[1,420],$V92=[1,421],$Va2=[1,431],$Vb2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,166,191,202,204,205,206,207,208,209,210,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vc2=[2,270],$Vd2=[1,438],$Ve2=[202,204,206],$Vf2=[61,323],$Vg2=[61,321,323],$Vh2=[1,445],$Vi2=[61,321],$Vj2=[4,5,96,191],$Vk2=[8,9,11,65,125,135,136,137,139,145,202,206],$Vl2=[8,9,11,65,91,97,124,125,135,136,137,139,145,202,206],$Vm2=[1,512],$Vn2=[8,9,11,61,65,91,97,124,125,135,136,137,139,145,202,206],$Vo2=[2,180],$Vp2=[1,514],$Vq2=[1,515],$Vr2=[8,9,11,61,65,91,97,124,125,135,136,137,139,145,150,151,202,206],$Vs2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,166,191,202,204,205,206,207,208,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vt2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,202,204,205,206,207,208,209,210,211,212,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vu2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,166,191,202,204,205,206,215,216,217,218,219,220,221,222,223,224,227,228,232,233,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vv2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,166,191,202,204,205,206,228,232,233,235,238,239,242,243,251,264,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vw2=[4,5,8,9,11,45,59,61,63,65,80,91,96,97,102,104,112,113,114,115,116,117,118,119,124,125,134,135,136,137,139,142,143,145,150,151,152,155,166,191,192,202,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,227,228,229,230,232,233,234,235,238,239,242,243,247,251,259,264,275,276,279,280,292,293,295,296,300,302,304,305,310,312,313,329,331,332,334,335,336,337,338,340,343,344,356],$Vx2=[1,537],$Vy2=[61,65],$Vz2=[2,195],$VA2=[1,577],$VB2=[8,9,11,65,135,136,137,139,145,202,206],$VC2=[8,9,11,61,65,124,125,135,136,137,139,145,202,206],$VD2=[1,592],$VE2=[1,593],$VF2=[1,595],$VG2=[1,596],$VH2=[1,597],$VI2=[1,598],$VJ2=[1,599],$VK2=[1,600],$VL2=[1,601],$VM2=[1,602],$VN2=[1,606],$VO2=[1,617],$VP2=[8,9,11,61,124,202,204,206,356],$VQ2=[1,625],$VR2=[1,624],$VS2=[2,233],$VT2=[1,646],$VU2=[2,437],$VV2=[1,667],$VW2=[1,679],$VX2=[8,9,11,61,202,204,206,356],$VY2=[1,682],$VZ2=[8,9,11,61,65,102,104,112,113,114,115,116,117,118,119,124,125,135,136,137,139,145,202,206],$V_2=[8,9,11,65,135,136,137,145,202,206],$V$2=[8,9,11,65,102,104,112,113,114,115,116,117,118,119,124,125,135,136,137,139,145,202,206],$V03=[1,696],$V13=[1,698],$V23=[4,5,64,193,195,196,197,198],$V33=[8,9,11,202,204,206,356],$V43=[214,219],$V53=[1,738],$V63=[8,9,11,61,65,202,206],$V73=[1,754],$V83=[8,9,11,65,135,136,137,202,206],$V93=[1,773],$Va3=[1,774],$Vb3=[1,775],$Vc3=[8,9,11,65,102,104,112,113,114,115,116,117,118,119,120,122,124,125,135,136,137,139,145,202,206],$Vd3=[1,805],$Ve3=[1,818],$Vf3=[1,819],$Vg3=[1,817],$Vh3=[1,815],$Vi3=[1,821],$Vj3=[1,812],$Vk3=[1,813],$Vl3=[1,814],$Vm3=[1,816],$Vn3=[1,825],$Vo3=[1,830],$Vp3=[1,831],$Vq3=[1,832],$Vr3=[1,833],$Vs3=[78,86,275,276,277,279],$Vt3=[2,380],$Vu3=[1,838],$Vv3=[8,9,11,65,202,206],$Vw3=[1,851],$Vx3=[8,9,11,61,65,134,135,136,137,139,145,202,206],$Vy3=[1,868],$Vz3=[1,867],$VA3=[8,9,11,202,206,247,258,259,260],$VB3=[1,921],$VC3=[8,9,11,61,65,135,136,137,145,202,206],$VD3=[1,938]; var parser = {trace: function trace() { }, yy: {}, symbols_: {"error":2,"Literal":3,"LITERAL":4,"BRALITERAL":5,"main":6,"Statements":7,"EOF":8,"SEMICOLON":9,"AStatement":10,"GO":11,"ExplainStatement":12,"EXPLAIN":13,"QUERY":14,"PLAN":15,"Statement":16,"If":17,"AlterTable":18,"AttachDatabase":19,"CreateDatabase":20,"CreateIndex":21,"CreateTable":22,"CreateView":23,"Declare":24,"Delete":25,"DetachDatabase":26,"DropDatabase":27,"DropIndex":28,"DropTable":29,"DropView":30,"Insert":31,"RenameTable":32,"Select":33,"Merge":34,"WithSelect":35,"ShowCreateTable":36,"ShowColumns":37,"ShowDatabases":38,"ShowIndex":39,"ShowTables":40,"TruncateTable":41,"BeginTransaction":42,"CommitTransaction":43,"RollbackTransaction":44,"EndTransaction":45,"UseDatabase":46,"Update":47,"Help":48,"JavaScript":49,"Source":50,"Assert":51,"While":52,"Continue":53,"Break":54,"BeginEnd":55,"Print":56,"Require":57,"SetVariable":58,"WITH":59,"WithTablesList":60,"COMMA":61,"WithTable":62,"AS":63,"LPAR":64,"RPAR":65,"SelectClause":66,"IntoClause":67,"FromClause":68,"WhereClause":69,"GroupClause":70,"OrderClause":71,"LimitClause":72,"UnionClause":73,"SelectModifier":74,"DISTINCT":75,"TopClause":76,"ResultColumns":77,"UNIQUE":78,"ALL":79,"SELECT":80,"VALUE":81,"ROW":82,"COLUMN":83,"MATRIX":84,"TEXTSTRING":85,"INDEX":86,"RECORDSET":87,"TOP":88,"NumValue":89,"PERCENT":90,"INTO":91,"Table":92,"FuncValue":93,"ParamValue":94,"VarValue":95,"STRING":96,"FROM":97,"FromTablesList":98,"FromTable":99,"JoinTablesList":100,"ApplyClause":101,"CROSS":102,"APPLY":103,"OUTER":104,"FromString":105,"DOT":106,"JoinTable":107,"JoinMode":108,"JoinTableAs":109,"OnClause":110,"JoinModeMode":111,"NATURAL":112,"JOIN":113,"INNER":114,"LEFT":115,"RIGHT":116,"FULL":117,"SEMI":118,"ANTI":119,"ON":120,"Expression":121,"USING":122,"ColumnsList":123,"WHERE":124,"GROUP":125,"BY":126,"GroupExpressionsList":127,"HavingClause":128,"GroupExpression":129,"GROUPING":130,"SETS":131,"ROLLUP":132,"CUBE":133,"HAVING":134,"UNION":135,"EXCEPT":136,"INTERSECT":137,"CORRESPONDING":138,"ORDER":139,"OrderExpressionsList":140,"OrderExpression":141,"DIRECTION":142,"COLLATE":143,"NOCASE":144,"LIMIT":145,"OffsetClause":146,"OFFSET":147,"ResultColumn":148,"TDTH":149,"TD":150,"TH":151,"NUMBER":152,"StringValue":153,"Star":154,"STAR":155,"Column":156,"AggrValue":157,"Op":158,"LogicValue":159,"NullValue":160,"ExistsValue":161,"CaseValue":162,"CastClause":163,"Json":164,"NewClause":165,"JAVASCRIPT":166,"NEW":167,"CAST":168,"ColumnType":169,"CONVERT":170,"PrimitiveValue":171,"CURRENT_TIMESTAMP":172,"Aggregator":173,"OverClause":174,"OVER":175,"OverPartitionClause":176,"OverOrderByClause":177,"PARTITION":178,"SUM":179,"COUNT":180,"MIN":181,"MAX":182,"AVG":183,"FIRST":184,"LAST":185,"AGGR":186,"ARRAY":187,"ExprList":188,"TRUE":189,"FALSE":190,"NSTRING":191,"NULL":192,"AT":193,"EXISTS":194,"DOLLAR":195,"COLON":196,"QUESTION":197,"BRAQUESTION":198,"CASE":199,"WhensList":200,"ElseClause":201,"END":202,"When":203,"WHEN":204,"THEN":205,"ELSE":206,"LIKE":207,"NOT_LIKE":208,"PLUS":209,"MINUS":210,"SLASH":211,"MODULO":212,"CARET":213,"ARROW":214,"GT":215,"GE":216,"LT":217,"LE":218,"EQ":219,"EQEQ":220,"EQEQEQ":221,"NE":222,"NEEQEQ":223,"NEEQEQEQ":224,"CondOp":225,"AllSome":226,"AND":227,"OR":228,"NOT":229,"IN":230,"ColFunc":231,"BETWEEN":232,"NOT_BETWEEN":233,"IS":234,"DOUBLECOLON":235,"SOME":236,"ANY":237,"UPDATE":238,"SET":239,"SetColumnsList":240,"SetColumn":241,"DELETE":242,"INSERT":243,"Into":244,"VALUES":245,"ValuesListsList":246,"DEFAULT":247,"ValuesList":248,"Value":249,"DateValue":250,"CREATE":251,"TABLE":252,"IfNotExists":253,"CreateTableDefClause":254,"CreateTableOptionsClause":255,"CreateTableOptions":256,"CreateTableOption":257,"ENGINE":258,"AUTO_INCREMENT":259,"CHARSET":260,"TemporaryClause":261,"TEMPORARY":262,"TEMP":263,"IF":264,"ColumnDefsList":265,"ConstraintsList":266,"Constraint":267,"ConstraintName":268,"PrimaryKey":269,"ForeignKey":270,"UniqueKey":271,"IndexKey":272,"Check":273,"CONSTRAINT":274,"CHECK":275,"PRIMARY":276,"KEY":277,"ColsList":278,"FOREIGN":279,"REFERENCES":280,"OnForeignKeyClause":281,"OnDeleteClause":282,"OnUpdateClause":283,"NO":284,"ACTION":285,"ColumnDef":286,"ColumnConstraintsClause":287,"ColumnConstraints":288,"ENUM":289,"ColumnConstraintsList":290,"ColumnConstraint":291,"IDENTITY":292,"DROP":293,"IfExists":294,"ALTER":295,"RENAME":296,"TO":297,"ADD":298,"MODIFY":299,"ATTACH":300,"DATABASE":301,"DETACH":302,"AsClause":303,"USE":304,"SHOW":305,"DATABASES":306,"TABLES":307,"COLUMNS":308,"VIEW":309,"HELP":310,"ExpressionStatement":311,"SOURCE":312,"ASSERT":313,"JsonObject":314,"ATLBRA":315,"JsonArray":316,"JsonValue":317,"JsonPrimitiveValue":318,"LCUR":319,"JsonPropertiesList":320,"RCUR":321,"JsonElementsList":322,"RBRA":323,"JsonProperty":324,"OnOff":325,"SetPropsList":326,"SetProp":327,"OFF":328,"COMMIT":329,"TRANSACTION":330,"ROLLBACK":331,"BEGIN":332,"ElseStatement":333,"WHILE":334,"CONTINUE":335,"BREAK":336,"PRINT":337,"REQUIRE":338,"StringValuesList":339,"DECLARE":340,"DeclaresList":341,"DeclareItem":342,"TRUNCATE":343,"MERGE":344,"MergeInto":345,"MergeUsing":346,"MergeOn":347,"MergeMatchedList":348,"OutputClause":349,"MergeMatched":350,"MergeNotMatched":351,"MATCHED":352,"MergeMatchedAction":353,"MergeNotMatchedAction":354,"TARGET":355,"OUTPUT":356,"$accept":0,"$end":1}, terminals_: {2:"error",4:"LITERAL",5:"BRALITERAL",8:"EOF",9:"SEMICOLON",11:"GO",13:"EXPLAIN",14:"QUERY",15:"PLAN",45:"EndTransaction",59:"WITH",61:"COMMA",63:"AS",64:"LPAR",65:"RPAR",75:"DISTINCT",78:"UNIQUE",79:"ALL",80:"SELECT",81:"VALUE",82:"ROW",83:"COLUMN",84:"MATRIX",85:"TEXTSTRING",86:"INDEX",87:"RECORDSET",88:"TOP",90:"PERCENT",91:"INTO",96:"STRING",97:"FROM",102:"CROSS",103:"APPLY",104:"OUTER",106:"DOT",112:"NATURAL",113:"JOIN",114:"INNER",115:"LEFT",116:"RIGHT",117:"FULL",118:"SEMI",119:"ANTI",120:"ON",122:"USING",124:"WHERE",125:"GROUP",126:"BY",130:"GROUPING",131:"SETS",132:"ROLLUP",133:"CUBE",134:"HAVING",135:"UNION",136:"EXCEPT",137:"INTERSECT",138:"CORRESPONDING",139:"ORDER",142:"DIRECTION",143:"COLLATE",144:"NOCASE",145:"LIMIT",147:"OFFSET",150:"TD",151:"TH",152:"NUMBER",155:"STAR",166:"JAVASCRIPT",167:"NEW",168:"CAST",170:"CONVERT",172:"CURRENT_TIMESTAMP",175:"OVER",178:"PARTITION",179:"SUM",180:"COUNT",181:"MIN",182:"MAX",183:"AVG",184:"FIRST",185:"LAST",186:"AGGR",187:"ARRAY",189:"TRUE",190:"FALSE",191:"NSTRING",192:"NULL",193:"AT",194:"EXISTS",195:"DOLLAR",196:"COLON",197:"QUESTION",198:"BRAQUESTION",199:"CASE",202:"END",204:"WHEN",205:"THEN",206:"ELSE",207:"LIKE",208:"NOT_LIKE",209:"PLUS",210:"MINUS",211:"SLASH",212:"MODULO",213:"CARET",214:"ARROW",215:"GT",216:"GE",217:"LT",218:"LE",219:"EQ",220:"EQEQ",221:"EQEQEQ",222:"NE",223:"NEEQEQ",224:"NEEQEQEQ",227:"AND",228:"OR",229:"NOT",230:"IN",232:"BETWEEN",233:"NOT_BETWEEN",234:"IS",235:"DOUBLECOLON",236:"SOME",237:"ANY",238:"UPDATE",239:"SET",242:"DELETE",243:"INSERT",245:"VALUES",247:"DEFAULT",250:"DateValue",251:"CREATE",252:"TABLE",258:"ENGINE",259:"AUTO_INCREMENT",260:"CHARSET",262:"TEMPORARY",263:"TEMP",264:"IF",274:"CONSTRAINT",275:"CHECK",276:"PRIMARY",277:"KEY",279:"FOREIGN",280:"REFERENCES",284:"NO",285:"ACTION",288:"ColumnConstraints",289:"ENUM",292:"IDENTITY",293:"DROP",295:"ALTER",296:"RENAME",297:"TO",298:"ADD",299:"MODIFY",300:"ATTACH",301:"DATABASE",302:"DETACH",304:"USE",305:"SHOW",306:"DATABASES",307:"TABLES",308:"COLUMNS",309:"VIEW",310:"HELP",312:"SOURCE",313:"ASSERT",315:"ATLBRA",319:"LCUR",321:"RCUR",323:"RBRA",328:"OFF",329:"COMMIT",330:"TRANSACTION",331:"ROLLBACK",332:"BEGIN",334:"WHILE",335:"CONTINUE",336:"BREAK",337:"PRINT",338:"REQUIRE",340:"DECLARE",343:"TRUNCATE",344:"MERGE",352:"MATCHED",355:"TARGET",356:"OUTPUT"}, productions_: [0,[3,1],[3,1],[6,2],[7,3],[7,3],[7,1],[7,1],[12,2],[12,4],[10,1],[16,0],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[16,1],[35,3],[60,3],[60,1],[62,5],[33,8],[66,4],[66,4],[66,4],[66,3],[74,1],[74,2],[74,2],[74,2],[74,2],[74,2],[74,2],[74,2],[76,2],[76,4],[76,3],[76,0],[67,0],[67,2],[67,2],[67,2],[67,2],[67,2],[68,2],[68,3],[68,0],[101,6],[101,7],[101,6],[101,7],[98,1],[98,3],[99,4],[99,5],[99,3],[99,2],[99,3],[99,1],[99,2],[99,3],[99,1],[99,1],[99,2],[99,3],[99,1],[99,2],[99,3],[99,1],[99,2],[99,3],[105,1],[92,3],[92,1],[100,2],[100,2],[100,1],[100,1],[107,3],[109,1],[109,2],[109,3],[109,2],[109,3],[109,4],[109,5],[109,1],[109,2],[109,3],[109,1],[109,2],[109,3],[108,1],[108,2],[111,1],[111,2],[111,2],[111,3],[111,2],[111,3],[111,2],[111,3],[111,2],[111,2],[111,2],[110,2],[110,2],[110,0],[69,0],[69,2],[70,0],[70,4],[127,1],[127,3],[129,5],[129,4],[129,4],[129,1],[128,0],[128,2],[73,0],[73,2],[73,3],[73,2],[73,2],[73,3],[73,4],[73,3],[73,3],[71,0],[71,3],[140,1],[140,3],[141,1],[141,2],[141,3],[141,4],[72,0],[72,3],[146,0],[146,2],[77,4],[77,2],[149,0],[149,2],[149,2],[149,4],[148,3],[148,2],[148,3],[148,2],[148,3],[148,2],[148,1],[154,5],[154,3],[154,1],[156,5],[156,3],[156,3],[156,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,1],[121,3],[121,1],[49,1],[165,2],[165,2],[163,6],[163,8],[163,6],[163,8],[171,1],[171,1],[171,1],[171,1],[171,1],[171,1],[171,1],[157,5],[157,6],[157,6],[174,0],[174,4],[174,4],[174,5],[176,3],[177,3],[173,1],[173,1],[173,1],[173,1],[173,1],[173,1],[173,1],[173,1],[173,1],[93,4],[93,3],[188,1],[188,3],[89,1],[159,1],[159,1],[153,1],[153,1],[160,1],[95,2],[161,4],[94,2],[94,2],[94,1],[94,1],[162,5],[162,4],[200,2],[200,1],[203,4],[201,2],[201,0],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,5],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,3],[158,6],[158,6],[158,3],[158,3],[158,2],[158,2],[158,2],[158,3],[158,5],[158,6],[158,5],[158,6],[158,4],[158,5],[158,3],[158,4],[158,3],[158,3],[158,3],[158,3],[231,1],[231,1],[231,4],[225,1],[225,1],[225,1],[225,1],[225,1],[225,1],[226,1],[226,1],[226,1],[47,6],[47,4],[240,1],[240,3],[241,3],[25,5],[25,3],[31,5],[31,5],[31,8],[31,4],[31,7],[244,0],[244,1],[246,3],[246,1],[246,1],[246,5],[246,3],[246,3],[248,1],[248,3],[249,1],[249,1],[249,1],[249,1],[249,1],[249,1],[123,1],[123,3],[22,8],[22,4],[255,0],[255,1],[256,2],[256,1],[257,1],[257,3],[257,3],[257,3],[261,0],[261,1],[261,1],[253,0],[253,3],[254,3],[254,1],[254,2],[266,1],[266,3],[267,2],[267,2],[267,2],[267,2],[267,2],[268,0],[268,2],[273,4],[269,5],[270,11],[281,0],[281,2],[282,4],[283,4],[271,1],[272,5],[272,5],[278,1],[278,1],[278,3],[278,3],[265,1],[265,3],[286,3],[286,2],[286,1],[169,6],[169,4],[169,1],[169,4],[287,0],[287,1],[290,2],[290,1],[291,2],[291,7],[291,5],[291,1],[291,6],[291,1],[291,2],[291,1],[291,2],[291,1],[29,4],[294,0],[294,2],[18,6],[18,6],[18,6],[18,8],[18,6],[32,5],[19,4],[19,7],[19,6],[19,9],[26,3],[20,4],[20,6],[20,9],[20,6],[303,0],[303,2],[46,3],[46,2],[27,4],[27,5],[27,5],[21,8],[21,9],[28,3],[38,2],[38,4],[38,3],[38,5],[40,2],[40,4],[40,4],[40,6],[37,4],[37,6],[39,4],[39,6],[36,4],[36,6],[23,9],[23,6],[30,4],[48,2],[48,1],[311,1],[50,2],[51,2],[51,2],[51,4],[164,4],[164,2],[164,2],[164,2],[164,2],[164,1],[164,2],[164,2],[317,1],[317,1],[318,1],[318,1],[318,1],[318,1],[318,1],[318,1],[318,1],[318,3],[314,3],[314,4],[314,2],[316,2],[316,3],[316,1],[320,3],[320,1],[324,3],[324,3],[324,3],[322,3],[322,1],[58,3],[58,5],[58,6],[326,3],[326,2],[327,1],[327,1],[327,3],[325,1],[325,1],[43,2],[44,2],[42,2],[17,4],[17,3],[333,2],[52,3],[53,1],[54,1],[55,3],[56,2],[56,2],[57,2],[339,3],[339,1],[24,2],[341,1],[341,3],[342,3],[342,4],[342,5],[342,6],[41,3],[34,6],[345,1],[345,2],[346,2],[347,2],[348,2],[348,2],[348,1],[348,1],[350,4],[350,6],[353,1],[353,3],[351,5],[351,7],[351,7],[351,9],[351,7],[351,9],[354,3],[354,6],[354,3],[354,6],[349,0],[349,2],[349,5],[349,4],[349,7]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ var $0 = $$.length - 1; switch (yystate) { case 1: if (yy.casesensitive) this.$ = $$[$0]; else this.$ = $$[$0].toLowerCase(); break; case 2: this.$ = doubleq($$[$0].substr(1,$$[$0].length-2)); break; case 3: return new yy.Statements({statements:$$[$0-1]}); break; case 4: case 5: this.$ = $$[$0-2]; if($$[$0]) $$[$0-2].push($$[$0]); break; case 6: case 7: case 56: case 88: case 113: case 114: case 149: case 168: case 250: case 267: case 327: case 340: case 341: case 345: case 353: case 392: case 393: case 501: case 506: case 526: case 528: case 542: case 543: this.$ = [$$[$0]]; break; case 8: this.$ = $$[$0]; $$[$0].explain = true; break; case 9: this.$ = $$[$0]; $$[$0].explain = true; break; case 10: this.$ = $$[$0]; if(yy.exists) this.$.exists = yy.exists; delete yy.exists; if(yy.queries) this.$.queries = yy.queries; delete yy.queries; break; case 11: case 63: case 74: case 83: case 144: case 145: case 147: case 155: case 157: case 166: case 174: case 176: case 229: case 270: case 365: case 368: case 380: case 385: case 386: case 420: this.$ = undefined; break; case 54: this.$ = new yy.WithSelect({withs: $$[$0-1], select:$$[$0]}); break; case 55: $$[$0-2].push($$[$0]); this.$=$$[$0-2]; break; case 57: this.$ = {name:$$[$0-4], select:$$[$0-1]}; break; case 58: yy.extend(this.$,$$[$0-7]); yy.extend(this.$,$$[$0-6]); yy.extend(this.$,$$[$0-5]); yy.extend(this.$,$$[$0-4]); yy.extend(this.$,$$[$0-3]); yy.extend(this.$,$$[$0-2]);yy.extend(this.$,$$[$0-1]); yy.extend(this.$,$$[$0]); this.$ = $$[$0-7]; /* if(yy.exists) this.$.exists = yy.exists; delete yy.exists; if(yy.queries) this.$.queries = yy.queries; delete yy.queries; */ break; case 59: this.$ = new yy.Select({ columns:$$[$0], distinct: true }); yy,extend(this.$, $$[$0-3]); yy.extend(this.$, $$[$0-1]); break; case 60: this.$ = new yy.Select({ columns:$$[$0], distinct: true }); yy,extend(this.$, $$[$0-3]);yy.extend(this.$, $$[$0-1]); break; case 61: this.$ = new yy.Select({ columns:$$[$0], all:true }); yy,extend(this.$, $$[$0-3]);yy.extend(this.$, $$[$0-1]); break; case 62: this.$ = new yy.Select({ columns:$$[$0] }); yy,extend(this.$, $$[$0-2]);yy.extend(this.$, $$[$0-1]); break; case 64: this.$ = {modifier:'VALUE'} break; case 65: this.$ = {modifier:'ROW'} break; case 66: this.$ = {modifier:'COLUMN'} break; case 67: this.$ = {modifier:'MATRIX'} break; case 68: this.$ = {modifier:'TEXTSTRING'} break; case 69: this.$ = {modifier:'INDEX'} break; case 70: this.$ = {modifier:'RECORDSET'} break; case 71: this.$ = {top: $$[$0]}; break; case 72: this.$ = {top: $$[$0-1]}; break; case 73: this.$ = {top: $$[$0-1], percent:true}; break; case 75: case 233: case 387: case 388: this.$ = undefined; break; case 76: case 77: case 78: case 79: this.$ = {into: $$[$0]} break; case 80: var s = $$[$0]; s = s.substr(1,s.length-2); var x3 = s.substr(-3).toUpperCase(); var x4 = s.substr(-4).toUpperCase(); if(s[0] == '#') { this.$ = {into: new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})}; } else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') { this.$ = {into: new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})}; } else if(x4=='XLSX' || x4 == 'JSON') { this.$ = {into: new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})}; } break; case 81: this.$ = { from: $$[$0] }; break; case 82: this.$ = { from: [$$[$0-1]], joins: $$[$0] }; break; case 84: this.$ = new yy.Apply({select: $$[$0-2], applymode:'CROSS', as:$$[$0]}); break; case 85: this.$ = new yy.Apply({select: $$[$0-3], applymode:'CROSS', as:$$[$0]}); break; case 86: this.$ = new yy.Apply({select: $$[$0-2], applymode:'OUTER', as:$$[$0]}); break; case 87: this.$ = new yy.Apply({select: $$[$0-3], applymode:'OUTER', as:$$[$0]}); break; case 89: case 150: case 328: case 394: case 395: this.$ = $$[$0-2]; $$[$0-2].push($$[$0]); break; case 90: this.$ = $$[$0-2]; this.$.as = $$[$0] break; case 91: this.$ = $$[$0-3]; this.$.as = $$[$0] break; case 92: this.$ = $$[$0-1]; this.$.as = 'default' break; case 93: this.$ = $$[$0-1]; $$[$0-1].as = $$[$0] break; case 94: this.$ = $$[$0-2]; $$[$0-2].as = $$[$0] break; case 95: case 154: case 190: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 213: case 223: case 224: case 225: case 226: case 227: case 228: case 269: case 316: case 317: case 318: case 319: case 320: case 321: case 381: case 406: case 408: case 475: case 476: case 477: case 478: case 479: case 480: case 484: case 486: case 487: case 496: case 507: case 508: this.$ = $$[$0]; break; case 96: case 100: case 103: case 106: this.$ = $$[$0-1]; $$[$0-1].as = $$[$0]; break; case 97: case 101: case 104: case 107: this.$ = $$[$0-2]; $$[$0-2].as = $$[$0]; break; case 98: case 99: case 102: case 105: this.$ = $$[$0]; $$[$0].as = 'default'; break; case 108: var s = $$[$0]; s = s.substr(1,s.length-2); var x3 = s.substr(-3).toUpperCase(); var x4 = s.substr(-4).toUpperCase(); var r; if(s[0] == '#') { r = new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]}); } else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') { r = new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]}); } else if(x4=='XLSX' || x4 == 'JSON') { r = new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]}); } else { throw new Error('Unknown string in FROM clause'); }; this.$ = r; break; case 109: this.$ = new yy.Table({databaseid: $$[$0-2], tableid:$$[$0]}); break; case 110: this.$ = new yy.Table({tableid: $$[$0]}); break; case 111: case 112: this.$ = $$[$0-1]; $$[$0-1].push($$[$0]); break; case 115: this.$ = new yy.Join($$[$0-2]); yy.extend(this.$, $$[$0-1]); yy.extend(this.$, $$[$0]); break; case 116: this.$ = {table: $$[$0]}; break; case 117: this.$ = {table: $$[$0-1], as: $$[$0] } ; break; case 118: this.$ = {table: $$[$0-2], as: $$[$0] } ; break; case 119: this.$ = {param: $$[$0-1], as: $$[$0] } ; break; case 120: this.$ = {param: $$[$0-2], as: $$[$0] } ; break; case 121: this.$ = {select: $$[$0-3], as: $$[$0]} ; break; case 122: this.$ = {select: $$[$0-4], as: $$[$0] } ; break; case 123: this.$ = {funcid:$$[$0], as:'default'}; break; case 124: this.$ = {funcid:$$[$0-1], as: $$[$0]}; break; case 125: this.$ = {funcid:$$[$0-2], as: $$[$0]}; break; case 126: this.$ = {variable:$$[$0],as:'default'}; break; case 127: this.$ = {variable:$$[$0-1],as:$$[$0]}; break; case 128: this.$ = {variable:$$[$0-2],as:$$[$0]} break; case 129: this.$ = { joinmode: $$[$0] } ; break; case 130: this.$ = {joinmode: $$[$0-1], natural:true} ; break; case 131: case 132: this.$ = "INNER"; break; case 133: case 134: this.$ = "LEFT"; break; case 135: case 136: this.$ = "RIGHT"; break; case 137: case 138: this.$ = "OUTER"; break; case 139: this.$ = "SEMI"; break; case 140: this.$ = "ANTI"; break; case 141: this.$ = "CROSS"; break; case 142: this.$ = {on: $$[$0]}; break; case 143: case 538: this.$ = {using: $$[$0]}; break; case 146: this.$ = {where: new yy.Expression({expression:$$[$0]})}; break; case 148: this.$ = {group:$$[$0-1]}; yy.extend(this.$,$$[$0]); break; case 151: this.$ = new yy.GroupExpression({type:'GROUPING SETS', group: $$[$0-1]}); break; case 152: this.$ = new yy.GroupExpression({type:'ROLLUP', group: $$[$0-1]}); break; case 153: this.$ = new yy.GroupExpression({type:'CUBE', group: $$[$0-1]}); break; case 156: this.$ = {having:$$[$0]} break; case 158: this.$ = {union: $$[$0]} ; break; case 159: this.$ = {unionall: $$[$0]} ; break; case 160: this.$ = {except: $$[$0]} ; break; case 161: this.$ = {intersect: $$[$0]} ; break; case 162: this.$ = {union: $$[$0-1], corresponding:true} ; break; case 163: this.$ = {unionall: $$[$0-1], corresponding:true} ; break; case 164: this.$ = {except: $$[$0-1], corresponding:true} ; break; case 165: this.$ = {intersect: $$[$0-1], corresponding:true} ; break; case 167: this.$ = {order:$$[$0]} break; case 169: this.$ = $$[$0-2]; $$[$0-2].push($$[$0]) break; case 170: this.$ = new yy.Expression({expression: $$[$0], direction:'ASC'}) break; case 171: this.$ = new yy.Expression({expression: $$[$0-1], direction:$$[$0].toUpperCase()}) break; case 172: this.$ = new yy.Expression({expression: $$[$0-2], direction:'ASC', nocase:true}) break; case 173: this.$ = new yy.Expression({expression: $$[$0-3], direction:$$[$0].toUpperCase(), nocase:true}) break; case 175: this.$ = {limit:$$[$0-1]}; yy.extend(this.$, $$[$0]) break; case 177: this.$ = {offset:$$[$0]} break; case 178: yy.extend($$[$0-1],$$[$0]); $$[$0-3].push($$[$0-1]); this.$ = $$[$0-3]; break; case 179: yy.extend($$[$0-1],$$[$0]); this.$ = [$$[$0-1]]; break; case 180: this.$ = undefined break; case 181: this.$ = {td:$$[$0]}; break; case 182: this.$ = {th:$$[$0]}; break; case 183: this.$ = {th:$$[$0-2],td:$$[$0]}; break; case 184: case 186: case 188: $$[$0-2].as = $$[$0]; this.$ = $$[$0-2]; break; case 185: case 187: case 189: $$[$0-1].as = $$[$0]; this.$ = $$[$0-1]; break; case 191: this.$ = new yy.Column({columid: $$[$0], tableid: $$[$0-2], databaseid:$$[$0-4]}); break; case 192: this.$ = new yy.Column({columnid: $$[$0], tableid: $$[$0-2]}); break; case 193: this.$ = new yy.Column({columnid:$$[$0]}); break; case 194: this.$ = new yy.Column({columnid: $$[$0], tableid: $$[$0-2], databaseid:$$[$0-4]}); break; case 195: case 196: this.$ = new yy.Column({columnid: $$[$0], tableid: $$[$0-2]}); break; case 197: this.$ = new yy.Column({columnid: $$[$0]}); break; case 212: this.$ = new yy.Json({value:$$[$0]}); break; case 214: if(!yy.queries) yy.queries = []; yy.queries.push($$[$0-1]); $$[$0-1].queriesidx = yy.queries.length; this.$ = $$[$0-1]; break; case 215: this.$ = $$[$0] break; case 216: this.$ = new yy.JavaScript({value:$$[$0].substr(2,$$[$0].length-4)}); break; case 217: this.$ = new yy.FuncValue({funcid:$$[$0], newid:true}); break; case 218: this.$ = $$[$0]; yy.extend(this.$,{newid:true}); break; case 219: this.$ = new yy.Convert({expression:$$[$0-3]}) ; yy.extend(this.$,$$[$0-1]) ; break; case 220: this.$ = new yy.Convert({expression:$$[$0-5], style:$$[$0-1]}) ; yy.extend(this.$,$$[$0-3]) ; break; case 221: this.$ = new yy.Convert({expression:$$[$0-1]}) ; yy.extend(this.$,$$[$0-3]) ; break; case 222: this.$ = new yy.Convert({expression:$$[$0-3], style:$$[$0-1]}) ; yy.extend(this.$,$$[$0-5]) ; break; case 230: this.$ = new yy.AggrValue({aggregatorid: $$[$0-4].toUpperCase(), expression: $$[$0-2], over:$$[$0]}); break; case 231: this.$ = new yy.AggrValue({aggregatorid: $$[$0-5].toUpperCase(), expression: $$[$0-2], distinct:true, over:$$[$0]}); break; case 232: this.$ = new yy.AggrValue({aggregatorid: $$[$0-5].toUpperCase(), expression: $$[$0-2], over:$$[$0]}); break; case 234: case 235: this.$ = new yy.Over(); yy.extend(this.$,$$[$0-1]); break; case 236: this.$ = new yy.Over(); yy.extend(this.$,$$[$0-2]); yy.extend(this.$,$$[$0-1]); break; case 237: this.$ = {partition:$$[$0]}; break; case 238: this.$ = {order:$$[$0]}; break; case 239: this.$ = "SUM"; break; case 240: this.$ = "COUNT"; break; case 241: this.$ = "MIN"; break; case 242: this.$ = "MAX"; break; case 243: this.$ = "AVG"; break; case 244: this.$ = "FIRST"; break; case 245: this.$ = "LAST"; break; case 246: this.$ = "AGGR"; break; case 247: this.$ = "ARRAY"; break; case 248: if(alasql.aggr[$$[$0-3]]) { this.$ = new yy.AggrValue({aggregatorid: 'REDUCE', funcid: $$[$0-3], expression: $$[$0-1].pop() }); } else { this.$ = new yy.FuncValue({funcid: $$[$0-3], args: $$[$0-1]}); }; break; case 249: this.$ = new yy.FuncValue({ funcid: $$[$0-2] }) break; case 251: $$[$0-2].push($$[$0]); this.$ = $$[$0-2] break; case 252: this.$ = new yy.NumValue({value:+$$[$0]}); break; case 253: this.$ = new yy.LogicValue({value:true}); break; case 254: this.$ = new yy.LogicValue({value:false}); break; case 255: this.$ = new yy.StringValue({value: $$[$0].substr(1,$$[$0].length-2).replace(/(\\\')/g,"'").replace(/(\'\')/g,"'")}); break; case 256: this.$ = new yy.StringValue({value: $$[$0].substr(2,$$[$0].length-3).replace(/(\\\')/g,"'").replace(/(\'\')/g,"'")}); break; case 257: this.$ = new yy.NullValue({value:undefined}); break; case 258: this.$ = new yy.VarValue({variable:$$[$0]}); break; case 259: if(!yy.exists) yy.exists = []; this.$ = new yy.ExistsValue({value:$$[$0-1], existsidx:yy.exists.length}); yy.exists.push($$[$0-1]); break; case 260: case 261: this.$ = new yy.ParamValue({param: $$[$0]}); break; case 262: if(typeof yy.question == 'undefined') yy.question = 0; this.$ = new yy.ParamValue({param: yy.question++}); break; case 263: if(typeof yy.question == 'undefined') yy.question = 0; this.$ = new yy.ParamValue({param: yy.question++, array:true}); break; case 264: this.$ = new yy.CaseValue({expression:$$[$0-3], whens: $$[$0-2], elses: $$[$0-1]}); break; case 265: this.$ = new yy.CaseValue({whens: $$[$0-2], elses: $$[$0-1]}); break; case 266: case 540: case 541: this.$ = $$[$0-1]; this.$.push($$[$0]); break; case 268: this.$ = {when: $$[$0-2], then: $$[$0] }; break; case 271: this.$ = new yy.Op({left:$$[$0-2], op:'LIKE', right:$$[$0]}); break; case 272: this.$ = new yy.Op({left:$$[$0-2], op:'NOT LIKE', right:$$[$0] }); break; case 273: this.$ = new yy.Op({left:$$[$0-2], op:'+', right:$$[$0]}); break; case 274: this.$ = new yy.Op({left:$$[$0-2], op:'-', right:$$[$0]}); break; case 275: this.$ = new yy.Op({left:$$[$0-2], op:'*', right:$$[$0]}); break; case 276: this.$ = new yy.Op({left:$$[$0-2], op:'/', right:$$[$0]}); break; case 277: this.$ = new yy.Op({left:$$[$0-2], op:'%', right:$$[$0]}); break; case 278: this.$ = new yy.Op({left:$$[$0-2], op:'^', right:$$[$0]}); break; case 279: case 280: case 282: this.$ = new yy.Op({left:$$[$0-2], op:'->' , right:$$[$0]}); break; case 281: this.$ = new yy.Op({left:$$[$0-4], op:'->' , right:$$[$0-1]}); break; case 283: this.$ = new yy.Op({left:$$[$0-2], op:'>' , right:$$[$0]}); break; case 284: this.$ = new yy.Op({left:$$[$0-2], op:'>=' , right:$$[$0]}); break; case 285: this.$ = new yy.Op({left:$$[$0-2], op:'<' , right:$$[$0]}); break; case 286: this.$ = new yy.Op({left:$$[$0-2], op:'<=' , right:$$[$0]}); break; case 287: this.$ = new yy.Op({left:$$[$0-2], op:'=' , right:$$[$0]}); break; case 288: this.$ = new yy.Op({left:$$[$0-2], op:'==' , right:$$[$0]}); break; case 289: this.$ = new yy.Op({left:$$[$0-2], op:'===' , right:$$[$0]}); break; case 290: this.$ = new yy.Op({left:$$[$0-2], op:'!=' , right:$$[$0]}); break; case 291: this.$ = new yy.Op({left:$$[$0-2], op:'!==' , right:$$[$0]}); break; case 292: this.$ = new yy.Op({left:$$[$0-2], op:'!===' , right:$$[$0]}); break; case 293: if(!yy.queries) yy.queries = []; this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1], queriesidx: yy.queries.length}); yy.queries.push($$[$0-1]); break; case 294: this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1]}); break; case 295: this.$ = new yy.Op({left:$$[$0-2], op:'AND' , right:$$[$0]}); break; case 296: this.$ = new yy.Op({left:$$[$0-2], op:'OR' , right:$$[$0]}); break; case 297: this.$ = new yy.UniOp({op:'NOT' , right:$$[$0]}); break; case 298: this.$ = new yy.UniOp({op:'-' , right:$$[$0]}); break; case 299: this.$ = new yy.UniOp({op:'+' , right:$$[$0]}); break; case 300: this.$ = new yy.UniOp({right: $$[$0-1]}); break; case 301: if(!yy.queries) yy.queries = []; this.$ = new yy.Op({left: $$[$0-4], op:'IN', right:$$[$0-1], queriesidx: yy.queries.length}); yy.queries.push($$[$0-1]); break; case 302: if(!yy.queries) yy.queries = []; this.$ = new yy.Op({left: $$[$0-5], op:'NOT IN', right:$$[$0-1], queriesidx: yy.queries.length}); yy.queries.push($$[$0-1]); break; case 303: this.$ = new yy.Op({left: $$[$0-4], op:'IN', right:$$[$0-1]}); break; case 304: this.$ = new yy.Op({left: $$[$0-5], op:'NOT IN', right:$$[$0-1]}); break; case 305: this.$ = new yy.Op({left: $$[$0-3], op:'IN', right:[]}); break; case 306: this.$ = new yy.Op({left: $$[$0-4], op:'NOT IN', right:[]}); break; case 307: this.$ = new yy.Op({left: $$[$0-2], op:'IN', right:$$[$0]}); break; case 308: this.$ = new yy.Op({left: $$[$0-3], op:'NOT IN', right:$$[$0]}); break; case 309: this.$ = new yy.Op({left:$$[$0-2], op:'BETWEEN', right:$$[$0] }); break; case 310: this.$ = new yy.Op({left:$$[$0-2], op:'NOT BETWEEN', right:$$[$0] }); break; case 311: this.$ = new yy.Op({op:'IS' , left:$$[$0-2], right:$$[$0]}); break; case 312: this.$ = new yy.Convert({expression:$$[$0-2]}) ; yy.extend(this.$,$$[$0]) ; break; case 313: case 314: this.$ = $$[$0]; break; case 315: this.$ = $$[$0-1]; break; case 322: this.$ = 'ALL'; break; case 323: this.$ = 'SOME'; break; case 324: this.$ = 'ANY'; break; case 325: this.$ = new yy.Update({table:$$[$0-4], columns:$$[$0-2], where:$$[$0]}); break; case 326: this.$ = new yy.Update({table:$$[$0-2], columns:$$[$0]}); break; case 329: this.$ = new yy.SetColumn({columnid:$$[$0-2], expression:$$[$0]}) break; case 330: this.$ = new yy.Delete({table:$$[$0-2], where:$$[$0]}); break; case 331: this.$ = new yy.Delete({table:$$[$0]}); break; case 332: this.$ = new yy.Insert({into:$$[$0-2], values: $$[$0]}); break; case 333: this.$ = new yy.Insert({into:$$[$0-2], default: true}) ; break; case 334: this.$ = new yy.Insert({into:$$[$0-5], columns: $$[$0-3], values: $$[$0]}); break; case 335: this.$ = new yy.Insert({into:$$[$0-1], select: $$[$0]}); break; case 336: this.$ = new yy.Insert({into:$$[$0-4], columns: $$[$0-2], select: $$[$0]}); break; case 339: this.$ = [$$[$0-1]]; break; case 342: this.$ = $$[$0-4]; $$[$0-4].push($$[$0-1]) break; case 343: case 344: case 346: case 354: this.$ = $$[$0-2]; $$[$0-2].push($$[$0]) break; case 355: this.$ = new yy.CreateTable({table:$$[$0-4]}); //yy.extend(this.$,$$[$0-6]); yy.extend(this.$,$$[$0-5]); yy.extend(this.$,$$[$0-2]); break; case 356: this.$ = new yy.CreateTable({table:$$[$0]}); break; case 366: case 367: this.$ = {temporary:true}; break; case 369: this.$ = {ifnotexists: true}; break; case 370: this.$ = {columns: $$[$0-2], constraints: $$[$0]}; break; case 371: this.$ = {columns: $$[$0]}; break; case 372: this.$ = {as: $$[$0]} break; case 373: case 396: this.$ = [$$[$0]]; break; case 374: case 397: case 500: case 505: case 525: case 529: $$[$0-2].push($$[$0]); this.$ = $$[$0-2]; break; case 375: case 376: case 377: case 378: case 379: $$[$0].constraintid = $$[$0-1]; this.$ = $$[$0]; break; case 382: this.$ = {type: 'CHECK', expression: $$[$0-1]}; break; case 383: this.$ = {type: 'PRIMARY KEY', columns: $$[$0-1]}; break; case 384: this.$ = {type: 'FOREIGN KEY', columns: $$[$0-7], fktableid: $$[$0-4], fkcolumns: $$[$0-2]}; break; case 398: this.$ = new yy.ColumnDef({columnid:$$[$0-2]}); yy.extend(this.$,$$[$0-1]); yy.extend(this.$,$$[$0]); break; case 399: this.$ = new yy.ColumnDef({columnid:$$[$0-1]}); yy.extend(this.$,$$[$0]); break; case 400: this.$ = new yy.ColumnDef({columnid:$$[$0], dbtypeid: ''}); break; case 401: this.$ = {dbtypeid: $$[$0-5], dbsize: +$$[$0-3], dbprecision: +$$[$0-1]} break; case 402: this.$ = {dbtypeid: $$[$0-3], dbsize: +$$[$0-1]} break; case 403: this.$ = {dbtypeid: $$[$0]} break; case 404: this.$ = {dbtypeid: 'ENUM', enumvalues: $$[$0-1]} break; case 405: this.$ = undefined break; case 407: yy.extend($$[$0-1],$$[$0]); this.$ = $$[$0-1]; break; case 409: this.$ = {primarykey:true}; break; case 410: case 411: this.$ = {foreignkey:{tableid:$$[$0-3], columnid: $$[$0-1]}}; break; case 412: this.$ = {auto_increment:true}; break; case 413: this.$ = {identity: [$$[$0-3],$$[$0-1]]} break; case 414: this.$ = {identity: [1,1]} break; case 415: this.$ = {default:$$[$0]}; break; case 416: this.$ = {null:true}; break; case 417: this.$ = {notnull:true}; break; case 418: this.$ = $$[$0]; break; case 419: this.$ = new yy.DropTable({table:$$[$0]}); yy.extend(this.$, $$[$0-1]); break; case 421: this.$ = {ifexists: true}; break; case 422: this.$ = new yy.AlterTable({table:$$[$0-3], renameto: $$[$0]}); break; case 423: this.$ = new yy.AlterTable({table:$$[$0-3], addcolumn: $$[$0]}); break; case 424: this.$ = new yy.AlterTable({table:$$[$0-3], modifycolumn: $$[$0]}); break; case 425: this.$ = new yy.AlterTable({table:$$[$0-5], renamecolumn: $$[$0-2], to: $$[$0]}); break; case 426: this.$ = new yy.AlterTable({table:$$[$0-3], dropcolumn: $$[$0]}); break; case 427: this.$ = new yy.AlterTable({table:$$[$0-2], renameto: $$[$0]}); break; case 428: this.$ = new yy.AttachDatabase({databaseid:$$[$0], engineid:$$[$0-2].toUpperCase() }); break; case 429: this.$ = new yy.AttachDatabase({databaseid:$$[$0-3], engineid:$$[$0-5].toUpperCase(), args:$$[$0-1] }); break; case 430: this.$ = new yy.AttachDatabase({databaseid:$$[$0-2], engineid:$$[$0-4].toUpperCase(), as:$$[$0] }); break; case 431: this.$ = new yy.AttachDatabase({databaseid:$$[$0-5], engineid:$$[$0-7].toUpperCase(), as:$$[$0], args:$$[$0-3]}); break; case 432: this.$ = new yy.DetachDatabase({databaseid:$$[$0]}); break; case 433: this.$ = new yy.CreateDatabase({databaseid:$$[$0] }); yy.extend(this.$,$$[$0]); break; case 434: this.$ = new yy.CreateDatabase({engineid:$$[$0-4].toUpperCase(), databaseid:$$[$0-1], as:$$[$0] }); yy.extend(this.$,$$[$0-2]); break; case 435: this.$ = new yy.CreateDatabase({engineid:$$[$0-7].toUpperCase(), databaseid:$$[$0-4], args:$$[$0-2], as:$$[$0] }); yy.extend(this.$,$$[$0-5]); break; case 436: this.$ = new yy.CreateDatabase({engineid:$$[$0-4].toUpperCase(), as:$$[$0], args:[$$[$0-1]] }); yy.extend(this.$,$$[$0-2]); break; case 437: this.$ = undefined; break; case 438: case 471: case 489: case 492: case 509: this.$ = $$[$0-1]; break; case 439: case 440: this.$ = new yy.UseDatabase({databaseid: $$[$0] }); break; case 441: this.$ = new yy.DropDatabase({databaseid: $$[$0] }); yy.extend(this.$,$$[$0-1]); break; case 442: case 443: this.$ = new yy.DropDatabase({databaseid: $$[$0], engineid:$$[$0-3].toUpperCase() }); yy.extend(this.$,$$[$0-1]); break; case 444: this.$ = new yy.CreateIndex({indexid:$$[$0-5], table:$$[$0-3], columns:$$[$0-1]}) break; case 445: this.$ = new yy.CreateIndex({indexid:$$[$0-5], table:$$[$0-3], columns:$