From 54d3f4fe77ad6795b6f9b45d1d2ab487bd43c33f Mon Sep 17 00:00:00 2001 From: John Wehr Date: Wed, 11 Jul 2018 09:04:00 -0400 Subject: [PATCH 1/2] Keep decimal point in numbers specified as floats/doubles. (#2) * Keep decimal point in numbers specified as floats. --- index.js | 4 +++- lib/ast.js | 16 ++++++++++++---- lib/parse.js | 8 ++++---- lib/stringify.js | 5 +++-- package.json | 2 +- peg/sqlparser.pegjs | 8 ++++---- test/unit/select.test.js | 11 ++++++++++- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 28a224c..8b5986c 100644 --- a/index.js +++ b/index.js @@ -2,4 +2,6 @@ * node-sqlparser: index.js * Create : 2014-05-21 18:05:12 */ -module.exports = require('./lib/ast'); \ No newline at end of file +exports.AST = require('./lib/ast'); +exports.parse = require('./lib/parse').parse; +exports.stringify = require('./lib/stringify'); \ No newline at end of file diff --git a/lib/ast.js b/lib/ast.js index b5b55a0..1024590 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -1,17 +1,25 @@ -var parse = require('./parser'); +/** + * @class AST Helper + */ +var parse = require('./parse').parse; var stringify = require('./stringify'); function AST(ast) { this.ast = ast; } -AST.parse = parse; -AST.stringify = stringify; - AST.prototype = { + /** + * parse sql string to ast object + * @param {String} sql + */ parse: function (sql) { this.ast = parse(sql); }, + /** + * stringify ast object to sql + * @return {String} sql + */ stringify: function () { return stringify(this.ast); }, diff --git a/lib/parse.js b/lib/parse.js index c1810d1..0e1debe 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -458,10 +458,10 @@ module.exports = (function() { value: n } }, - peg$c153 = function(int_, frac, exp) { return parseFloat(int_ + frac + exp); }, - peg$c154 = function(int_, frac) { return parseFloat(int_ + frac); }, - peg$c155 = function(int_, exp) { return parseFloat(int_ + exp); }, - peg$c156 = function(int_) { return parseFloat(int_); }, + peg$c153 = function(int_, frac, exp) { var x = parseFloat(int_ + frac + exp); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"}, + peg$c154 = function(int_, frac) { var x = parseFloat(int_ + frac); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"}, + peg$c155 = function(int_, exp) { return parseFloat(int_ + exp).toString(); }, + peg$c156 = function(int_) { return parseFloat(int_).toString(); }, peg$c157 = function(digit19, digits) { return digit19 + digits; }, peg$c158 = function(op, digit19, digits) { return "-" + digit19 + digits; }, peg$c159 = function(op, digit) { return "-" + digit; }, diff --git a/lib/stringify.js b/lib/stringify.js index 403f4da..fa3e626 100644 --- a/lib/stringify.js +++ b/lib/stringify.js @@ -141,8 +141,6 @@ function columnRefToSQL(e) { } } -exports.exprToSQL = exprToSQL; - function exprToSQL(e) { var t = e.type; var res ; @@ -438,3 +436,6 @@ module.exports = function (ast, opt) { } return res; }; + +module.exports.exprToSQL = exprToSQL; + diff --git a/package.json b/package.json index bf44242..99ff559 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ ], "name": "node-sqlparser", "description": "a sql parser for node.js", - "version": "1.0.0", + "version": "1.0.4", "repository": { "url": "git://github.com/alibaba/nquery.git" }, diff --git a/peg/sqlparser.pegjs b/peg/sqlparser.pegjs index 3d6c6a2..e25bcd3 100644 --- a/peg/sqlparser.pegjs +++ b/peg/sqlparser.pegjs @@ -816,10 +816,10 @@ literal_int "LITERAL INT" } number - = int_:int frac:frac exp:exp __ { return parseFloat(int_ + frac + exp); } - / int_:int frac:frac __ { return parseFloat(int_ + frac); } - / int_:int exp:exp __ { return parseFloat(int_ + exp); } - / int_:int __ { return parseFloat(int_); } + = int_:int frac:frac exp:exp __ { var x = parseFloat(int_ + frac + exp); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"} + / int_:int frac:frac __ { var x = parseFloat(int_ + frac); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"} + / int_:int exp:exp __ { return parseFloat(int_ + exp).toString(); } + / int_:int __ { return parseFloat(int_).toString(); } int = digit19:digit19 digits:digits { return digit19 + digits; } diff --git a/test/unit/select.test.js b/test/unit/select.test.js index f0c8037..4eda38c 100644 --- a/test/unit/select.test.js +++ b/test/unit/select.test.js @@ -13,7 +13,7 @@ describe('SQL select', function () { describe('check selected fields', function () { it('should return ok when simple fields', function () { - var sql = 'select custom(abc), def from a.tablename where custom(id) in (1, 2, 2, 3) and c = ?'; + var sql = 'select custom(abc), def from a.tablename where custom(id) in (1.0, 2.1, 2, 3) and c = ?'; var result = parser.parse(sql); var resSql = stringify(result); expect(result) @@ -28,6 +28,15 @@ describe('SQL select', function () { .type('select') .columns(['sum(abc,1)', 'def']); }); + it('should keep decimals in floats', function () { + var sql = 'select a from b where x = 1.0'; + var result = parser.parse(sql); + var resSql = stringify(result); + expect(result) + .type('select') + .columns(['a']); + resSql.toLowerCase().should.equal(sql); + }); it('should ok when limit 10', function () { var sql = 'select a from b limit 10'; var result = parser.parse(sql); From 897f295fcd4e96ff96f1bdf285e916c6c24352ac Mon Sep 17 00:00:00 2001 From: "jianxun.zxl" Date: Thu, 12 Jul 2018 15:49:14 +0800 Subject: [PATCH 2/2] feat: delete & create table --- Makefile | 10 +- lib/parse.js | 8092 -------------------------------------- package.json | 9 +- peg/sqlparser.pegjs | 132 +- test/unit/create.test.js | 22 + 5 files changed, 150 insertions(+), 8115 deletions(-) create mode 100644 test/unit/create.test.js diff --git a/Makefile b/Makefile index db10d34..b60763a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ TESTS = test/unit/*.js REPORTER = spec install: - @npm install . - @./node_modules/pegjs/bin/pegjs peg/sqlparser.pegjs ./lib/parse.js -test: clean install - @npm install - @./node_modules/mocha/bin/mocha -r should $(TESTS) --reporter spec + @npm install + @./node_modules/pegjs/bin/pegjs -o ./lib/parse.js ./peg/sqlparser.pegjs +test: install + @./node_modules/mocha/bin/mocha -r should $(TESTS) --reporter spec clean: + rm -rf ./node_modules .PHONY: test diff --git a/lib/parse.js b/lib/parse.js index 0e1debe..e69de29 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1,8092 +0,0 @@ -module.exports = (function() { - /* - * Generated by PEG.js 0.8.0. - * - * http://pegjs.majda.cz/ - */ - - function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - } - - function SyntaxError(message, expected, found, offset, line, column) { - this.message = message; - this.expected = expected; - this.found = found; - this.offset = offset; - this.line = line; - this.column = column; - - this.name = "SyntaxError"; - } - - peg$subclass(SyntaxError, Error); - - function parse(input) { - var options = arguments.length > 1 ? arguments[1] : {}, - - peg$FAILED = {}, - - peg$startRuleFunctions = { start: peg$parsestart }, - peg$startRuleFunction = peg$parsestart, - - peg$c0 = peg$FAILED, - peg$c1 = function(ast) { - ast.params = params; - return ast; - }, - peg$c2 = function(ast) { - return ast; - }, - peg$c3 = [], - peg$c4 = function(head, tail) { - var cur = head; - for (var i = 0; i < tail.length; i++) { - cur._next = tail[i][3]; - cur = cur._next - } - return head; - }, - peg$c5 = "(", - peg$c6 = { type: "literal", value: "(", description: "\"(\"" }, - peg$c7 = ")", - peg$c8 = { type: "literal", value: ")", description: "\")\"" }, - peg$c9 = function(s) { - return s[2]; - }, - peg$c10 = null, - peg$c11 = function(d, c, f, w, g, o, l) { - return { - type : 'select', - distinct : d, - columns : c, - from : f, - where : w, - groupby : g, - orderby : o, - limit : l - } - }, - peg$c12 = { type: "other", description: "column_clause" }, - peg$c13 = void 0, - peg$c14 = function() { - return '*'; - }, - peg$c15 = function(head, tail) { - return createList(head, tail); - }, - peg$c16 = function(e, alias) { - return { - expr : e, - as : alias - }; - }, - peg$c17 = function(i) { return i; }, - peg$c18 = function(l) { return l; }, - peg$c19 = function(head, tail) { - tail.unshift(head); - return tail; - }, - peg$c20 = function(t) { return t; }, - peg$c21 = function(op, t, expr) { - t.join = op; - t.on = expr; - return t; - /* - return { - db : t.db, - table : t.table, - as : t.as, - join : op, - on : expr - } - */ - }, - peg$c22 = function(t, alias) { - if (t.type == 'var') { - t.as = alias; - return t; - } else { - return { - db : t.db, - table : t.table, - as : alias - } - } - }, - peg$c23 = function() { return 'LEFT JOIN'; }, - peg$c24 = function() { return 'INNER JOIN'; }, - peg$c25 = function(dt, tail) { - var obj = { - db : '', - table : dt - } - if (tail) { - obj.db = dt; - obj.table = tail[3]; - } - return obj; - }, - peg$c26 = function(v) { - v.db = ''; - v.table = v.name; - return v; - }, - peg$c27 = function(e) { return e; }, - peg$c28 = function(e, d) { - var obj = { - expr : e, - type : 'ASC' - } - if (d == 'DESC') { - obj.type = 'DESC'; - } - return obj; - }, - peg$c29 = function(i1, tail) { - var res = [i1]; - if (!tail) { - res.unshift({ - type : 'number', - value : 0 - }); - } else { - res.push(tail[2]); - } - return res; - }, - peg$c30 = function(t, l, w) { - return { - type : 'update', - db : t.db, - table : t.table, - set : l, - where : w - } - }, - peg$c31 = "=", - peg$c32 = { type: "literal", value: "=", description: "\"=\"" }, - peg$c33 = function(c, v) { - return { - column: c, - value : v - } - }, - peg$c34 = function(ri, t, c, v) { - return { - type : ri, - db : t.db, - table : t.table, - columns : c, - values : v - } - }, - peg$c35 = function() { return 'insert'; }, - peg$c36 = function() { return 'replace' }, - peg$c37 = function(l) { - return l; - }, - peg$c38 = function(head, tail) { - var el = { - type : 'expr_list' - } - - var l = createExprList(head, tail, el); - - el.value = l; - return el; - }, - peg$c39 = function() { - return { - type : 'expr_list', - value : [] - } - }, - peg$c40 = function(head, tail) { - return createBinaryExprChain(head, tail); - }, - peg$c41 = "!", - peg$c42 = { type: "literal", value: "!", description: "\"!\"" }, - peg$c43 = function(expr) { - return createUnaryExpr('NOT', expr); - }, - peg$c44 = function(left, rh) { - if (!rh) { - return left; - } else { - var res = null; - if (rh.type == 'arithmetic') { - res = createBinaryExprChain(left, rh.tail); - } else { - res = createBinaryExpr(rh.op, left, rh.right); - } - return res; - } - }, - peg$c45 = function(l) { - return { - type : 'arithmetic', - tail : l - } - }, - peg$c46 = ">=", - peg$c47 = { type: "literal", value: ">=", description: "\">=\"" }, - peg$c48 = ">", - peg$c49 = { type: "literal", value: ">", description: "\">\"" }, - peg$c50 = "<=", - peg$c51 = { type: "literal", value: "<=", description: "\"<=\"" }, - peg$c52 = "<>", - peg$c53 = { type: "literal", value: "<>", description: "\"<>\"" }, - peg$c54 = "<", - peg$c55 = { type: "literal", value: "<", description: "\"<\"" }, - peg$c56 = "!=", - peg$c57 = { type: "literal", value: "!=", description: "\"!=\"" }, - peg$c58 = function(op, right) { - return { - op : op, - right : right - } - }, - peg$c59 = function(op, begin, end) { - return { - op : op, - right : { - type : 'expr_list', - value : [begin, end] - } - } - }, - peg$c60 = function(nk) { return nk[0] + ' ' + nk[2]; }, - peg$c61 = function(op, l) { - return { - op : op, - right : l - } - }, - peg$c62 = function(op, e) { - return { - op : op, - right : e - } - }, - peg$c63 = "+", - peg$c64 = { type: "literal", value: "+", description: "\"+\"" }, - peg$c65 = "-", - peg$c66 = { type: "literal", value: "-", description: "\"-\"" }, - peg$c67 = function(head, tail) { - return createBinaryExprChain(head, tail) - }, - peg$c68 = "*", - peg$c69 = { type: "literal", value: "*", description: "\"*\"" }, - peg$c70 = "/", - peg$c71 = { type: "literal", value: "/", description: "\"/\"" }, - peg$c72 = "%", - peg$c73 = { type: "literal", value: "%", description: "\"%\"" }, - peg$c74 = function(e) { - e.paren = true; - return e; - }, - peg$c75 = function(tbl, col) { - return { - type : 'column_ref', - table : tbl, - column : col - }; - }, - peg$c76 = function(col) { - return { - type : 'column_ref', - table : '', - column: col - }; - }, - peg$c77 = function(name) { return reservedMap[name.toUpperCase()] === true; }, - peg$c78 = function(name) { - return name; - }, - peg$c79 = "`", - peg$c80 = { type: "literal", value: "`", description: "\"`\"" }, - peg$c81 = /^[^`]/, - peg$c82 = { type: "class", value: "[^`]", description: "[^`]" }, - peg$c83 = function(chars) { - return chars.join(''); - }, - peg$c84 = function(start, parts) { return start + parts.join(''); }, - peg$c85 = /^[A-Za-z_]/, - peg$c86 = { type: "class", value: "[A-Za-z_]", description: "[A-Za-z_]" }, - peg$c87 = /^[A-Za-z0-9_]/, - peg$c88 = { type: "class", value: "[A-Za-z0-9_]", description: "[A-Za-z0-9_]" }, - peg$c89 = /^[A-Za-z0-9_:]/, - peg$c90 = { type: "class", value: "[A-Za-z0-9_:]", description: "[A-Za-z0-9_:]" }, - peg$c91 = { type: "other", description: "PARAM[:param, ?]" }, - peg$c92 = ":", - peg$c93 = { type: "literal", value: ":", description: "\":\"" }, - peg$c94 = "?", - peg$c95 = { type: "literal", value: "?", description: "\"?\"" }, - peg$c96 = function(l) { - var p = { - type : 'param', - value: l.length > 1 ? l[1] : l[0] - }; - //var key = 'L' + line + 'C' + column; - //debug(key); - //params[key] = p; - params.push(p); - return p; - }, - peg$c97 = function(name, e) { - return { - type : 'aggr_func', - name : name, - args : { - expr : e - } - } - }, - peg$c98 = /^[0-9a-zA-Z_]/, - peg$c99 = { type: "class", value: "[0-9a-zA-Z_]", description: "[0-9a-zA-Z_]" }, - peg$c100 = function(w) {return w.join('');}, - peg$c101 = function(name, arg) { - return { - type : 'aggr_func', - name : name, - args : arg - } - }, - peg$c102 = function(e) { - return { - expr : e - } - }, - peg$c103 = function(d, c) { - return { - distinct : d, - expr : c - } - }, - peg$c104 = function() { - return { - type : 'star', - value : '*' - } - }, - peg$c105 = function(name, l) { - return { - type : 'function', - name : name, - args : l - } - }, - peg$c106 = function() { - return { - type : 'null', - value : null - }; - }, - peg$c107 = function() { - return { - type : 'bool', - value : true - }; - }, - peg$c108 = function() { - return { - type : 'bool', - value : false - }; - }, - peg$c109 = "\"", - peg$c110 = { type: "literal", value: "\"", description: "\"\\\"\"" }, - peg$c111 = "'", - peg$c112 = { type: "literal", value: "'", description: "\"'\"" }, - peg$c113 = function(ca) { - return { - type : 'string', - value : ca[1].join('') - } - }, - peg$c114 = /^[^'\\\0-\x1F]/, - peg$c115 = { type: "class", value: "[^'\\\\\\0-\\x1F]", description: "[^'\\\\\\0-\\x1F]" }, - peg$c116 = /^[^"\\\0-\x1F]/, - peg$c117 = { type: "class", value: "[^\"\\\\\\0-\\x1F]", description: "[^\"\\\\\\0-\\x1F]" }, - peg$c118 = "\\'", - peg$c119 = { type: "literal", value: "\\'", description: "\"\\\\'\"" }, - peg$c120 = function() { return "'"; }, - peg$c121 = "\\\"", - peg$c122 = { type: "literal", value: "\\\"", description: "\"\\\\\\\"\"" }, - peg$c123 = function() { return '"'; }, - peg$c124 = "\\\\", - peg$c125 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, - peg$c126 = function() { return "\\"; }, - peg$c127 = "\\/", - peg$c128 = { type: "literal", value: "\\/", description: "\"\\\\/\"" }, - peg$c129 = function() { return "/"; }, - peg$c130 = "\\b", - peg$c131 = { type: "literal", value: "\\b", description: "\"\\\\b\"" }, - peg$c132 = function() { return "\b"; }, - peg$c133 = "\\f", - peg$c134 = { type: "literal", value: "\\f", description: "\"\\\\f\"" }, - peg$c135 = function() { return "\f"; }, - peg$c136 = "\\n", - peg$c137 = { type: "literal", value: "\\n", description: "\"\\\\n\"" }, - peg$c138 = function() { return "\n"; }, - peg$c139 = "\\r", - peg$c140 = { type: "literal", value: "\\r", description: "\"\\\\r\"" }, - peg$c141 = function() { return "\r"; }, - peg$c142 = "\\t", - peg$c143 = { type: "literal", value: "\\t", description: "\"\\\\t\"" }, - peg$c144 = function() { return "\t"; }, - peg$c145 = "\\u", - peg$c146 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, - peg$c147 = function(h1, h2, h3, h4) { - return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - }, - peg$c148 = /^[\n\r]/, - peg$c149 = { type: "class", value: "[\\n\\r]", description: "[\\n\\r]" }, - peg$c150 = function(n) { - return { - type : 'number', - value : n - } - }, - peg$c151 = { type: "other", description: "LITERAL INT" }, - peg$c152 = function(n) { - return { - type: 'number', - value: n - } - }, - peg$c153 = function(int_, frac, exp) { var x = parseFloat(int_ + frac + exp); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"}, - peg$c154 = function(int_, frac) { var x = parseFloat(int_ + frac); return (x % 1 != 0) ? x.toString() : x.toString() + ".0"}, - peg$c155 = function(int_, exp) { return parseFloat(int_ + exp).toString(); }, - peg$c156 = function(int_) { return parseFloat(int_).toString(); }, - peg$c157 = function(digit19, digits) { return digit19 + digits; }, - peg$c158 = function(op, digit19, digits) { return "-" + digit19 + digits; }, - peg$c159 = function(op, digit) { return "-" + digit; }, - peg$c160 = ".", - peg$c161 = { type: "literal", value: ".", description: "\".\"" }, - peg$c162 = function(digits) { return "." + digits; }, - peg$c163 = function(e, digits) { return e + digits; }, - peg$c164 = function(digits) { return digits.join(""); }, - peg$c165 = { type: "other", description: "NUMBER" }, - peg$c166 = /^[0-9]/, - peg$c167 = { type: "class", value: "[0-9]", description: "[0-9]" }, - peg$c168 = /^[1-9]/, - peg$c169 = { type: "class", value: "[1-9]", description: "[1-9]" }, - peg$c170 = { type: "other", description: "HEX" }, - peg$c171 = /^[0-9a-fA-F]/, - peg$c172 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, - peg$c173 = /^[eE]/, - peg$c174 = { type: "class", value: "[eE]", description: "[eE]" }, - peg$c175 = /^[+\-]/, - peg$c176 = { type: "class", value: "[+\\-]", description: "[+\\-]" }, - peg$c177 = function(e, sign) { return e + sign; }, - peg$c178 = "null", - peg$c179 = { type: "literal", value: "NULL", description: "\"NULL\"" }, - peg$c180 = "true", - peg$c181 = { type: "literal", value: "TRUE", description: "\"TRUE\"" }, - peg$c182 = "false", - peg$c183 = { type: "literal", value: "FALSE", description: "\"FALSE\"" }, - peg$c184 = "show", - peg$c185 = { type: "literal", value: "SHOW", description: "\"SHOW\"" }, - peg$c186 = "drop", - peg$c187 = { type: "literal", value: "DROP", description: "\"DROP\"" }, - peg$c188 = "select", - peg$c189 = { type: "literal", value: "SELECT", description: "\"SELECT\"" }, - peg$c190 = "update", - peg$c191 = { type: "literal", value: "UPDATE", description: "\"UPDATE\"" }, - peg$c192 = "create", - peg$c193 = { type: "literal", value: "CREATE", description: "\"CREATE\"" }, - peg$c194 = "delete", - peg$c195 = { type: "literal", value: "DELETE", description: "\"DELETE\"" }, - peg$c196 = "insert", - peg$c197 = { type: "literal", value: "INSERT", description: "\"INSERT\"" }, - peg$c198 = "replace", - peg$c199 = { type: "literal", value: "REPLACE", description: "\"REPLACE\"" }, - peg$c200 = "explain", - peg$c201 = { type: "literal", value: "EXPLAIN", description: "\"EXPLAIN\"" }, - peg$c202 = "into", - peg$c203 = { type: "literal", value: "INTO", description: "\"INTO\"" }, - peg$c204 = "from", - peg$c205 = { type: "literal", value: "FROM", description: "\"FROM\"" }, - peg$c206 = "set", - peg$c207 = { type: "literal", value: "SET", description: "\"SET\"" }, - peg$c208 = "as", - peg$c209 = { type: "literal", value: "AS", description: "\"AS\"" }, - peg$c210 = "table", - peg$c211 = { type: "literal", value: "TABLE", description: "\"TABLE\"" }, - peg$c212 = "on", - peg$c213 = { type: "literal", value: "ON", description: "\"ON\"" }, - peg$c214 = "left", - peg$c215 = { type: "literal", value: "LEFT", description: "\"LEFT\"" }, - peg$c216 = "inner", - peg$c217 = { type: "literal", value: "INNER", description: "\"INNER\"" }, - peg$c218 = "join", - peg$c219 = { type: "literal", value: "JOIN", description: "\"JOIN\"" }, - peg$c220 = "union", - peg$c221 = { type: "literal", value: "UNION", description: "\"UNION\"" }, - peg$c222 = "values", - peg$c223 = { type: "literal", value: "VALUES", description: "\"VALUES\"" }, - peg$c224 = "exists", - peg$c225 = { type: "literal", value: "EXISTS", description: "\"EXISTS\"" }, - peg$c226 = "where", - peg$c227 = { type: "literal", value: "WHERE", description: "\"WHERE\"" }, - peg$c228 = "group", - peg$c229 = { type: "literal", value: "GROUP", description: "\"GROUP\"" }, - peg$c230 = "by", - peg$c231 = { type: "literal", value: "BY", description: "\"BY\"" }, - peg$c232 = "order", - peg$c233 = { type: "literal", value: "ORDER", description: "\"ORDER\"" }, - peg$c234 = "having", - peg$c235 = { type: "literal", value: "HAVING", description: "\"HAVING\"" }, - peg$c236 = "limit", - peg$c237 = { type: "literal", value: "LIMIT", description: "\"LIMIT\"" }, - peg$c238 = "asc", - peg$c239 = { type: "literal", value: "ASC", description: "\"ASC\"" }, - peg$c240 = function() { return 'ASC'; }, - peg$c241 = "desc", - peg$c242 = { type: "literal", value: "DESC", description: "\"DESC\"" }, - peg$c243 = function() { return 'DESC'; }, - peg$c244 = "all", - peg$c245 = { type: "literal", value: "ALL", description: "\"ALL\"" }, - peg$c246 = function() { return 'ALL'; }, - peg$c247 = "distinct", - peg$c248 = { type: "literal", value: "DISTINCT", description: "\"DISTINCT\"" }, - peg$c249 = function() { return 'DISTINCT';}, - peg$c250 = "between", - peg$c251 = { type: "literal", value: "BETWEEN", description: "\"BETWEEN\"" }, - peg$c252 = function() { return 'BETWEEN'; }, - peg$c253 = "in", - peg$c254 = { type: "literal", value: "IN", description: "\"IN\"" }, - peg$c255 = function() { return 'IN'; }, - peg$c256 = "is", - peg$c257 = { type: "literal", value: "IS", description: "\"IS\"" }, - peg$c258 = function() { return 'IS'; }, - peg$c259 = "like", - peg$c260 = { type: "literal", value: "LIKE", description: "\"LIKE\"" }, - peg$c261 = function() { return 'LIKE'; }, - peg$c262 = "contains", - peg$c263 = { type: "literal", value: "CONTAINS", description: "\"CONTAINS\"" }, - peg$c264 = function() { return 'CONTAINS';}, - peg$c265 = "not", - peg$c266 = { type: "literal", value: "NOT", description: "\"NOT\"" }, - peg$c267 = function() { return 'NOT'; }, - peg$c268 = "and", - peg$c269 = { type: "literal", value: "AND", description: "\"AND\"" }, - peg$c270 = function() { return 'AND'; }, - peg$c271 = "or", - peg$c272 = { type: "literal", value: "OR", description: "\"OR\"" }, - peg$c273 = function() { return 'OR'; }, - peg$c274 = "count", - peg$c275 = { type: "literal", value: "COUNT", description: "\"COUNT\"" }, - peg$c276 = function() { return 'COUNT'; }, - peg$c277 = "max", - peg$c278 = { type: "literal", value: "MAX", description: "\"MAX\"" }, - peg$c279 = function() { return 'MAX'; }, - peg$c280 = "min", - peg$c281 = { type: "literal", value: "MIN", description: "\"MIN\"" }, - peg$c282 = function() { return 'MIN'; }, - peg$c283 = "sum", - peg$c284 = { type: "literal", value: "SUM", description: "\"SUM\"" }, - peg$c285 = function() { return 'SUM'; }, - peg$c286 = "avg", - peg$c287 = { type: "literal", value: "AVG", description: "\"AVG\"" }, - peg$c288 = function() { return 'AVG'; }, - peg$c289 = ",", - peg$c290 = { type: "literal", value: ",", description: "\",\"" }, - peg$c291 = "[", - peg$c292 = { type: "literal", value: "[", description: "\"[\"" }, - peg$c293 = "]", - peg$c294 = { type: "literal", value: "]", description: "\"]\"" }, - peg$c295 = { type: "any", description: "any character" }, - peg$c296 = { type: "other", description: "WHITE_SPACE" }, - peg$c297 = /^[ \t\n\r]/, - peg$c298 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" }, - peg$c299 = { type: "other", description: "EOF" }, - peg$c300 = function(s) { - return { - stmt : s, - vars: varList - } - }, - peg$c301 = function() { varList = []; return true; }, - peg$c302 = function(va, e) { - return { - type : 'assign', - left : va, - right: e - } - }, - peg$c303 = function(e) { - return { - type : 'return', - expr: e - } - }, - peg$c304 = function(lt, op, rt, expr) { - return { - type : 'join', - ltable : lt, - rtable : rt, - op : op, - on : expr - } - }, - peg$c305 = function(name, l) { - //compatible with original func_call - return { - type : 'function', - name : name, - args : { - type : 'expr_list', - value : l - } - } - }, - peg$c306 = function(l) { - return { - type : 'array', - value : l - } - }, - peg$c307 = function(name, m) { - //push for analysis - varList.push(name); - return { - type : 'var', - name : name, - members : m - } - }, - peg$c308 = function(l) { - var s = []; - for (var i = 0; i < l.length; i++) { - s.push(l[i][1]); - } - return s; - }, - peg$c309 = "$", - peg$c310 = { type: "literal", value: "$", description: "\"$\"" }, - peg$c311 = "return", - peg$c312 = { type: "literal", value: "return", description: "\"return\"" }, - peg$c313 = ":=", - peg$c314 = { type: "literal", value: ":=", description: "\":=\"" }, - - peg$currPos = 0, - peg$reportedPos = 0, - peg$cachedPos = 0, - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, - peg$maxFailPos = 0, - peg$maxFailExpected = [], - peg$silentFails = 0, - - peg$result; - - if ("startRule" in options) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$reportedPos, peg$currPos); - } - - function offset() { - return peg$reportedPos; - } - - function line() { - return peg$computePosDetails(peg$reportedPos).line; - } - - function column() { - return peg$computePosDetails(peg$reportedPos).column; - } - - function expected(description) { - throw peg$buildException( - null, - [{ type: "other", description: description }], - peg$reportedPos - ); - } - - function error(message) { - throw peg$buildException(message, null, peg$reportedPos); - } - - function peg$computePosDetails(pos) { - function advance(details, startPos, endPos) { - var p, ch; - - for (p = startPos; p < endPos; p++) { - ch = input.charAt(p); - if (ch === "\n") { - if (!details.seenCR) { details.line++; } - details.column = 1; - details.seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - details.line++; - details.column = 1; - details.seenCR = true; - } else { - details.column++; - details.seenCR = false; - } - } - } - - if (peg$cachedPos !== pos) { - if (peg$cachedPos > pos) { - peg$cachedPos = 0; - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; - } - advance(peg$cachedPosDetails, peg$cachedPos, pos); - peg$cachedPos = pos; - } - - return peg$cachedPosDetails; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildException(message, expected, pos) { - function cleanupExpected(expected) { - var i = 1; - - expected.sort(function(a, b) { - if (a.description < b.description) { - return -1; - } else if (a.description > b.description) { - return 1; - } else { - return 0; - } - }); - - while (i < expected.length) { - if (expected[i - 1] === expected[i]) { - expected.splice(i, 1); - } else { - i++; - } - } - } - - function buildMessage(expected, found) { - function stringEscape(s) { - function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } - - return s - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\x08/g, '\\b') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\f/g, '\\f') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) - .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) - .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); - } - - var expectedDescs = new Array(expected.length), - expectedDesc, foundDesc, i; - - for (i = 0; i < expected.length; i++) { - expectedDescs[i] = expected[i].description; - } - - expectedDesc = expected.length > 1 - ? expectedDescs.slice(0, -1).join(", ") - + " or " - + expectedDescs[expected.length - 1] - : expectedDescs[0]; - - foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; - - return "Expected " + expectedDesc + " but " + foundDesc + " found."; - } - - var posDetails = peg$computePosDetails(pos), - found = pos < input.length ? input.charAt(pos) : null; - - if (expected !== null) { - cleanupExpected(expected); - } - - return new SyntaxError( - message !== null ? message : buildMessage(expected, found), - expected, - found, - pos, - posDetails.line, - posDetails.column - ); - } - - function peg$parsestart() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$parseunion_stmt(); - if (s2 === peg$FAILED) { - s2 = peg$parseupdate_stmt(); - if (s2 === peg$FAILED) { - s2 = peg$parsereplace_insert_stmt(); - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c1(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseproc_stmts(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c2(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseunion_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseselect_stmt(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_UNION(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_UNION(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c4(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseselect_stmt() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$parseselect_stmt_nake(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s2 = peg$c5; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c6); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseselect_stmt(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s6 = peg$c7; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c8); } - } - if (s6 !== peg$FAILED) { - s2 = [s2, s3, s4, s5, s6]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c9(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseselect_stmt_nake() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$currPos; - s1 = peg$parseKW_SELECT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_DISTINCT(); - if (s3 === peg$FAILED) { - s3 = peg$c10; - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsecolumn_clause(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsefrom_clause(); - if (s7 === peg$FAILED) { - s7 = peg$c10; - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parsewhere_clause(); - if (s9 === peg$FAILED) { - s9 = peg$c10; - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parsegroup_by_clause(); - if (s11 === peg$FAILED) { - s11 = peg$c10; - } - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (s12 !== peg$FAILED) { - s13 = peg$parseorder_by_clause(); - if (s13 === peg$FAILED) { - s13 = peg$c10; - } - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - if (s14 !== peg$FAILED) { - s15 = peg$parselimit_clause(); - if (s15 === peg$FAILED) { - s15 = peg$c10; - } - if (s15 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c11(s3, s5, s7, s9, s11, s13, s15); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsecolumn_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - peg$silentFails++; - s0 = peg$currPos; - s1 = peg$parseKW_ALL(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - s2 = peg$parseSTAR(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseident_start(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c13; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c14(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn_list_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c12); } - } - - return s0; - } - - function peg$parsecolumn_list_item() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseadditive_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsealias_clause(); - if (s3 === peg$FAILED) { - s3 = peg$c10; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c16(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsealias_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 === peg$FAILED) { - s1 = peg$c10; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseident(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c17(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsefrom_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_FROM(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsetable_ref_list(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c18(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsetable_ref_list() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsetable_base(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsetable_ref(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsetable_ref(); - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c19(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsetable_ref() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$parseCOMMA(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parsetable_base(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c20(s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$parsetable_join(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c20(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parsetable_join() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsetable_base(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseon_clause(); - if (s5 === peg$FAILED) { - s5 = peg$c10; - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c21(s1, s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsetable_base() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsetable_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_AS(); - if (s3 === peg$FAILED) { - s3 = peg$c10; - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseident(); - if (s5 === peg$FAILED) { - s5 = peg$c10; - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c22(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsejoin_op() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_LEFT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_JOIN(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c23(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_INNER(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 === peg$FAILED) { - s1 = peg$c10; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseKW_JOIN(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c24(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parsetable_name() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseident_name(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c10; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c25(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c26(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseon_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseor_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c27(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsewhere_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_WHERE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseor_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c27(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsegroup_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_GROUP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsecolumn_ref_list(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c18(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsecolumn_ref_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn_ref(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsehaving_clause() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseKW_HAVING(); - if (s1 !== peg$FAILED) { - s2 = peg$parseor_expr(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c27(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseorder_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_ORDER(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseorder_by_list(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c18(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseorder_by_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseorder_by_element(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseorder_by_element() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseor_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_DESC(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_ASC(); - } - if (s3 === peg$FAILED) { - s3 = peg$c10; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c28(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsenumber_or_param() { - var s0; - - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - } - - return s0; - } - - function peg$parseint_or_param() { - var s0; - - s0 = peg$parseliteral_int(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - } - - return s0; - } - - function peg$parselimit_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_LIMIT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseint_or_param(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - s6 = peg$parseCOMMA(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseint_or_param(); - if (s8 !== peg$FAILED) { - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - if (s5 === peg$FAILED) { - s5 = peg$c10; - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c29(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseupdate_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_UPDATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsetable_name(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_SET(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseset_list(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parsewhere_clause(); - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c30(s3, s7, s9); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseset_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseset_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseset_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsecolumn_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c31; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_expr(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c33(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsereplace_insert_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$parsereplace_insert(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_INTO(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsetable_name(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parsecolumn_list(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (s12 !== peg$FAILED) { - s13 = peg$parsevalue_clause(); - if (s13 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c34(s1, s5, s9, s13); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsereplace_insert() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_INSERT(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c35(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_REPLACE(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c36(); - } - s0 = s1; - } - - return s0; - } - - function peg$parsevalue_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_VALUES(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsevalue_list(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c18(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsevalue_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevalue_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsevalue_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseexpr_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c37(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseexpr_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseor_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseor_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseor_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c38(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseexpr_list_or_empty() { - var s0, s1; - - s0 = peg$parseexpr_list(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = []; - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c39(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseor_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseand_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseand_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsenot_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsenot_expr() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseKW_NOT(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 33) { - s2 = peg$c41; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c31; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c13; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsenot_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c43(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parsecomparison_expr(); - } - - return s0; - } - - function peg$parsecomparison_expr() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseadditive_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsecomparison_op_right(); - if (s3 === peg$FAILED) { - s3 = peg$c10; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c44(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsecomparison_op_right() { - var s0; - - s0 = peg$parsearithmetic_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsein_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsebetween_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parseis_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parselike_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsecontains_op_right(); - } - } - } - } - } - - return s0; - } - - function peg$parsearithmetic_op_right() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } - } else { - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c45(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsearithmetic_comparison_operator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c46) { - s0 = peg$c46; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c47); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 62) { - s0 = peg$c48; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c50) { - s0 = peg$c50; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c52) { - s0 = peg$c52; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c53); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 60) { - s0 = peg$c54; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c55); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s0 = peg$c31; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c56) { - s0 = peg$c56; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c57); } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseis_op_right() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_IS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c58(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsebetween_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_BETWEEN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseadditive_expr(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c59(s1, s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parselike_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseKW_LIKE(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c60(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_LIKE(); - } - - return s0; - } - - function peg$parsein_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseKW_IN(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c60(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_IN(); - } - - return s0; - } - - function peg$parsecontains_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseKW_CONTAINS(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c60(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CONTAINS(); - } - - return s0; - } - - function peg$parselike_op_right() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parselike_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsecomparison_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c58(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsein_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c61(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsevar_decl(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c62(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parsecontains_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecontains_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c61(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecontains_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsevar_decl(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c62(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseadditive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsemultiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseadditive_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 43) { - s0 = peg$c63; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 45) { - s0 = peg$c65; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } - } - } - - return s0; - } - - function peg$parsemultiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseprimary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c67(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsemultiplicative_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c68; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s0 = peg$c70; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 37) { - s0 = peg$c72; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } - } - } - } - - return s0; - } - - function peg$parseprimary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggr_func(); - if (s0 === peg$FAILED) { - s0 = peg$parsefunc_call(); - if (s0 === peg$FAILED) { - s0 = peg$parsecolumn_ref(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseor_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c74(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - } - } - } - } - } - } - - return s0; - } - - function peg$parsecolumn_ref() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsecolumn(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c75(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c76(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsecolumn_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseident() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$reportedPos = peg$currPos; - s2 = peg$c77(s1); - if (s2) { - s2 = peg$c0; - } else { - s2 = peg$c13; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c78(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsecolumn() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsecolumn_name(); - if (s1 !== peg$FAILED) { - peg$reportedPos = peg$currPos; - s2 = peg$c77(s1); - if (s2) { - s2 = peg$c0; - } else { - s2 = peg$c13; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c78(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 96) { - s1 = peg$c79; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c80); } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$c81.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$c81.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - } - } else { - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 96) { - s3 = peg$c79; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c80); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c83(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parsecolumn_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsecolumn_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsecolumn_part(); - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c84(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseident_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseident_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseident_part(); - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c84(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseident_start() { - var s0; - - if (peg$c85.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c86); } - } - - return s0; - } - - function peg$parseident_part() { - var s0; - - if (peg$c87.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c88); } - } - - return s0; - } - - function peg$parsecolumn_part() { - var s0; - - if (peg$c89.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c90); } - } - - return s0; - } - - function peg$parseparam() { - var s0, s1, s2; - - peg$silentFails++; - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c92; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseident_name(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 63) { - s1 = peg$c94; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c95); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c96(s1); - } - s0 = s1; - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } - } - - return s0; - } - - function peg$parseaggr_func() { - var s0; - - s0 = peg$parseaggr_fun_count(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggr_fun_smma(); - } - - return s0; - } - - function peg$parseaggr_fun_smma() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_SUM_MAX_MIN_AVG(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_expr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c97(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_SUM_MAX_MIN_AVG() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - if (peg$c98.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c99); } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - if (peg$c98.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c99); } - } - } - } else { - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c100(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseaggr_fun_count() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_COUNT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsecount_arg(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c101(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsecount_arg() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsestar_expr(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c102(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 === peg$FAILED) { - s1 = peg$c10; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsecolumn_ref(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c103(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parsestar_expr() { - var s0, s1; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 42) { - s1 = peg$c68; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c104(); - } - s0 = s1; - - return s0; - } - - function peg$parsefunc_call() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseexpr_list_or_empty(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c105(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseliteral() { - var s0; - - s0 = peg$parseliteral_string(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_bool(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_null(); - } - } - } - - return s0; - } - - function peg$parseliteral_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseliteral(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseliteral_null() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_NULL(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c106(); - } - s0 = s1; - - return s0; - } - - function peg$parseliteral_bool() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_TRUE(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c107(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_FALSE(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c108(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseliteral_string() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c109; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c110); } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsedouble_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsedouble_char(); - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s4 = peg$c109; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c110); } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 === peg$FAILED) { - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c111; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c112); } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_char(); - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c111; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c112); } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c113(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsesingle_char() { - var s0; - - if (peg$c114.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c115); } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parsedouble_char() { - var s0; - - if (peg$c116.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c117); } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parseescape_char() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c118) { - s1 = peg$c118; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c119); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c120(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c121) { - s1 = peg$c121; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c122); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c123(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c124) { - s1 = peg$c124; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c125); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c126(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c127) { - s1 = peg$c127; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c128); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c129(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c130) { - s1 = peg$c130; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c131); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c132(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c133) { - s1 = peg$c133; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c134); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c135(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c136) { - s1 = peg$c136; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c137); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c138(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c139) { - s1 = peg$c139; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c140); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c141(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c142) { - s1 = peg$c142; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c143); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c144(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c145) { - s1 = peg$c145; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c146); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsehexDigit(); - if (s2 !== peg$FAILED) { - s3 = peg$parsehexDigit(); - if (s3 !== peg$FAILED) { - s4 = peg$parsehexDigit(); - if (s4 !== peg$FAILED) { - s5 = peg$parsehexDigit(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c147(s2, s3, s4, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseline_terminator() { - var s0; - - if (peg$c148.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c149); } - } - - return s0; - } - - function peg$parseliteral_numeric() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parsenumber(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c150(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseliteral_int() { - var s0, s1; - - peg$silentFails++; - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c152(s1); - } - s0 = s1; - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c151); } - } - - return s0; - } - - function peg$parsenumber() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - s3 = peg$parseexp(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c153(s1, s2, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c154(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parseexp(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c155(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c156(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parseint() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsedigit19(); - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c157(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parsedigit(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c65; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c63; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigit19(); - if (s2 !== peg$FAILED) { - s3 = peg$parsedigits(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c158(s1, s2, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c65; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c63; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c159(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parsefrac() { - var s0, s1, s2; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s1 = peg$c160; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c161); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c162(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseexp() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsee(); - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c163(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsedigits() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsedigit(); - } - } else { - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c164(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsedigit() { - var s0, s1; - - peg$silentFails++; - if (peg$c166.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c167); } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c165); } - } - - return s0; - } - - function peg$parsedigit19() { - var s0, s1; - - peg$silentFails++; - if (peg$c168.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c169); } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c165); } - } - - return s0; - } - - function peg$parsehexDigit() { - var s0, s1; - - peg$silentFails++; - if (peg$c171.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c172); } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c170); } - } - - return s0; - } - - function peg$parsee() { - var s0, s1, s2; - - s0 = peg$currPos; - if (peg$c173.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c174); } - } - if (s1 !== peg$FAILED) { - if (peg$c175.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c176); } - } - if (s2 === peg$FAILED) { - s2 = peg$c10; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c177(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_NULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c178) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c179); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_TRUE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c180) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c181); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_FALSE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c182) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c183); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_SHOW() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c184) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c185); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_DROP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c186) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c187); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_SELECT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c188) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c189); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_UPDATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c190) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c191); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_CREATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c192) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c193); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_DELETE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c194) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c195); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_INSERT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c196) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c197); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_REPLACE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c198) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c199); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_EXPLAIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c200) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c201); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_INTO() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c202) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c203); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_FROM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c204) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c205); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_SET() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c206) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c207); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_AS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c208) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c209); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_TABLE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c210) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c211); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_ON() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c212) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c213); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_LEFT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c214) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c215); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_INNER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c216) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c217); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_JOIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c218) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c219); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_UNION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c220) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c221); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_VALUES() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c222) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c223); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_EXISTS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c224) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c225); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_WHERE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c226) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c227); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_GROUP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c228) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c229); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_BY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c230) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c231); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_ORDER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c232) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c233); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_HAVING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c234) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c235); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_LIMIT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c236) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c237); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_ASC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c238) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c239); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c240(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_DESC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c241) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c243(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_ALL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c244) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c245); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c246(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_DISTINCT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c247) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_BETWEEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c250) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c251); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c252(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_IN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c253) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c254); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c255(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_IS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c256) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c257); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c258(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_LIKE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c259) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c260); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c261(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_CONTAINS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c262) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c263); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c264(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_NOT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c265) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c266); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c267(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_AND() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c268) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c269); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c270(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_OR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c271) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c272); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c273(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_COUNT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c274) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c275); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c276(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_MAX() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c277) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c278); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c279(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_MIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c280) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c281); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c282(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_SUM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c283) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c284); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c285(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseKW_AVG() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c286) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c287); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c13; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c288(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDOT() { - var s0; - - if (input.charCodeAt(peg$currPos) === 46) { - s0 = peg$c160; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c161); } - } - - return s0; - } - - function peg$parseCOMMA() { - var s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c289; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c290); } - } - - return s0; - } - - function peg$parseSTAR() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c68; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } - } - - return s0; - } - - function peg$parseLPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 40) { - s0 = peg$c5; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c6); } - } - - return s0; - } - - function peg$parseRPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 41) { - s0 = peg$c7; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c8); } - } - - return s0; - } - - function peg$parseLBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 91) { - s0 = peg$c291; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c292); } - } - - return s0; - } - - function peg$parseRBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 93) { - s0 = peg$c293; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c294); } - } - - return s0; - } - - function peg$parse__() { - var s0, s1; - - s0 = []; - s1 = peg$parsewhitespace(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsewhitespace(); - } - - return s0; - } - - function peg$parsechar() { - var s0; - - if (input.length > peg$currPos) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c295); } - } - - return s0; - } - - function peg$parsewhitespace() { - var s0, s1; - - peg$silentFails++; - if (peg$c297.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c298); } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c296); } - } - - return s0; - } - - function peg$parseEOL() { - var s0, s1; - - peg$silentFails++; - s0 = peg$parseEOF(); - if (s0 === peg$FAILED) { - s0 = []; - if (peg$c148.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c149); } - } - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - if (peg$c148.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c149); } - } - } - } else { - s0 = peg$c0; - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c299); } - } - - return s0; - } - - function peg$parseEOF() { - var s0, s1; - - s0 = peg$currPos; - peg$silentFails++; - if (input.length > peg$currPos) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c295); } - } - peg$silentFails--; - if (s1 === peg$FAILED) { - s0 = peg$c13; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_stmts() { - var s0, s1; - - s0 = []; - s1 = peg$parseproc_stmt(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseproc_stmt(); - } - - return s0; - } - - function peg$parseproc_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseproc_init(); - peg$silentFails--; - if (s2 !== peg$FAILED) { - peg$currPos = s1; - s1 = peg$c13; - } else { - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseassign_stmt(); - if (s3 === peg$FAILED) { - s3 = peg$parsereturn_stmt(); - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c300(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_init() { - var s0, s1; - - s0 = peg$currPos; - s1 = []; - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c301(); - } - s0 = s1; - - return s0; - } - - function peg$parseassign_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_ASSIGN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseproc_expr(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c302(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsereturn_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_RETURN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseproc_expr(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c303(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_expr() { - var s0; - - s0 = peg$parseselect_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_join(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_additive_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_array(); - } - } - } - - return s0; - } - - function peg$parseproc_additive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_multiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_multiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_join() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsejoin_op(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parsevar_decl(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseon_clause(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c304(s1, s3, s5, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_primary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_func_call(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseproc_additive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c74(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - } - - return s0; - } - - function peg$parseproc_func_call() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseproc_primary_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c305(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_primary_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseproc_array() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLBRAKE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseproc_primary_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c306(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsevar_decl() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_VAR_PRE(); - if (s1 !== peg$FAILED) { - s2 = peg$parseident_name(); - if (s2 !== peg$FAILED) { - s3 = peg$parsemem_chain(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c307(s2, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsemem_chain() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c160; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c161); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c160; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c161); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c308(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseKW_VAR_PRE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 36) { - s0 = peg$c309; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c310); } - } - - return s0; - } - - function peg$parseKW_RETURN() { - var s0; - - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c311) { - s0 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c312); } - } - - return s0; - } - - function peg$parseKW_ASSIGN() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c313) { - s0 = peg$c313; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c314); } - } - - return s0; - } - - - var util; - var inspect = function(){}; - if (module && process && process.env) { - util = require('util'); - inspect = function (obj) { - console.log(util.inspect(obj, false, 10)); - } - } - function debug(str) { - console.log(str); - } - - function createUnaryExpr(op, e) { - return { - type : 'unary_expr', - operator : op, - expr : e - } - } - - function createBinaryExpr(op, left, right) { - return { - type : 'binary_expr', - operator : op, - left : left, - right : right - } - } - - function createList(head, tail) { - var result = [head]; - for (var i = 0; i < tail.length; i++) { - result.push(tail[i][3]); - } - return result; - } - - function createExprList(head, tail, room) { - var epList = createList(head, tail); - var exprList = []; - var ep; - for (var i = 0; i < epList.length; i++) { - ep = epList[i]; - //the ep has already added to the global params - if (ep.type == 'param') { - ep.room = room; - ep.pos = i; - } else { - exprList.push(ep); - } - } - return exprList; - } - - function createBinaryExprChain(head, tail) { - var result = head; - for (var i = 0; i < tail.length; i++) { - result = createBinaryExpr(tail[i][1], result, tail[i][3]); - } - return result; - } - - var reservedMap = { - 'SHOW' : true, - 'DROP' : true, - 'SELECT' : true, - 'UPDATE' : true, - 'CREATE' : true, - 'DELETE' : true, - 'INSERT' : true, - 'REPLACE' : true, - 'EXPLAIN' : true, - 'ALL' : true, - 'DISTINCT': true, - 'AS' : true, - 'TABLE' : true, - 'INTO' : true, - 'FROM' : true, - 'SET' : true, - 'LEFT' : true, - 'ON' : true, - 'INNER' : true, - 'JOIN' : true, - 'UNION' : true, - 'VALUES' : true, - 'EXISTS' : true, - 'WHERE' : true, - 'GROUP' : true, - 'BY' : true, - 'HAVING' : true, - 'ORDER' : true, - 'ASC' : true, - 'DESC' : true, - 'LIMIT' : true, - 'BETWEEN' : true, - 'IN' : true, - 'IS' : true, - 'LIKE' : true, - 'CONTAINS': true, - 'NOT' : true, - 'AND' : true, - 'OR' : true, - - //literal - 'TRUE' : true, - 'FALSE' : true, - 'NULL' : true - } - - var cmpPrefixMap = { - '+' : true, - '-' : true, - '*' : true, - '/' : true, - '>' : true, - '<' : true, - '!' : true, - '=' : true, - - //between - 'B' : true, - 'b' : true, - //for is or in - 'I' : true, - 'i' : true, - //for like - 'L' : true, - 'l' : true, - //for not - 'N' : true, - 'n' : true, - //for contains - 'C' : true, - 'c' : true, - } - - //used for store refered parmas - var params = []; - - //used for dependency analysis - var varList = []; - - - peg$result = peg$startRuleFunction(); - - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail({ type: "end", description: "end of input" }); - } - - throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); - } - } - - return { - SyntaxError: SyntaxError, - parse: parse - }; -})(); diff --git a/package.json b/package.json index 99ff559..a727fa0 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,11 @@ "engines": { "node": ">=0.8.0" }, - "dependencies": { - }, + "dependencies": {}, "devDependencies": { - "pegjs": "=0.8.0", + "pegjs": "0.10.0", "mocha": ">=1.0.0", - "should":">=1.2.0" + "should": ">=1.2.0" }, "readmeFilename": "README.md", "main": "index.js", @@ -32,5 +31,5 @@ "sql ast", "custom sql" ], - "license": "GPLv2" + "license": "GPL-2.0" } diff --git a/peg/sqlparser.pegjs b/peg/sqlparser.pegjs index e25bcd3..108f869 100644 --- a/peg/sqlparser.pegjs +++ b/peg/sqlparser.pegjs @@ -11,14 +11,6 @@ */ { - var util; - var inspect = function(){}; - if (module && process && process.env) { - util = require('util'); - inspect = function (obj) { - console.log(util.inspect(obj, false, 10)); - } - } function debug(str) { console.log(str); } @@ -155,7 +147,13 @@ } start - = __ ast:(union_stmt / update_stmt / replace_insert_stmt) { + = __ ast:( + union_stmt / + update_stmt / + delete_stmt / + replace_insert_stmt / + create_table_stmt + ) { ast.params = params; return ast; } @@ -173,6 +171,113 @@ union_stmt return head; } +create_table_stmt + = KW_CREATE __ KW_TABLE __ (KW_IF __ KW_NOT __ KW_EXISTS __) ? + tb: table_name __ '(' __ + clist:columns_defs + __ ')' __ topt:table_options? __ popt:partition_options? __ ';'? __? { + return { + type: 'create_table', + name: tb, + columns: clist, + tableOptions: topt, + partitionOptions: popt + } + } + +columns_defs + = h:column_def t:(__ COMMA __ column_def)* { + return createList(h, t); + } + +column_def + = index_def / + ( + n:column __ + t:column_type + e:(__ (literal/ident_name))* { + let ext = []; + e.forEach((v) => { + ext.push(v[1]); + }); + return { + name: n, + type: t, + ext: ext + } + } + ) + +column_type + = ct: (func_call/ident) { + if (ct.type === 'function') { + let args = []; + ct.args.value.forEach((v) => { + args.push(v.value); + }); + return { + type: ct.name, + args: args + } + } else { + return {type: ct} + } + } + + table_options + = h:table_option t:(__ table_option)* { + let res = h; + t.forEach((v) => { + let tmp = v[1]; + let keys = Object.keys(tmp) + keys.forEach((k) => { + res[k] = tmp[k].column; + }); + }); + return res; + } + + table_option + = k:primary __ '='? __ v:primary { + let obj = {}; + let key = k.type === 'column_ref' ? k.column : k.value; + let value = v.type === 'column_ref' ? v.column : v.value; + obj[key] = value; + return obj; + } + +partition_options + = h:primary t:(__ primary)* { + let res = [h]; + t.forEach((v) => { + res.push(v); + }); + return res; + } + +index_def + = f:$(ident_name* __ ('KEY'i/'INDEX'i)) __ n:column __ '(' l: column_clause ')'{ + let list = []; + l.forEach((v) => { + list.push(v.expr.column) + }); + return { + type: f, + name: n, + columns: list + } + } + + +delete_stmt += KW_DELETE __ f:from_clause __ w:where_clause? { + return { + type: 'delete', + from: f, + where: w + } +} + select_stmt = select_stmt_nake / s:('(' __ select_stmt __ ')') { @@ -274,7 +379,7 @@ join_op / (KW_INNER __)? KW_JOIN { return 'INNER JOIN'; } table_name - = dt:ident tail:(__ DOT __ ident_name)? { + = '`'? dt:ident tail:(__ DOT __ ident_name)? '`'? { var obj = { db : '', table : dt @@ -429,12 +534,12 @@ expr_list expr_list_or_empty = l:expr_list - / { + / (''{ return { type : 'expr_list', value : [] } - } + }) /** * Borrowed from PL/SQL ,the priority of below list IS ORDER BY DESC @@ -874,6 +979,7 @@ KW_JOIN = "JOIN"i !ident_start KW_UNION = "UNION"i !ident_start KW_VALUES = "VALUES"i !ident_start +KW_IF = "IF"i !ident_start KW_EXISTS = "EXISTS"i !ident_start KW_WHERE = "WHERE"i !ident_start @@ -942,7 +1048,7 @@ proc_stmt } } -proc_init = { varList = []; return true; } +proc_init = '' { varList = []; return true; } assign_stmt = va:var_decl __ KW_ASSIGN __ e:proc_expr { diff --git a/test/unit/create.test.js b/test/unit/create.test.js new file mode 100644 index 0000000..237a475 --- /dev/null +++ b/test/unit/create.test.js @@ -0,0 +1,22 @@ +'use strict'; + +var parser = require('../../lib/parse'); +var stringify = require('../../lib/stringify'); +var expect = require('./expect'); +describe('SQL create', function () { + describe('create table simple', function () { + it.skip('should work fine when create table', function () { + var sql = ` + create table xxxx if not exists ( + a string comment 'xxx' + ); + `; + var result = parser.parse(sql); + var resSql = stringify(result); + expect(result) + .type('create') + .columns(['sum(abc,1)', 'def']); + resSql.toLowerCase().should.equal(sql); + }); + }); +});