From 4d3c998120435bd7f6ee0b73864834f163866ed1 Mon Sep 17 00:00:00 2001 From: HSunboy Date: Fri, 6 Jul 2018 16:58:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9E=84=E5=BB=BA=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=8D=87=E7=BA=A7peg=E4=B8=BA0.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/astParser.js | 16062 +++++++++++++++++++++----------------------- core/comment.js | 2069 +++--- package-lock.json | 6 +- package.json | 6 +- peg/build.js | 20 +- peg/nquery.pegjs | 2 +- 6 files changed, 8884 insertions(+), 9281 deletions(-) diff --git a/core/astParser.js b/core/astParser.js index 850d032..222a8f6 100644 --- a/core/astParser.js +++ b/core/astParser.js @@ -1,603 +1,180 @@ -module.exports = (function(){ - /* - * Generated by PEG.js 0.7.0. - * - * http://pegjs.majda.cz/ - */ - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - * - * For portability, we also escape escape all control and non-ASCII - * characters. Note that "\0" and "\v" escape sequences are not used - * because JSHint does not like the first and IE the second. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\x08/g, '\\b') // backspace - .replace(/\t/g, '\\t') // horizontal tab - .replace(/\n/g, '\\n') // line feed - .replace(/\f/g, '\\f') // form feed - .replace(/\r/g, '\\r') // carriage return - .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) - + '"'; +/* + * Generated by PEG.js 0.10.0. + * + * http://pegjs.org/ + */ +(function(root, factory) { + if (typeof define === "function" && define.amd) { + define([], factory); + } else if (typeof module === "object" && module.exports) { + module.exports = factory(); } - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - parse: function(input, startRule) { - var parseFunctions = { - "start": parse_start, - "init": parse_init, - "union_stmt": parse_union_stmt, - "select_stmt": parse_select_stmt, - "select_stmt_nake": parse_select_stmt_nake, - "column_clause": parse_column_clause, - "column_list_item": parse_column_list_item, - "alias_clause": parse_alias_clause, - "from_clause": parse_from_clause, - "table_ref_list": parse_table_ref_list, - "table_ref": parse_table_ref, - "table_join": parse_table_join, - "table_base": parse_table_base, - "join_op": parse_join_op, - "table_name": parse_table_name, - "on_clause": parse_on_clause, - "where_clause": parse_where_clause, - "group_by_clause": parse_group_by_clause, - "column_ref_list": parse_column_ref_list, - "having_clause": parse_having_clause, - "order_by_clause": parse_order_by_clause, - "order_by_list": parse_order_by_list, - "order_by_element": parse_order_by_element, - "number_or_param": parse_number_or_param, - "limit_clause": parse_limit_clause, - "update_stmt": parse_update_stmt, - "set_list": parse_set_list, - "set_item": parse_set_item, - "replace_insert_stmt": parse_replace_insert_stmt, - "replace_insert": parse_replace_insert, - "value_clause": parse_value_clause, - "value_list": parse_value_list, - "value_item": parse_value_item, - "expr_list": parse_expr_list, - "expr_list_or_empty": parse_expr_list_or_empty, - "or_expr": parse_or_expr, - "and_expr": parse_and_expr, - "not_expr": parse_not_expr, - "comparison_expr": parse_comparison_expr, - "comparison_op_right": parse_comparison_op_right, - "arithmetic_op_right": parse_arithmetic_op_right, - "arithmetic_comparison_operator": parse_arithmetic_comparison_operator, - "is_op_right": parse_is_op_right, - "between_op_right": parse_between_op_right, - "like_op": parse_like_op, - "in_op": parse_in_op, - "contains_op": parse_contains_op, - "like_op_right": parse_like_op_right, - "in_op_right": parse_in_op_right, - "contains_op_right": parse_contains_op_right, - "additive_expr": parse_additive_expr, - "additive_operator": parse_additive_operator, - "multiplicative_expr": parse_multiplicative_expr, - "multiplicative_operator": parse_multiplicative_operator, - "primary": parse_primary, - "column_ref": parse_column_ref, - "column_list": parse_column_list, - "ident": parse_ident, - "column": parse_column, - "column_name": parse_column_name, - "ident_name": parse_ident_name, - "ident_start": parse_ident_start, - "ident_part": parse_ident_part, - "column_part": parse_column_part, - "param": parse_param, - "aggr_func": parse_aggr_func, - "aggr_fun_smma": parse_aggr_fun_smma, - "KW_SUM_MAX_MIN_AVG": parse_KW_SUM_MAX_MIN_AVG, - "aggr_fun_count": parse_aggr_fun_count, - "count_arg": parse_count_arg, - "star_expr": parse_star_expr, - "func_call": parse_func_call, - "literal": parse_literal, - "literal_list": parse_literal_list, - "literal_null": parse_literal_null, - "literal_bool": parse_literal_bool, - "literal_string": parse_literal_string, - "single_char": parse_single_char, - "double_char": parse_double_char, - "escape_char": parse_escape_char, - "line_terminator": parse_line_terminator, - "literal_numeric": parse_literal_numeric, - "number": parse_number, - "int": parse_int, - "frac": parse_frac, - "exp": parse_exp, - "digits": parse_digits, - "digit": parse_digit, - "digit19": parse_digit19, - "hexDigit": parse_hexDigit, - "e": parse_e, - "KW_NULL": parse_KW_NULL, - "KW_TRUE": parse_KW_TRUE, - "KW_FALSE": parse_KW_FALSE, - "KW_SHOW": parse_KW_SHOW, - "KW_DROP": parse_KW_DROP, - "KW_SELECT": parse_KW_SELECT, - "KW_UPDATE": parse_KW_UPDATE, - "KW_CREATE": parse_KW_CREATE, - "KW_DELETE": parse_KW_DELETE, - "KW_INSERT": parse_KW_INSERT, - "KW_REPLACE": parse_KW_REPLACE, - "KW_EXPLAIN": parse_KW_EXPLAIN, - "KW_INTO": parse_KW_INTO, - "KW_FROM": parse_KW_FROM, - "KW_SET": parse_KW_SET, - "KW_AS": parse_KW_AS, - "KW_TABLE": parse_KW_TABLE, - "KW_ON": parse_KW_ON, - "KW_LEFT": parse_KW_LEFT, - "KW_INNER": parse_KW_INNER, - "KW_JOIN": parse_KW_JOIN, - "KW_UNION": parse_KW_UNION, - "KW_VALUES": parse_KW_VALUES, - "KW_EXISTS": parse_KW_EXISTS, - "KW_WHERE": parse_KW_WHERE, - "KW_GROUP": parse_KW_GROUP, - "KW_BY": parse_KW_BY, - "KW_ORDER": parse_KW_ORDER, - "KW_HAVING": parse_KW_HAVING, - "KW_LIMIT": parse_KW_LIMIT, - "KW_ASC": parse_KW_ASC, - "KW_DESC": parse_KW_DESC, - "KW_ALL": parse_KW_ALL, - "KW_DISTINCT": parse_KW_DISTINCT, - "KW_BETWEEN": parse_KW_BETWEEN, - "KW_IN": parse_KW_IN, - "KW_IS": parse_KW_IS, - "KW_LIKE": parse_KW_LIKE, - "KW_CONTAINS": parse_KW_CONTAINS, - "KW_NOT": parse_KW_NOT, - "KW_AND": parse_KW_AND, - "KW_OR": parse_KW_OR, - "KW_COUNT": parse_KW_COUNT, - "KW_MAX": parse_KW_MAX, - "KW_MIN": parse_KW_MIN, - "KW_SUM": parse_KW_SUM, - "KW_AVG": parse_KW_AVG, - "DOT": parse_DOT, - "COMMA": parse_COMMA, - "STAR": parse_STAR, - "LPAREN": parse_LPAREN, - "RPAREN": parse_RPAREN, - "LBRAKE": parse_LBRAKE, - "RBRAKE": parse_RBRAKE, - "__": parse___, - "char": parse_char, - "whitespace": parse_whitespace, - "EOL": parse_EOL, - "EOF": parse_EOF, - "proc_stmts": parse_proc_stmts, - "proc_stmt": parse_proc_stmt, - "proc_init": parse_proc_init, - "assign_stmt": parse_assign_stmt, - "return_stmt": parse_return_stmt, - "proc_expr": parse_proc_expr, - "proc_additive_expr": parse_proc_additive_expr, - "proc_multiplicative_expr": parse_proc_multiplicative_expr, - "proc_join": parse_proc_join, - "proc_primary": parse_proc_primary, - "proc_func_call": parse_proc_func_call, - "proc_primary_list": parse_proc_primary_list, - "proc_array": parse_proc_array, - "var_decl": parse_var_decl, - "mem_chain": parse_mem_chain, - "KW_VAR_PRE": parse_KW_VAR_PRE, - "KW_RETURN": parse_KW_RETURN, - "KW_ASSIGN": parse_KW_ASSIGN - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "start"; - } - - var pos = 0; - var reportFailures = 0; - var rightmostFailuresPos = 0; - var rightmostFailuresExpected = []; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; - } - - return result; - } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - var escapeChar; - var length; - - if (charCode <= 0xFF) { - escapeChar = 'x'; - length = 2; - } else { - escapeChar = 'u'; - length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); - } - - function matchFailed(failure) { - if (pos < rightmostFailuresPos) { - return; - } - - if (pos > rightmostFailuresPos) { - rightmostFailuresPos = pos; - rightmostFailuresExpected = []; - } - - rightmostFailuresExpected.push(failure); - } - - function parse_start() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - pos2 = pos; - reportFailures++; - result0 = parse_init(); - reportFailures--; - if (result0 !== null) { - result0 = ""; - pos = pos2; - } else { - result0 = null; - } - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_union_stmt(); - if (result2 === null) { - result2 = parse_update_stmt(); - if (result2 === null) { - result2 = parse_replace_insert_stmt(); - } +})(this, function() { + "use strict"; + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } + } + + peg$subclass(peg$SyntaxError, Error); + + peg$SyntaxError.buildMessage = function(expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + + "class": function(expectation) { + var escapedParts = "", + i; + + for (i = 0; i < expectation.parts.length; i++) { + escapedParts += expectation.parts[i] instanceof Array + ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) + : classEscape(expectation.parts[i]); } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + + any: function(expectation) { + return "any character"; + }, + + end: function(expectation) { + return "end of input"; + }, + + other: function(expectation) { + return expectation.description; + } + }; + + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + function literalEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } + + function classEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/\]/g, '\\]') + .replace(/\^/g, '\\^') + .replace(/-/g, '\\-') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + var descriptions = new Array(expected.length), + i, j; + + for (i = 0; i < expected.length; i++) { + descriptions[i] = describeExpectation(expected[i]); + } + + descriptions.sort(); + + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; } - } else { - result0 = null; - pos = pos1; } - if (result0 !== null) { - result0 = (function(offset, ast) { + descriptions.length = j; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + }; + + function peg$parse(input, options) { + options = options !== void 0 ? options : {}; + + var peg$FAILED = {}, + + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + + peg$c0 = function(ast) { return { ast : ast, param : params } - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - result0 = parse_proc_stmts(); - if (result0 !== null) { - result0 = (function(offset, ast) { - return { - ast : ast - } - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_init() { - var result0; - - result0 = (function(offset) { params = []; return true; })(pos) ? "" : null; - return result0; - } - - function parse_union_stmt() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_select_stmt(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_UNION(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_select_stmt(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; + }, + peg$c1 = function(ast) { + return { + ast : ast } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_UNION(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_select_stmt(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c2 = function() { params = []; return true; }, + peg$c3 = function(head, tail) { var cur = head; for (var i = 0; i < tail.length; i++) { cur._next = tail[i][3]; cur = cur._next } return head; - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_select_stmt() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - result0 = parse_select_stmt_nake(); - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_select_stmt(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 41) { - result4 = ")"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, s) { - console.log(s); - return s[2]; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_select_stmt_nake() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_SELECT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_DISTINCT(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_column_clause(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_from_clause(); - result6 = result6 !== null ? result6 : ""; - if (result6 !== null) { - result7 = parse___(); - if (result7 !== null) { - result8 = parse_where_clause(); - result8 = result8 !== null ? result8 : ""; - if (result8 !== null) { - result9 = parse___(); - if (result9 !== null) { - result10 = parse_group_by_clause(); - result10 = result10 !== null ? result10 : ""; - if (result10 !== null) { - result11 = parse___(); - if (result11 !== null) { - result12 = parse_order_by_clause(); - result12 = result12 !== null ? result12 : ""; - if (result12 !== null) { - result13 = parse___(); - if (result13 !== null) { - result14 = parse_limit_clause(); - result14 = result14 !== null ? result14 : ""; - if (result14 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, d, c, f, w, g, o, l) { + }, + peg$c4 = "(", + peg$c5 = peg$literalExpectation("(", false), + peg$c6 = ")", + peg$c7 = peg$literalExpectation(")", false), + peg$c8 = function(s) { + return s[2]; + }, + peg$c9 = function(d, c, f, w, g, o, l) { return { type : 'select', distinct : d, @@ -608,384 +185,27 @@ module.exports = (function(){ orderby : o, limit : l } - })(pos0, result0[2], result0[4], result0[6], result0[8], result0[10], result0[12], result0[14]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_column_clause() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - result0 = parse_KW_ALL(); - if (result0 === null) { - pos1 = pos; - result0 = parse_STAR(); - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } - if (result0 !== null) { - result0 = (function(offset) { + }, + peg$c10 = function() { return '*'; - })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_column_list_item(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column_list_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column_list_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_column_list_item() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_additive_expr(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_alias_clause(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e, alias) { + }, + peg$c11 = function(head, tail) { + return createList(head, tail); + }, + peg$c12 = function(e, alias) { return { expr : e, as : alias }; - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_alias_clause() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_AS(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_ident(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, i) { return i; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_from_clause() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_FROM(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_table_ref_list(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { return l; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_table_ref_list() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_table_base(); - if (result0 !== null) { - result1 = []; - result2 = parse_table_ref(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_table_ref(); - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c13 = function(i) { return i; }, + peg$c14 = function(l) { return l; }, + peg$c15 = function(head, tail) { tail.unshift(head); return tail; - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_table_ref() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse___(); - if (result0 !== null) { - result1 = parse_COMMA(); - if (result1 !== null) { - result2 = parse___(); - if (result2 !== null) { - result3 = parse_table_base(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, t) { return t; })(pos0, result0[3]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse___(); - if (result0 !== null) { - result1 = parse_table_join(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, t) { return t; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_table_join() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_join_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_table_base(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_on_clause(); - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, t, expr) { + }, + peg$c16 = function(t) { return t; }, + peg$c17 = function(op, t, expr) { t.join = op; t.on = expr; return t; @@ -998,55 +218,8 @@ module.exports = (function(){ on : expr } */ - })(pos0, result0[0], result0[2], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_table_base() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_table_name(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_AS(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_ident(); - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, t, alias) { + }, + peg$c18 = function(t, alias) { if (t.type == 'var') { t.as = alias; return t; @@ -1057,552 +230,27 @@ module.exports = (function(){ as : alias } } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_join_op() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_LEFT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_JOIN(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'LEFT JOIN'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - pos2 = pos; - result0 = parse_KW_INNER(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos2; - } - } else { - result0 = null; - pos = pos2; - } - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse_KW_JOIN(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'INNER JOIN'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_table_name() { - var result0, result1, result2, result3, result4; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident(); - if (result0 !== null) { - pos2 = pos; - result1 = parse___(); - if (result1 !== null) { - result2 = parse_DOT(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_ident_name(); - if (result4 !== null) { - result1 = [result1, result2, result3, result4]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, dt, tail) { + }, + peg$c19 = function() { return 'LEFT JOIN'; }, + peg$c20 = function() { return 'INNER JOIN'; }, + peg$c21 = function(dt, tail) { var obj = { db : '', table : dt } - if (tail != '') { + if (tail) { obj.db = dt; obj.table = tail[3]; } return obj; - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - result0 = parse_var_decl(); - if (result0 !== null) { - result0 = (function(offset, v) { - v.db = ''; - v.table = v.name; - return v; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_on_clause() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_ON(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_or_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { return e; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_where_clause() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_WHERE(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_or_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { return e; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_group_by_clause() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_GROUP(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_BY(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_column_ref_list(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { return l; })(pos0, result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_column_ref_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_column_ref(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column_ref(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column_ref(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_having_clause() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_HAVING(); - if (result0 !== null) { - result1 = parse_or_expr(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { return e; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_order_by_clause() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_ORDER(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_BY(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_order_by_list(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { return l; })(pos0, result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_order_by_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_order_by_element(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_order_by_element(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_order_by_element(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_order_by_element() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_or_expr(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_DESC(); - if (result2 === null) { - result2 = parse_KW_ASC(); - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e, d) { + }, + peg$c22 = function(v) { + v.db = ''; + v.table = v.name; + return v; + }, + peg$c23 = function(e) { return e; }, + peg$c24 = function(e, d) { var obj = { expr : e, type : 'ASC' @@ -1611,83 +259,8 @@ module.exports = (function(){ obj.type = 'DESC'; } return obj; - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_number_or_param() { - var result0; - - result0 = parse_literal_numeric(); - if (result0 === null) { - result0 = parse_param(); - } - return result0; - } - - function parse_limit_clause() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_LIMIT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_number_or_param(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - pos2 = pos; - result4 = parse_COMMA(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_number_or_param(); - if (result6 !== null) { - result4 = [result4, result5, result6]; - } else { - result4 = null; - pos = pos2; - } - } else { - result4 = null; - pos = pos2; - } - } else { - result4 = null; - pos = pos2; - } - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, i1, tail) { + }, + peg$c25 = function(i1, tail) { var res = [i1]; if (tail == '') { res.unshift({ @@ -1698,77 +271,8 @@ module.exports = (function(){ res.push(tail[2]); } return res; - })(pos0, result0[2], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_update_stmt() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_UPDATE(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_table_name(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_KW_SET(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_set_list(); - if (result6 !== null) { - result7 = parse___(); - if (result7 !== null) { - result8 = parse_where_clause(); - if (result8 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, t, l, w) { + }, + peg$c26 = function(t, l, w) { return { type : 'update', db : t.db, @@ -1776,245 +280,16 @@ module.exports = (function(){ set : l, where : w } - })(pos0, result0[2], result0[6], result0[8]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_set_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_set_item(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_set_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_set_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_set_item() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_column_name(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 61) { - result2 = "="; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_additive_expr(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, c, v) { + }, + peg$c27 = "=", + peg$c28 = peg$literalExpectation("=", false), + peg$c29 = function(c, v) { return { column: c, value : v } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_replace_insert_stmt() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_replace_insert(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_INTO(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_table_name(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_LPAREN(); - if (result6 !== null) { - result7 = parse___(); - if (result7 !== null) { - result8 = parse_column_list(); - if (result8 !== null) { - result9 = parse___(); - if (result9 !== null) { - result10 = parse_RPAREN(); - if (result10 !== null) { - result11 = parse___(); - if (result11 !== null) { - result12 = parse_value_clause(); - if (result12 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, ri, t, c, v) { + }, + peg$c30 = function(ri, t, c, v) { return { type : ri, db : t.db, @@ -2022,590 +297,36 @@ module.exports = (function(){ columns : c, values : v } - })(pos0, result0[0], result0[4], result0[8], result0[12]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_replace_insert() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_KW_INSERT(); - if (result0 !== null) { - result0 = (function(offset) { return 'insert'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - result0 = parse_KW_REPLACE(); - if (result0 !== null) { - result0 = (function(offset) { return 'replace' })(pos0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_value_clause() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_VALUES(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_value_list(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { return l; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_value_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_value_item(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_value_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_value_item(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_value_item() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_LPAREN(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_expr_list(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_RPAREN(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { + }, + peg$c31 = function() { return 'insert'; }, + peg$c32 = function() { return 'replace' }, + peg$c33 = function(l) { return l; - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_expr_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_or_expr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_or_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_or_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c34 = function(head, tail) { var el = { type : 'expr_list' } var l = createExprList(head, tail, el); - + el.value = l; return el; - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_expr_list_or_empty() { - var result0; - - result0 = parse_expr_list(); - if (result0 === null) { - result0 = (function(offset, l) { - return { - type : 'expr_list', - value : [] - } - })(pos, result0) ? "" : null; - } - return result0; - } - - function parse_or_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_and_expr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_OR(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_and_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; + }, + peg$c35 = function() { + return { + type : 'expr_list', + value : [] } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_OR(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_and_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c36 = function(head, tail) { return createBinaryExprChain(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_and_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_not_expr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_AND(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_not_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_KW_AND(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_not_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createBinaryExprChain(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_not_expr() { - var result0, result1, result2; - var pos0, pos1, pos2, pos3; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_NOT(); - if (result0 === null) { - pos2 = pos; - if (input.charCodeAt(pos) === 33) { - result0 = "!"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result0 !== null) { - pos3 = pos; - reportFailures++; - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos3; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos2; - } - } else { - result0 = null; - pos = pos2; - } - } - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_not_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, expr) { + }, + peg$c37 = "!", + peg$c38 = peg$literalExpectation("!", false), + peg$c39 = function(expr) { return createUnaryExpr('NOT', expr); - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_comparison_expr(); - } - return result0; - } - - function parse_comparison_expr() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_additive_expr(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_comparison_op_right(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, left, rh) { + }, + peg$c40 = function(left, rh) { if (rh == '') { return left; } else { @@ -2617,286 +338,32 @@ module.exports = (function(){ } return res; } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_comparison_op_right() { - var result0; - - result0 = parse_arithmetic_op_right(); - if (result0 === null) { - result0 = parse_in_op_right(); - if (result0 === null) { - result0 = parse_between_op_right(); - if (result0 === null) { - result0 = parse_is_op_right(); - if (result0 === null) { - result0 = parse_like_op_right(); - if (result0 === null) { - result0 = parse_contains_op_right(); - } - } - } - } - } - return result0; - } - - function parse_arithmetic_op_right() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result1 = parse___(); - if (result1 !== null) { - result2 = parse_arithmetic_comparison_operator(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_additive_expr(); - if (result4 !== null) { - result1 = [result1, result2, result3, result4]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - pos1 = pos; - result1 = parse___(); - if (result1 !== null) { - result2 = parse_arithmetic_comparison_operator(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_additive_expr(); - if (result4 !== null) { - result1 = [result1, result2, result3, result4]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, l) { + }, + peg$c41 = function(l) { return { type : 'arithmetic', tail : l } - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_arithmetic_comparison_operator() { - var result0; - - if (input.substr(pos, 2) === ">=") { - result0 = ">="; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\">=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 62) { - result0 = ">"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result0 === null) { - if (input.substr(pos, 2) === "<=") { - result0 = "<="; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"<=\""); - } - } - if (result0 === null) { - if (input.substr(pos, 2) === "<>") { - result0 = "<>"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"<>\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 60) { - result0 = "<"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"<\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.substr(pos, 2) === "!=") { - result0 = "!="; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"!=\""); - } - } - } - } - } - } - } - } - return result0; - } - - function parse_is_op_right() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_IS(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_additive_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, right) { + }, + peg$c42 = ">=", + peg$c43 = peg$literalExpectation(">=", false), + peg$c44 = ">", + peg$c45 = peg$literalExpectation(">", false), + peg$c46 = "<=", + peg$c47 = peg$literalExpectation("<=", false), + peg$c48 = "<>", + peg$c49 = peg$literalExpectation("<>", false), + peg$c50 = "<", + peg$c51 = peg$literalExpectation("<", false), + peg$c52 = "!=", + peg$c53 = peg$literalExpectation("!=", false), + peg$c54 = function(op, right) { return { op : op, right : right } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_between_op_right() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_BETWEEN(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_additive_expr(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_KW_AND(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_additive_expr(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, begin, end) { + }, + peg$c55 = function(op, begin, end) { return { op : op, right : { @@ -2904,1083 +371,78 @@ module.exports = (function(){ value : [begin, end] } } - })(pos0, result0[0], result0[2], result0[6]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_like_op() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_NOT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_LIKE(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, nk) { return nk[0] + ' ' + nk[2]; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_KW_LIKE(); - } - return result0; - } - - function parse_in_op() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_NOT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_IN(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, nk) { return nk[0] + ' ' + nk[2]; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_KW_IN(); - } - return result0; - } - - function parse_contains_op() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_NOT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_CONTAINS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, nk) { return nk[0] + ' ' + nk[2]; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_KW_CONTAINS(); - } - return result0; - } - - function parse_like_op_right() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_like_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_comparison_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, right) { + }, + peg$c56 = function(nk) { return nk[0] + ' ' + nk[2]; }, + peg$c57 = function(op, right) { return { op : op, right : right } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_in_op_right() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_in_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_expr_list(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, l) { + }, + peg$c58 = function(op, l) { return { op : op, right : l } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_in_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_var_decl(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, e) { - return { - op : op, - right : e - } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_contains_op_right() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_contains_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_expr_list(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, l) { + }, + peg$c59 = function(op, e) { return { op : op, - right : l + right : e } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_contains_op(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_var_decl(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, e) { - return { - op : op, - right : e - } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_additive_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_multiplicative_expr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_additive_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_multiplicative_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_additive_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_multiplicative_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createBinaryExprChain(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_additive_operator() { - var result0; - - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 45) { - result0 = "-"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - } - return result0; - } - - function parse_multiplicative_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_primary(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_multiplicative_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_multiplicative_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c60 = "+", + peg$c61 = peg$literalExpectation("+", false), + peg$c62 = "-", + peg$c63 = peg$literalExpectation("-", false), + peg$c64 = function(head, tail) { return createBinaryExprChain(head, tail) - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_multiplicative_operator() { - var result0; - - if (input.charCodeAt(pos) === 42) { - result0 = "*"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 37) { - result0 = "%"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - } - } - return result0; - } - - function parse_primary() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - result0 = parse_literal(); - if (result0 === null) { - result0 = parse_aggr_func(); - if (result0 === null) { - result0 = parse_func_call(); - if (result0 === null) { - result0 = parse_column_ref(); - if (result0 === null) { - result0 = parse_param(); - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_LPAREN(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_or_expr(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_RPAREN(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { - e.paren = true; - return e; - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_var_decl(); - } - } - } - } - } - } - return result0; - } - - function parse_column_ref() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_DOT(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_column(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, tbl, col) { + }, + peg$c65 = "*", + peg$c66 = peg$literalExpectation("*", false), + peg$c67 = "/", + peg$c68 = peg$literalExpectation("/", false), + peg$c69 = "%", + peg$c70 = peg$literalExpectation("%", false), + peg$c71 = function(e) { + e.paren = true; + return e; + }, + peg$c72 = function(tbl, col) { return { type : 'column_ref', table : tbl, column : col }; - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - result0 = parse_column(); - if (result0 !== null) { - result0 = (function(offset, col) { - return { - type : 'column_ref', - table : '', - column: col - }; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_column_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_column(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_column(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_ident() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident_name(); - if (result0 !== null) { - result1 = (function(offset, name) { return reservedMap[name.toUpperCase()] === true; })(pos, result0) ? null : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name) { + }, + peg$c73 = function(col) { + return { + type : 'column_ref', + table : '', + column: col + }; + }, + peg$c74 = function(name) { return reservedMap[name.toUpperCase()] === true; }, + peg$c75 = function(name) { return name; - })(pos0, result0[0]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_column() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_column_name(); - if (result0 !== null) { - result1 = (function(offset, name) { return reservedMap[name.toUpperCase()] === true; })(pos, result0) ? null : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name) { - return name; - })(pos0, result0[0]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 96) { - result0 = "`"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result0 !== null) { - if (/^[^`]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^`]"); - } - } - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - if (/^[^`]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^`]"); - } - } - } - } else { - result1 = null; - } - if (result1 !== null) { - if (input.charCodeAt(pos) === 96) { - result2 = "`"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, chars) { - return chars.join(''); - })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_column_name() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident_start(); - if (result0 !== null) { - result1 = []; - result2 = parse_column_part(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_column_part(); - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, parts) { return start + parts.join(''); })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_ident_name() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident_start(); - if (result0 !== null) { - result1 = []; - result2 = parse_ident_part(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_ident_part(); - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, parts) { return start + parts.join(''); })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_ident_start() { - var result0; - - if (/^[A-Za-z_]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z_]"); - } - } - return result0; - } - - function parse_ident_part() { - var result0; - - if (/^[A-Za-z0-9_]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_]"); - } - } - return result0; - } - - function parse_column_part() { - var result0; - - if (/^[A-Za-z0-9_:]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_:]"); - } - } - return result0; - } - - function parse_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 !== null) { - result1 = parse_ident_name(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { + }, + peg$c76 = "`", + peg$c77 = peg$literalExpectation("`", false), + peg$c78 = /^[^`]/, + peg$c79 = peg$classExpectation(["`"], true, false), + peg$c80 = function(chars) { + return chars.join(''); + }, + peg$c81 = function(start, parts) { return start + parts.join(''); }, + peg$c82 = /^[A-Za-z_]/, + peg$c83 = peg$classExpectation([["A", "Z"], ["a", "z"], "_"], false, false), + peg$c84 = /^[A-Za-z0-9_]/, + peg$c85 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false), + peg$c86 = /^[A-Za-z0-9_:]/, + peg$c87 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", ":"], false, false), + peg$c88 = ":", + peg$c89 = peg$literalExpectation(":", false), + peg$c90 = function(l) { var p = { type : 'param', value: l[1] @@ -3990,75 +452,8 @@ module.exports = (function(){ //params[key] = p; params.push(p); return p; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_aggr_func() { - var result0; - - result0 = parse_aggr_fun_count(); - if (result0 === null) { - result0 = parse_aggr_fun_smma(); - } - return result0; - } - - function parse_aggr_fun_smma() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_SUM_MAX_MIN_AVG(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_additive_expr(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name, e) { + }, + peg$c91 = function(name, e) { return { type : 'aggr_func', name : name, @@ -4066,3718 +461,277 @@ module.exports = (function(){ expr : e } } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_SUM_MAX_MIN_AVG() { - var result0; - - result0 = parse_KW_SUM(); - if (result0 === null) { - result0 = parse_KW_MAX(); - if (result0 === null) { - result0 = parse_KW_MIN(); - if (result0 === null) { - result0 = parse_KW_AVG(); - } - } - } - return result0; - } - - function parse_aggr_fun_count() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_COUNT(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_count_arg(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name, arg) { + }, + peg$c92 = function(name, arg) { return { type : 'aggr_func', name : name, args : arg } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_count_arg() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = parse_star_expr(); - if (result0 !== null) { - result0 = (function(offset, e) { + }, + peg$c93 = function(e) { return { expr : e } - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_KW_DISTINCT(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_column_ref(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; + }, + peg$c94 = function(d, c) { + return { + distinct : d, + expr : c } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, d, c) { - return { - distinct : d, - expr : c - } - })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_star_expr() { - var result0; - var pos0; - - pos0 = pos; - if (input.charCodeAt(pos) === 42) { - result0 = "*"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { + }, + peg$c95 = function() { return { type : 'star', value : '*' } - })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_func_call() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_expr_list_or_empty(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name, l) { + }, + peg$c96 = function(name, l) { return { type : 'function', name : name, args : l } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_literal() { - var result0; - - result0 = parse_literal_string(); - if (result0 === null) { - result0 = parse_literal_numeric(); - if (result0 === null) { - result0 = parse_literal_bool(); - if (result0 === null) { - result0 = parse_literal_null(); - } - } - } - return result0; - } - - function parse_literal_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_literal(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_literal(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_literal(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { + }, + peg$c97 = function(head, tail) { return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_literal_null() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_KW_NULL(); - if (result0 !== null) { - result0 = (function(offset) { + }, + peg$c98 = function() { return { type : 'null', value : null }; - })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_literal_bool() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_KW_TRUE(); - if (result0 !== null) { - result0 = (function(offset) { + }, + peg$c99 = function() { return { type : 'bool', value : true }; - })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - result0 = parse_KW_FALSE(); - if (result0 !== null) { - result0 = (function(offset) { - return { - type : 'bool', - value : false - }; - })(pos0); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_literal_string() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 34) { - result0 = "\""; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 !== null) { - result1 = []; - result2 = parse_double_char(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_double_char(); - } - if (result1 !== null) { - if (input.charCodeAt(pos) === 34) { - result2 = "\""; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result0 !== null) { - result1 = []; - result2 = parse_single_char(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_single_char(); - } - if (result1 !== null) { - if (input.charCodeAt(pos) === 39) { - result2 = "'"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } - if (result0 !== null) { - result0 = (function(offset, ca) { + }, + peg$c100 = function() { + return { + type : 'bool', + value : false + }; + }, + peg$c101 = "\"", + peg$c102 = peg$literalExpectation("\"", false), + peg$c103 = "'", + peg$c104 = peg$literalExpectation("'", false), + peg$c105 = function(ca) { return { type : 'string', value : ca[1].join('') } - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_single_char() { - var result0; - - if (/^[^'\\\0-\x1F]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[^'\\\\\\0-\\x1F]"); - } - } - if (result0 === null) { - result0 = parse_escape_char(); - } - return result0; - } - - function parse_double_char() { - var result0; - - if (/^[^"\\\0-\x1F]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[^\"\\\\\\0-\\x1F]"); - } - } - if (result0 === null) { - result0 = parse_escape_char(); - } - return result0; - } - - function parse_escape_char() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 2) === "\\'") { - result0 = "\\'"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\'\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "'"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\\"") { - result0 = "\\\""; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\\\"\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return '"'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\\\") { - result0 = "\\\\"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\\\\\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\\"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\/") { - result0 = "\\/"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\/\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "/"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\b") { - result0 = "\\b"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\b\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\b"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\f") { - result0 = "\\f"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\f\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\f"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\n") { - result0 = "\\n"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\n\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\n"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\r") { - result0 = "\\r"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\r\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\r"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.substr(pos, 2) === "\\t") { - result0 = "\\t"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\t\""); - } - } - if (result0 !== null) { - result0 = (function(offset) { return "\t"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 2) === "\\u") { - result0 = "\\u"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\u\""); - } - } - if (result0 !== null) { - result1 = parse_hexDigit(); - if (result1 !== null) { - result2 = parse_hexDigit(); - if (result2 !== null) { - result3 = parse_hexDigit(); - if (result3 !== null) { - result4 = parse_hexDigit(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, h1, h2, h3, h4) { - return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - })(pos0, result0[1], result0[2], result0[3], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_line_terminator() { - var result0; - - if (/^[\n\r]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r]"); - } - } - return result0; - } - - function parse_literal_numeric() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_number(); - if (result0 !== null) { - result0 = (function(offset, n) { + }, + peg$c106 = /^[^'\\\0-\x1F\x7F]/, + peg$c107 = peg$classExpectation(["'", "\\", ["\0", "\x1F"], "\x7F"], true, false), + peg$c108 = /^[^"\\\0-\x1F\x7F]/, + peg$c109 = peg$classExpectation(["\"", "\\", ["\0", "\x1F"], "\x7F"], true, false), + peg$c110 = "\\'", + peg$c111 = peg$literalExpectation("\\'", false), + peg$c112 = function() { return "'"; }, + peg$c113 = "\\\"", + peg$c114 = peg$literalExpectation("\\\"", false), + peg$c115 = function() { return '"'; }, + peg$c116 = "\\\\", + peg$c117 = peg$literalExpectation("\\\\", false), + peg$c118 = function() { return "\\"; }, + peg$c119 = "\\/", + peg$c120 = peg$literalExpectation("\\/", false), + peg$c121 = function() { return "/"; }, + peg$c122 = "\\b", + peg$c123 = peg$literalExpectation("\\b", false), + peg$c124 = function() { return "\b"; }, + peg$c125 = "\\f", + peg$c126 = peg$literalExpectation("\\f", false), + peg$c127 = function() { return "\f"; }, + peg$c128 = "\\n", + peg$c129 = peg$literalExpectation("\\n", false), + peg$c130 = function() { return "\n"; }, + peg$c131 = "\\r", + peg$c132 = peg$literalExpectation("\\r", false), + peg$c133 = function() { return "\r"; }, + peg$c134 = "\\t", + peg$c135 = peg$literalExpectation("\\t", false), + peg$c136 = function() { return "\t"; }, + peg$c137 = "\\u", + peg$c138 = peg$literalExpectation("\\u", false), + peg$c139 = function(h1, h2, h3, h4) { + return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); + }, + peg$c140 = /^[\n\r]/, + peg$c141 = peg$classExpectation(["\n", "\r"], false, false), + peg$c142 = function(n) { return { type : 'number', value : n } - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_number() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_int(); - if (result0 !== null) { - result1 = parse_frac(); - if (result1 !== null) { - result2 = parse_exp(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, int_, frac, exp) { return parseFloat(int_ + frac + exp); })(pos0, result0[0], result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_int(); - if (result0 !== null) { - result1 = parse_frac(); - if (result1 !== null) { - result2 = parse___(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, int_, frac) { return parseFloat(int_ + frac); })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_int(); - if (result0 !== null) { - result1 = parse_exp(); - if (result1 !== null) { - result2 = parse___(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, int_, exp) { return parseFloat(int_ + exp); })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_int(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, int_) { return parseFloat(int_); })(pos0, result0[0]); - } - if (result0 === null) { - pos = pos0; - } - } - } - } - return result0; - } - - function parse_int() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_digit19(); - if (result0 !== null) { - result1 = parse_digits(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, digit19, digits) { return digit19 + digits; })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_digit(); - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 45) { - result0 = "-"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - } - if (result0 !== null) { - result1 = parse_digit19(); - if (result1 !== null) { - result2 = parse_digits(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, digit19, digits) { return "-" + digit19 + digits; })(pos0, result0[0], result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 45) { - result0 = "-"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - } - if (result0 !== null) { - result1 = parse_digit(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, op, digit) { return "-" + digit; })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - } - } - } - return result0; - } - - function parse_frac() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 46) { - result0 = "."; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result0 !== null) { - result1 = parse_digits(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, digits) { return "." + digits; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_exp() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_e(); - if (result0 !== null) { - result1 = parse_digits(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e, digits) { return e + digits; })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_digits() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_digit(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_digit(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, digits) { return digits.join(""); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_digit() { - var result0; - - if (/^[0-9]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - return result0; - } - - function parse_digit19() { - var result0; - - if (/^[1-9]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[1-9]"); - } - } - return result0; - } - - function parse_hexDigit() { - var result0; - - if (/^[0-9a-fA-F]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[0-9a-fA-F]"); - } - } - return result0; - } - - function parse_e() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (/^[eE]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[eE]"); - } - } - if (result0 !== null) { - if (/^[+\-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[+\\-]"); - } - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e, sign) { return e + sign; })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_NULL() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "null") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"NULL\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_TRUE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "true") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"TRUE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_FALSE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "false") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"FALSE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_SHOW() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "show") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SHOW\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_DROP() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "drop") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"DROP\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_SELECT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "select") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SELECT\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_UPDATE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "update") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"UPDATE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_CREATE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "create") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"CREATE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_DELETE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "delete") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"DELETE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_INSERT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "insert") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"INSERT\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_REPLACE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 7).toLowerCase() === "replace") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"REPLACE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_EXPLAIN() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 7).toLowerCase() === "explain") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"EXPLAIN\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_INTO() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "into") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"INTO\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_FROM() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "from") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"FROM\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_SET() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 3).toLowerCase() === "set") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SET\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_AS() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 2).toLowerCase() === "as") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"AS\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_TABLE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "table") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"TABLE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_ON() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 2).toLowerCase() === "on") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ON\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_LEFT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "left") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"LEFT\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_INNER() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "inner") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"INNER\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_JOIN() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 4).toLowerCase() === "join") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"JOIN\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_UNION() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "union") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"UNION\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_VALUES() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "values") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"VALUES\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_EXISTS() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "exists") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"EXISTS\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_WHERE() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "where") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"WHERE\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_GROUP() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "group") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"GROUP\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_BY() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 2).toLowerCase() === "by") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"BY\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_ORDER() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "order") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ORDER\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_HAVING() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "having") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"HAVING\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_LIMIT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "limit") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"LIMIT\""); - } - } - if (result0 !== null) { - pos1 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos1; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_KW_ASC() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "asc") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ASC\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'ASC'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_DESC() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 4).toLowerCase() === "desc") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"DESC\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'DESC'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_ALL() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "all") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ALL\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'ALL'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_DISTINCT() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 8).toLowerCase() === "distinct") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"DISTINCT\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'DISTINCT';})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_BETWEEN() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 7).toLowerCase() === "between") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"BETWEEN\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'BETWEEN'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_IN() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 2).toLowerCase() === "in") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"IN\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'IN'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_IS() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 2).toLowerCase() === "is") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"IS\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'IS'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_LIKE() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 4).toLowerCase() === "like") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"LIKE\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'LIKE'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_CONTAINS() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 8).toLowerCase() === "contains") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"CONTAINS\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'CONTAINS';})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_NOT() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "not") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"NOT\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'NOT'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_AND() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "and") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"AND\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'AND'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_OR() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 2).toLowerCase() === "or") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"OR\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'OR'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_COUNT() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 5).toLowerCase() === "count") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"COUNT\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'COUNT'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_MAX() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "max") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"MAX\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'MAX'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_MIN() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "min") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"MIN\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'MIN'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_SUM() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "sum") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SUM\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'SUM'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_KW_AVG() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "avg") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"AVG\""); - } - } - if (result0 !== null) { - pos2 = pos; - reportFailures++; - result1 = parse_ident_start(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = pos2; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return 'AVG'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_DOT() { - var result0; - - if (input.charCodeAt(pos) === 46) { - result0 = "."; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - return result0; - } - - function parse_COMMA() { - var result0; - - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - return result0; - } - - function parse_STAR() { - var result0; - - if (input.charCodeAt(pos) === 42) { - result0 = "*"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - return result0; - } - - function parse_LPAREN() { - var result0; - - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - return result0; - } - - function parse_RPAREN() { - var result0; - - if (input.charCodeAt(pos) === 41) { - result0 = ")"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - return result0; - } - - function parse_LBRAKE() { - var result0; - - if (input.charCodeAt(pos) === 91) { - result0 = "["; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - return result0; - } - - function parse_RBRAKE() { - var result0; - - if (input.charCodeAt(pos) === 93) { - result0 = "]"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - return result0; - } - - function parse___() { - var result0, result1; - - result0 = []; - result1 = parse_whitespace(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_whitespace(); - } - return result0; - } - - function parse_char() { - var result0; - - if (input.length > pos) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - return result0; - } - - function parse_whitespace() { - var result0; - - if (/^[ \t\n\r]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[ \\t\\n\\r]"); - } - } - return result0; - } - - function parse_EOL() { - var result0, result1; - - result0 = parse_EOF(); - if (result0 === null) { - if (/^[\n\r]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r]"); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[\n\r]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r]"); - } - } - } - } else { - result0 = null; - } - } - return result0; - } - - function parse_EOF() { - var result0; - var pos0; - - pos0 = pos; - reportFailures++; - if (input.length > pos) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - reportFailures--; - if (result0 === null) { - result0 = ""; - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_proc_stmts() { - var result0, result1; - - result0 = []; - result1 = parse_proc_stmt(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_proc_stmt(); - } - return result0; - } - - function parse_proc_stmt() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - pos2 = pos; - reportFailures++; - result0 = parse_proc_init(); - reportFailures--; - if (result0 !== null) { - result0 = ""; - pos = pos2; - } else { - result0 = null; - } - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_assign_stmt(); - if (result2 === null) { - result2 = parse_return_stmt(); - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, s) { + }, + peg$c143 = function(int_, frac, exp) { return parseFloat(int_ + frac + exp); }, + peg$c144 = function(int_, frac) { return parseFloat(int_ + frac); }, + peg$c145 = function(int_, exp) { return parseFloat(int_ + exp); }, + peg$c146 = function(int_) { return parseFloat(int_); }, + peg$c147 = function(digit19, digits) { return digit19 + digits; }, + peg$c148 = function(op, digit19, digits) { return "-" + digit19 + digits; }, + peg$c149 = function(op, digit) { return "-" + digit; }, + peg$c150 = ".", + peg$c151 = peg$literalExpectation(".", false), + peg$c152 = function(digits) { return "." + digits; }, + peg$c153 = function(e, digits) { return e + digits; }, + peg$c154 = function(digits) { return digits.join(""); }, + peg$c155 = /^[0-9]/, + peg$c156 = peg$classExpectation([["0", "9"]], false, false), + peg$c157 = /^[1-9]/, + peg$c158 = peg$classExpectation([["1", "9"]], false, false), + peg$c159 = /^[0-9a-fA-F]/, + peg$c160 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), + peg$c161 = /^[eE]/, + peg$c162 = peg$classExpectation(["e", "E"], false, false), + peg$c163 = /^[+\-]/, + peg$c164 = peg$classExpectation(["+", "-"], false, false), + peg$c165 = function(e, sign) { return e + sign; }, + peg$c166 = "null", + peg$c167 = peg$literalExpectation("NULL", true), + peg$c168 = "true", + peg$c169 = peg$literalExpectation("TRUE", true), + peg$c170 = "false", + peg$c171 = peg$literalExpectation("FALSE", true), + peg$c172 = "show", + peg$c173 = peg$literalExpectation("SHOW", true), + peg$c174 = "drop", + peg$c175 = peg$literalExpectation("DROP", true), + peg$c176 = "select", + peg$c177 = peg$literalExpectation("SELECT", true), + peg$c178 = "update", + peg$c179 = peg$literalExpectation("UPDATE", true), + peg$c180 = "create", + peg$c181 = peg$literalExpectation("CREATE", true), + peg$c182 = "delete", + peg$c183 = peg$literalExpectation("DELETE", true), + peg$c184 = "insert", + peg$c185 = peg$literalExpectation("INSERT", true), + peg$c186 = "replace", + peg$c187 = peg$literalExpectation("REPLACE", true), + peg$c188 = "explain", + peg$c189 = peg$literalExpectation("EXPLAIN", true), + peg$c190 = "into", + peg$c191 = peg$literalExpectation("INTO", true), + peg$c192 = "from", + peg$c193 = peg$literalExpectation("FROM", true), + peg$c194 = "set", + peg$c195 = peg$literalExpectation("SET", true), + peg$c196 = "as", + peg$c197 = peg$literalExpectation("AS", true), + peg$c198 = "table", + peg$c199 = peg$literalExpectation("TABLE", true), + peg$c200 = "on", + peg$c201 = peg$literalExpectation("ON", true), + peg$c202 = "left", + peg$c203 = peg$literalExpectation("LEFT", true), + peg$c204 = "inner", + peg$c205 = peg$literalExpectation("INNER", true), + peg$c206 = "join", + peg$c207 = peg$literalExpectation("JOIN", true), + peg$c208 = "union", + peg$c209 = peg$literalExpectation("UNION", true), + peg$c210 = "values", + peg$c211 = peg$literalExpectation("VALUES", true), + peg$c212 = "exists", + peg$c213 = peg$literalExpectation("EXISTS", true), + peg$c214 = "where", + peg$c215 = peg$literalExpectation("WHERE", true), + peg$c216 = "group", + peg$c217 = peg$literalExpectation("GROUP", true), + peg$c218 = "by", + peg$c219 = peg$literalExpectation("BY", true), + peg$c220 = "order", + peg$c221 = peg$literalExpectation("ORDER", true), + peg$c222 = "having", + peg$c223 = peg$literalExpectation("HAVING", true), + peg$c224 = "limit", + peg$c225 = peg$literalExpectation("LIMIT", true), + peg$c226 = "asc", + peg$c227 = peg$literalExpectation("ASC", true), + peg$c228 = function() { return 'ASC'; }, + peg$c229 = "desc", + peg$c230 = peg$literalExpectation("DESC", true), + peg$c231 = function() { return 'DESC'; }, + peg$c232 = "all", + peg$c233 = peg$literalExpectation("ALL", true), + peg$c234 = function() { return 'ALL'; }, + peg$c235 = "distinct", + peg$c236 = peg$literalExpectation("DISTINCT", true), + peg$c237 = function() { return 'DISTINCT';}, + peg$c238 = "between", + peg$c239 = peg$literalExpectation("BETWEEN", true), + peg$c240 = function() { return 'BETWEEN'; }, + peg$c241 = "in", + peg$c242 = peg$literalExpectation("IN", true), + peg$c243 = function() { return 'IN'; }, + peg$c244 = "is", + peg$c245 = peg$literalExpectation("IS", true), + peg$c246 = function() { return 'IS'; }, + peg$c247 = "like", + peg$c248 = peg$literalExpectation("LIKE", true), + peg$c249 = function() { return 'LIKE'; }, + peg$c250 = "contains", + peg$c251 = peg$literalExpectation("CONTAINS", true), + peg$c252 = function() { return 'CONTAINS';}, + peg$c253 = "not", + peg$c254 = peg$literalExpectation("NOT", true), + peg$c255 = function() { return 'NOT'; }, + peg$c256 = "and", + peg$c257 = peg$literalExpectation("AND", true), + peg$c258 = function() { return 'AND'; }, + peg$c259 = "or", + peg$c260 = peg$literalExpectation("OR", true), + peg$c261 = function() { return 'OR'; }, + peg$c262 = "count", + peg$c263 = peg$literalExpectation("COUNT", true), + peg$c264 = function() { return 'COUNT'; }, + peg$c265 = "max", + peg$c266 = peg$literalExpectation("MAX", true), + peg$c267 = function() { return 'MAX'; }, + peg$c268 = "min", + peg$c269 = peg$literalExpectation("MIN", true), + peg$c270 = function() { return 'MIN'; }, + peg$c271 = "sum", + peg$c272 = peg$literalExpectation("SUM", true), + peg$c273 = function() { return 'SUM'; }, + peg$c274 = "avg", + peg$c275 = peg$literalExpectation("AVG", true), + peg$c276 = function() { return 'AVG'; }, + peg$c277 = ",", + peg$c278 = peg$literalExpectation(",", false), + peg$c279 = "[", + peg$c280 = peg$literalExpectation("[", false), + peg$c281 = "]", + peg$c282 = peg$literalExpectation("]", false), + peg$c283 = peg$anyExpectation(), + peg$c284 = /^[ \t\n\r]/, + peg$c285 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false), + peg$c286 = function(s) { return { stmt : s, vars: varList } - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_init() { - var result0; - - result0 = (function(offset) { varList = []; return true; })(pos) ? "" : null; - return result0; - } - - function parse_assign_stmt() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_var_decl(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_KW_ASSIGN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_proc_expr(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, va, e) { + }, + peg$c287 = function() { varList = []; return true; }, + peg$c288 = function(va, e) { return { type : 'assign', left : va, right: e } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_return_stmt() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_RETURN(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_proc_expr(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { + }, + peg$c289 = function(e) { return { type : 'return', expr: e } - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_expr() { - var result0; - - result0 = parse_select_stmt(); - if (result0 === null) { - result0 = parse_proc_join(); - if (result0 === null) { - result0 = parse_proc_additive_expr(); - if (result0 === null) { - result0 = parse_proc_array(); - } - } - } - return result0; - } - - function parse_proc_additive_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_proc_multiplicative_expr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_additive_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_multiplicative_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_additive_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_multiplicative_expr(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createBinaryExprChain(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_multiplicative_expr() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_proc_primary(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_multiplicative_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_multiplicative_operator(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createBinaryExprChain(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_join() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_var_decl(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_join_op(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_var_decl(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_on_clause(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, lt, op, rt, expr) { + }, + peg$c290 = function(lt, op, rt, expr) { return { type : 'join', ltable : lt, @@ -7785,126 +739,8 @@ module.exports = (function(){ op : op, on : expr } - })(pos0, result0[0], result0[2], result0[4], result0[6]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_primary() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - result0 = parse_literal(); - if (result0 === null) { - result0 = parse_var_decl(); - if (result0 === null) { - result0 = parse_proc_func_call(); - if (result0 === null) { - result0 = parse_param(); - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_LPAREN(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_proc_additive_expr(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_RPAREN(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, e) { - e.paren = true; - return e; - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - } - } - } - } - return result0; - } - - function parse_proc_func_call() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ident(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_LPAREN(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_proc_primary_list(); - if (result4 !== null) { - result5 = parse___(); - if (result5 !== null) { - result6 = parse_RPAREN(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name, l) { + }, + peg$c291 = function(name, l) { //compatible with original func_call return { type : 'function', @@ -7914,177 +750,14 @@ module.exports = (function(){ value : l } } - })(pos0, result0[0], result0[4]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_primary_list() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_proc_primary(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse___(); - if (result2 !== null) { - result3 = parse_COMMA(); - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result5 = parse_proc_primary(); - if (result5 !== null) { - result2 = [result2, result3, result4, result5]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, head, tail) { - return createList(head, tail); - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_proc_array() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_LBRAKE(); - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result2 = parse_proc_primary_list(); - if (result2 !== null) { - result3 = parse___(); - if (result3 !== null) { - result4 = parse_RBRAKE(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, l) { + }, + peg$c292 = function(l) { return { type : 'array', value : l } - })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_var_decl() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_VAR_PRE(); - if (result0 !== null) { - result1 = parse_ident_name(); - if (result1 !== null) { - result2 = parse_mem_chain(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, name, m) { + }, + peg$c293 = function(name, m) { //push for analysis varList.push(name); return { @@ -8092,396 +765,7337 @@ module.exports = (function(){ name : name, members : m } - })(pos0, result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_mem_chain() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = []; - pos1 = pos; - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 !== null) { - result2 = parse_ident_name(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - while (result1 !== null) { - result0.push(result1); - pos1 = pos; - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 !== null) { - result2 = parse_ident_name(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - } - if (result0 !== null) { - result0 = (function(offset, l) { + }, + peg$c294 = function(l) { var s = []; for (var i = 0; i < l.length; i++) { s.push(l[i][1]); } return s; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; + }, + peg$c295 = "$", + peg$c296 = peg$literalExpectation("$", false), + peg$c297 = "return", + peg$c298 = peg$literalExpectation("return", true), + peg$c299 = ":=", + peg$c300 = peg$literalExpectation(":=", false), + + peg$currPos = 0, + peg$savedPos = 0, + peg$posDetailsCache = [{ line: 1, column: 1 }], + 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 + "\"."); } - - function parse_KW_VAR_PRE() { - var result0; - - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildSimpleError(message, location); + } + + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + + function peg$classExpectation(parts, inverted, ignoreCase) { + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; } - return result0; - } - - function parse_KW_RETURN() { - var result0; - - if (input.substr(pos, 6).toLowerCase() === "return") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"return\""); - } - } - return result0; - } - - function parse_KW_ASSIGN() { - var result0; - - if (input.substr(pos, 2) === ":=") { - result0 = ":="; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":=\""); - } - } - return result0; - } - - - function cleanupExpected(expected) { - expected.sort(); - - var lastExpected = null; - var cleanExpected = []; - for (var i = 0; i < expected.length; i++) { - if (expected[i] !== lastExpected) { - cleanExpected.push(expected[i]); - lastExpected = expected[i]; - } - } - return cleanExpected; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { - var ch = input.charAt(i); - if (ch === "\n") { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - line++; - column = 1; - seenCR = true; + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; } else { - column++; - seenCR = false; + details.column++; } + + p++; } - - return { line: line, column: column }; + + peg$posDetailsCache[pos] = details; + return details; } - - - var util = require('util'); - - function debug(str){ - console.log(str); + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); + + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column } - - function inspect(obj){ - console.log(util.inspect(obj, false, 10)); - } - - 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); + }; + } + + 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$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parsestart() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseinit(); + peg$silentFails--; + if (s2 !== peg$FAILED) { + peg$currPos = s1; + s1 = void 0; + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parseunion_stmt(); + if (s3 === peg$FAILED) { + s3 = peg$parseupdate_stmt(); + if (s3 === peg$FAILED) { + s3 = peg$parsereplace_insert_stmt(); } } - 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]); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c0(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return result; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - - 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 = []; - - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var offset = Math.max(pos, rightmostFailuresPos); - var found = offset < input.length ? input.charAt(offset) : null; - var errorPosition = computeErrorPosition(); - - throw new this.SyntaxError( - cleanupExpected(rightmostFailuresExpected), - found, - offset, - errorPosition.line, - errorPosition.column - ); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(expected, found, offset, line, column) { - function buildMessage(expected, found) { - var expectedHumanized, foundHumanized; - - switch (expected.length) { - case 0: - expectedHumanized = "end of input"; - break; - case 1: - expectedHumanized = expected[0]; - break; - default: - expectedHumanized = expected.slice(0, expected.length - 1).join(", ") - + " or " - + expected[expected.length - 1]; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseproc_stmts(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c1(s1); + } + s0 = s1; } - - foundHumanized = found ? quote(found) : "end of input"; - - return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; + + return s0; } - - this.name = "SyntaxError"; - this.expected = expected; - this.found = found; - this.message = buildMessage(expected, found); - this.offset = offset; - this.line = line; - this.column = column; + + function peg$parseinit() { + var s0; + + peg$savedPos = peg$currPos; + s0 = peg$c2(); + if (s0) { + s0 = void 0; + } else { + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c3(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$c4; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c5); } + } + 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$c6; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c7); } + } + if (s6 !== peg$FAILED) { + s2 = [s2, s3, s4, s5, s6]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c8(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 = null; + } + 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 = null; + } + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + if (s8 !== peg$FAILED) { + s9 = peg$parsewhere_clause(); + if (s9 === peg$FAILED) { + s9 = null; + } + if (s9 !== peg$FAILED) { + s10 = peg$parse__(); + if (s10 !== peg$FAILED) { + s11 = peg$parsegroup_by_clause(); + if (s11 === peg$FAILED) { + s11 = null; + } + if (s11 !== peg$FAILED) { + s12 = peg$parse__(); + if (s12 !== peg$FAILED) { + s13 = peg$parseorder_by_clause(); + if (s13 === peg$FAILED) { + s13 = null; + } + if (s13 !== peg$FAILED) { + s14 = peg$parse__(); + if (s14 !== peg$FAILED) { + s15 = peg$parselimit_clause(); + if (s15 === peg$FAILED) { + s15 = null; + } + if (s15 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c9(s3, s5, s7, s9, s11, s13, s15); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsecolumn_clause() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + 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 = void 0; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c10(); + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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 = null; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c12(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsealias_clause() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseKW_AS(); + if (s1 === peg$FAILED) { + s1 = null; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parseident(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c13(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c14(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c15(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c16(s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse__(); + if (s1 !== peg$FAILED) { + s2 = peg$parsetable_join(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c16(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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 = null; + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c17(s1, s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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 = null; + } + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (s4 !== peg$FAILED) { + s5 = peg$parseident(); + if (s5 === peg$FAILED) { + s5 = null; + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c18(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c19(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = null; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseKW_JOIN(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c20(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c21(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsevar_decl(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c22(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$savedPos = s0; + s1 = peg$c23(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c23(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c14(s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c23(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c14(s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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 = null; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c24(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsenumber_or_param() { + var s0; + + s0 = peg$parseliteral_numeric(); + 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$parsenumber_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$parsenumber_or_param(); + if (s8 !== peg$FAILED) { + s6 = [s6, s7, s8]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c25(s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c26(s3, s7, s9); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$c27; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (s4 !== peg$FAILED) { + s5 = peg$parseadditive_expr(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c29(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c30(s1, s5, s9, s13); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsereplace_insert() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseKW_INSERT(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c31(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseKW_REPLACE(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c32(); + } + 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$savedPos = s0; + s1 = peg$c14(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c33(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c34(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseexpr_list_or_empty() { + var s0; + + s0 = peg$parseexpr_list(); + if (s0 === peg$FAILED) { + peg$savedPos = peg$currPos; + s0 = peg$c35(); + if (s0) { + s0 = void 0; + } else { + s0 = peg$FAILED; + } + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$c37; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s4 = peg$c27; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = void 0; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parsenot_expr(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c39(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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 = null; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c40(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c41(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsearithmetic_comparison_operator() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c42) { + s0 = peg$c42; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c43); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 62) { + s0 = peg$c44; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c45); } + } + if (s0 === peg$FAILED) { + 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.substr(peg$currPos, 2) === peg$c48) { + s0 = peg$c48; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c49); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 60) { + s0 = peg$c50; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s0 = peg$c27; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + 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); } + } + } + } + } + } + } + } + + 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$savedPos = s0; + s1 = peg$c54(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c55(s1, s3, s7); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c56(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$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c56(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$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c56(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$savedPos = s0; + s1 = peg$c57(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c58(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c59(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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$savedPos = s0; + s1 = peg$c58(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c59(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseadditive_operator() { + var s0; + + if (input.charCodeAt(peg$currPos) === 43) { + s0 = peg$c60; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c61); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c62; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c63); } + } + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c64(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsemultiplicative_operator() { + var s0; + + if (input.charCodeAt(peg$currPos) === 42) { + s0 = peg$c65; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s0 = peg$c67; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c68); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 37) { + s0 = peg$c69; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c70); } + } + } + } + + 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$savedPos = s0; + s1 = peg$c71(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c72(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsecolumn(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c73(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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseident() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parseident_name(); + if (s1 !== peg$FAILED) { + peg$savedPos = peg$currPos; + s2 = peg$c74(s1); + if (s2) { + s2 = peg$FAILED; + } else { + s2 = void 0; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c75(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsecolumn() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parsecolumn_name(); + if (s1 !== peg$FAILED) { + peg$savedPos = peg$currPos; + s2 = peg$c74(s1); + if (s2) { + s2 = peg$FAILED; + } else { + s2 = void 0; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c75(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 96) { + s1 = peg$c76; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c78.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c79); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c78.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c79); } + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 96) { + s3 = peg$c76; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c80(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + 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$savedPos = s0; + s1 = peg$c81(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c81(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseident_start() { + var s0; + + if (peg$c82.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c83); } + } + + return s0; + } + + function peg$parseident_part() { + var s0; + + if (peg$c84.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c85); } + } + + return s0; + } + + function peg$parsecolumn_part() { + var s0; + + if (peg$c86.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } + } + + return s0; + } + + function peg$parseparam() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c88; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseident_name(); + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c90(s1); + } + s0 = s1; + + 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$savedPos = s0; + s1 = peg$c91(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_SUM_MAX_MIN_AVG() { + var s0; + + s0 = peg$parseKW_SUM(); + if (s0 === peg$FAILED) { + s0 = peg$parseKW_MAX(); + if (s0 === peg$FAILED) { + s0 = peg$parseKW_MIN(); + if (s0 === peg$FAILED) { + s0 = peg$parseKW_AVG(); + } + } + } + + 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$savedPos = s0; + s1 = peg$c92(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsecount_arg() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parsestar_expr(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c93(s1); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseKW_DISTINCT(); + if (s1 === peg$FAILED) { + s1 = null; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + s3 = peg$parsecolumn_ref(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c94(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parsestar_expr() { + var s0, s1; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 42) { + s1 = peg$c65; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c95(); + } + 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$savedPos = s0; + s1 = peg$c96(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c97(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseliteral_null() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseKW_NULL(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c98(); + } + s0 = s1; + + return s0; + } + + function peg$parseliteral_bool() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseKW_TRUE(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c99(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseKW_FALSE(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c100(); + } + 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$c101; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c102); } + } + 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$c101; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c102); } + } + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c103; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c104); } + } + 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$c103; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c104); } + } + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c105(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsesingle_char() { + var s0; + + if (peg$c106.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c107); } + } + if (s0 === peg$FAILED) { + s0 = peg$parseescape_char(); + } + + return s0; + } + + function peg$parsedouble_char() { + var s0; + + if (peg$c108.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c109); } + } + 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$c110) { + s1 = peg$c110; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c111); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c112(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c113) { + s1 = peg$c113; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c114); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c115(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c116) { + s1 = peg$c116; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c117); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c118(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c119) { + s1 = peg$c119; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c120); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c121(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c122) { + s1 = peg$c122; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c123); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c124(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c125) { + s1 = peg$c125; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c126); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c127(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c128) { + s1 = peg$c128; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c129); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c130(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c131) { + s1 = peg$c131; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c132); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c133(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c134) { + s1 = peg$c134; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c135); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c136(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c137) { + s1 = peg$c137; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c138); } + } + 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$savedPos = s0; + s1 = peg$c139(s2, s3, s4, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + } + } + } + } + } + } + + return s0; + } + + function peg$parseline_terminator() { + var s0; + + if (peg$c140.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c141); } + } + + return s0; + } + + function peg$parseliteral_numeric() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parsenumber(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c142(s1); + } + s0 = s1; + + 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$savedPos = s0; + s1 = peg$c143(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c144(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c145(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseint(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c146(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + + 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$savedPos = s0; + s1 = peg$c147(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parsedigit(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 45) { + s1 = peg$c62; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c63); } + } + if (s1 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s1 = peg$c60; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c61); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsedigit19(); + if (s2 !== peg$FAILED) { + s3 = peg$parsedigits(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c148(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 45) { + s1 = peg$c62; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c63); } + } + if (s1 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s1 = peg$c60; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c61); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsedigit(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c149(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + + return s0; + } + + function peg$parsefrac() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c150; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c151); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsedigits(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c152(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c153(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c154(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsedigit() { + var s0; + + if (peg$c155.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c156); } + } + + return s0; + } + + function peg$parsedigit19() { + var s0; + + if (peg$c157.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + + return s0; + } + + function peg$parsehexDigit() { + var s0; + + if (peg$c159.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + + return s0; + } + + function peg$parsee() { + var s0, s1, s2; + + s0 = peg$currPos; + if (peg$c161.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + if (s1 !== peg$FAILED) { + if (peg$c163.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c164); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c165(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_NULL() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c166) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c167); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_TRUE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c168) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c169); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_FALSE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c170) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c171); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_SHOW() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c172) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c173); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_DROP() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c174) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c175); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_SELECT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c176) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c177); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_UPDATE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c178) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_CREATE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c180) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_DELETE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c182) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_INSERT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c184) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_REPLACE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c186) { + s1 = input.substr(peg$currPos, 7); + peg$currPos += 7; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_EXPLAIN() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c188) { + s1 = input.substr(peg$currPos, 7); + peg$currPos += 7; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_INTO() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c190) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_FROM() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c192) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_SET() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c194) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_AS() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c196) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_TABLE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c198) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_ON() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c200) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_LEFT() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_INNER() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c204) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_JOIN() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c206) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_UNION() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c208) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_VALUES() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c210) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_EXISTS() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c212) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_WHERE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c214) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_GROUP() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_BY() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c218) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_ORDER() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_HAVING() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_LIMIT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c224) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_ASC() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c226) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c228(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_DESC() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c229) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c230); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c231(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_ALL() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c232) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c234(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_DISTINCT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c235) { + s1 = input.substr(peg$currPos, 8); + peg$currPos += 8; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c236); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseident_start(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c237(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_BETWEEN() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c238) { + s1 = input.substr(peg$currPos, 7); + peg$currPos += 7; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c240(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_IN() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c241) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c243(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_IS() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c244) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c246(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_LIKE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c247) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c249(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_CONTAINS() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c250) { + s1 = input.substr(peg$currPos, 8); + peg$currPos += 8; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c252(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_NOT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c253) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c255(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_AND() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c256) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c258(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_OR() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c259) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c261(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_COUNT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5).toLowerCase() === peg$c262) { + s1 = input.substr(peg$currPos, 5); + peg$currPos += 5; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c264(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_MAX() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c267(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_MIN() { + 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c270(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_SUM() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c271) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c273(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseKW_AVG() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3).toLowerCase() === peg$c274) { + s1 = input.substr(peg$currPos, 3); + peg$currPos += 3; + } 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 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c276(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDOT() { + var s0; + + if (input.charCodeAt(peg$currPos) === 46) { + s0 = peg$c150; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c151); } + } + + return s0; + } + + function peg$parseCOMMA() { + var s0; + + if (input.charCodeAt(peg$currPos) === 44) { + s0 = peg$c277; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c278); } + } + + return s0; + } + + function peg$parseSTAR() { + var s0; + + if (input.charCodeAt(peg$currPos) === 42) { + s0 = peg$c65; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + + return s0; + } + + function peg$parseLPAREN() { + var s0; + + if (input.charCodeAt(peg$currPos) === 40) { + s0 = peg$c4; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c5); } + } + + return s0; + } + + function peg$parseRPAREN() { + var s0; + + if (input.charCodeAt(peg$currPos) === 41) { + s0 = peg$c6; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c7); } + } + + return s0; + } + + function peg$parseLBRAKE() { + var s0; + + if (input.charCodeAt(peg$currPos) === 91) { + s0 = peg$c279; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c280); } + } + + return s0; + } + + function peg$parseRBRAKE() { + var s0; + + if (input.charCodeAt(peg$currPos) === 93) { + s0 = peg$c281; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c282); } + } + + 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$c283); } + } + + return s0; + } + + function peg$parsewhitespace() { + var s0; + + if (peg$c284.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c285); } + } + + return s0; + } + + function peg$parseEOL() { + var s0, s1; + + s0 = peg$parseEOF(); + if (s0 === peg$FAILED) { + s0 = []; + if (peg$c140.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c141); } + } + if (s1 !== peg$FAILED) { + while (s1 !== peg$FAILED) { + s0.push(s1); + if (peg$c140.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c141); } + } + } + } else { + s0 = peg$FAILED; + } + } + + 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$c283); } + } + peg$silentFails--; + if (s1 === peg$FAILED) { + s0 = void 0; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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 = void 0; + } else { + s1 = peg$FAILED; + } + 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$savedPos = s0; + s1 = peg$c286(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseproc_init() { + var s0; + + peg$savedPos = peg$currPos; + s0 = peg$c287(); + if (s0) { + s0 = void 0; + } else { + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c288(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c289(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c290(s1, s3, s5, s7); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c71(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + } + + 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$savedPos = s0; + s1 = peg$c291(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + 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$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c292(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$savedPos = s0; + s1 = peg$c293(s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + 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$c150; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c151); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseident_name(); + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c150; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c151); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseident_name(); + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c294(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseKW_VAR_PRE() { + var s0; + + if (input.charCodeAt(peg$currPos) === 36) { + s0 = peg$c295; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c296); } + } + + return s0; + } + + function peg$parseKW_RETURN() { + var s0; + + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c297) { + s0 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c298); } + } + + return s0; + } + + function peg$parseKW_ASSIGN() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c299) { + s0 = peg$c299; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c300); } + } + + return s0; + } + + + var util = require('util'); + + function debug(str){ + console.log(str); + } + + function inspect(obj){ + console.log(util.inspect(obj, false, 10)); + } + + 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(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } + } + + return { + SyntaxError: peg$SyntaxError, + parse: peg$parse }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); +}); diff --git a/core/comment.js b/core/comment.js index 68d844d..95666a1 100644 --- a/core/comment.js +++ b/core/comment.js @@ -1,265 +1,163 @@ -module.exports = (function(){ - /* - * Generated by PEG.js 0.7.0. - * - * http://pegjs.majda.cz/ - */ - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - * - * For portability, we also escape escape all control and non-ASCII - * characters. Note that "\0" and "\v" escape sequences are not used - * because JSHint does not like the first and IE the second. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\x08/g, '\\b') // backspace - .replace(/\t/g, '\\t') // horizontal tab - .replace(/\n/g, '\\n') // line feed - .replace(/\f/g, '\\f') // form feed - .replace(/\r/g, '\\r') // carriage return - .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) - + '"'; +/* + * Generated by PEG.js 0.10.0. + * + * http://pegjs.org/ + */ +(function(root, factory) { + if (typeof define === "function" && define.amd) { + define([], factory); + } else if (typeof module === "object" && module.exports) { + module.exports = factory(); } - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - parse: function(input, startRule) { - var parseFunctions = { - "start": parse_start, - "union_stmt": parse_union_stmt, - "comment": parse_comment, - "singleLine": parse_singleLine, - "multiLine": parse_multiLine, - "quote": parse_quote, - "kw_start": parse_kw_start, - "KW_SINGLE_LINE_START": parse_KW_SINGLE_LINE_START, - "KW_SINGLE_LINE_END": parse_KW_SINGLE_LINE_END, - "KW_MULTI_LINE_START": parse_KW_MULTI_LINE_START, - "KW_MULTI_LINE_END": parse_KW_MULTI_LINE_END, - "__": parse___, - "whitespace": parse_whitespace - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "start"; +})(this, function() { + "use strict"; + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } + } + + peg$subclass(peg$SyntaxError, Error); + + peg$SyntaxError.buildMessage = function(expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + + "class": function(expectation) { + var escapedParts = "", + i; + + for (i = 0; i < expectation.parts.length; i++) { + escapedParts += expectation.parts[i] instanceof Array + ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) + : classEscape(expectation.parts[i]); + } + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + + any: function(expectation) { + return "any character"; + }, + + end: function(expectation) { + return "end of input"; + }, + + other: function(expectation) { + return expectation.description; + } + }; + + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + function literalEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } + + function classEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/\]/g, '\\]') + .replace(/\^/g, '\\^') + .replace(/-/g, '\\-') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + var descriptions = new Array(expected.length), + i, j; + + for (i = 0; i < expected.length; i++) { + descriptions[i] = describeExpectation(expected[i]); } - - var pos = 0; - var reportFailures = 0; - var rightmostFailuresPos = 0; - var rightmostFailuresExpected = []; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; + + descriptions.sort(); + + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } } - - return result; + descriptions.length = j; } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - var escapeChar; - var length; - - if (charCode <= 0xFF) { - escapeChar = 'x'; - length = 2; - } else { - escapeChar = 'u'; - length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; } - - function matchFailed(failure) { - if (pos < rightmostFailuresPos) { - return; - } - - if (pos > rightmostFailuresPos) { - rightmostFailuresPos = pos; - rightmostFailuresExpected = []; - } - - rightmostFailuresExpected.push(failure); - } - - function parse_start() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_union_stmt(); - if (result0 !== null) { - result0 = (function(offset, union_stmt) { + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + }; + + function peg$parse(input, options) { + options = options !== void 0 ? options : {}; + + var peg$FAILED = {}, + + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + + peg$c0 = function(union_stmt) { return {lines,text:union_stmt}; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_union_stmt() { - var result0, result1, result2, result3; - var pos0, pos1, pos2, pos3, pos4, pos5, pos6; - - pos0 = pos; - pos1 = pos; - result0 = []; - pos2 = pos; - pos3 = pos; - result1 = []; - pos4 = pos; - pos5 = pos; - pos6 = pos; - reportFailures++; - result2 = parse_kw_start(); - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos6; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos5; - } - } else { - result2 = null; - pos = pos5; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word})(pos4, result2[1]); - } - if (result2 === null) { - pos = pos4; - } - while (result2 !== null) { - result1.push(result2); - pos4 = pos; - pos5 = pos; - pos6 = pos; - reportFailures++; - result2 = parse_kw_start(); - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos6; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos5; - } - } else { - result2 = null; - pos = pos5; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word})(pos4, result2[1]); - } - if (result2 === null) { - pos = pos4; - } - } - if (result1 !== null) { - pos4 = pos; - result2 = parse_comment(); - if (result2 !== null) { - result2 = (function(offset, comment) {return ''})(pos4, result2); - } - if (result2 === null) { - pos = pos4; - } - if (result2 === null) { - pos4 = pos; - result2 = parse_quote(); - if (result2 !== null) { - result2 = (function(offset, quote) {return quote})(pos4, result2); - } - if (result2 === null) { - pos = pos4; - } - if (result2 === null) { - pos4 = pos; - if (input.charCodeAt(pos) === 59) { - result2 = ";"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result2 !== null) { - result2 = (function(offset) {isSplit=true;return ";"})(pos4); - } - if (result2 === null) { - pos = pos4; - } - } - } - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos3; - } - } else { - result1 = null; - pos = pos3; - } - if (result1 !== null) { - result1 = (function(offset, words, stmt) { + }, + peg$c1 = peg$anyExpectation(), + peg$c2 = function(word) {return word}, + peg$c3 = function(words, comment) {return ''}, + peg$c4 = function(words, quote) {return quote}, + peg$c5 = ";", + peg$c6 = peg$literalExpectation(";", false), + peg$c7 = function(words) {isSplit=true;return ";"}, + peg$c8 = function(words, stmt) { const text=words.join("")+stmt; let index=Math.max(lines.length-1,0); lines[index]=(lines[index]||'')+text; @@ -268,804 +166,879 @@ module.exports = (function(){ lines.push(''); } return text; - })(pos2, result1[0], result1[1]); - } - if (result1 === null) { - pos = pos2; - } - while (result1 !== null) { - result0.push(result1); - pos2 = pos; - pos3 = pos; - result1 = []; - pos4 = pos; - pos5 = pos; - pos6 = pos; - reportFailures++; - result2 = parse_kw_start(); - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos6; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos5; - } - } else { - result2 = null; - pos = pos5; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word})(pos4, result2[1]); - } - if (result2 === null) { - pos = pos4; - } - while (result2 !== null) { - result1.push(result2); - pos4 = pos; - pos5 = pos; - pos6 = pos; - reportFailures++; - result2 = parse_kw_start(); - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos6; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos5; - } - } else { - result2 = null; - pos = pos5; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word})(pos4, result2[1]); - } - if (result2 === null) { - pos = pos4; - } - } - if (result1 !== null) { - pos4 = pos; - result2 = parse_comment(); - if (result2 !== null) { - result2 = (function(offset, comment) {return ''})(pos4, result2); - } - if (result2 === null) { - pos = pos4; - } - if (result2 === null) { - pos4 = pos; - result2 = parse_quote(); - if (result2 !== null) { - result2 = (function(offset, quote) {return quote})(pos4, result2); - } - if (result2 === null) { - pos = pos4; - } - if (result2 === null) { - pos4 = pos; - if (input.charCodeAt(pos) === 59) { - result2 = ";"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result2 !== null) { - result2 = (function(offset) {isSplit=true;return ";"})(pos4); - } - if (result2 === null) { - pos = pos4; - } - } - } - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos3; - } - } else { - result1 = null; - pos = pos3; - } - if (result1 !== null) { - result1 = (function(offset, words, stmt) { - const text=words.join("")+stmt; - let index=Math.max(lines.length-1,0); - lines[index]=(lines[index]||'')+text; - if(isSplit){ - isSplit=false; - lines.push(''); - } - return text; - })(pos2, result1[0], result1[1]); - } - if (result1 === null) { - pos = pos2; - } - } - if (result0 !== null) { - result1 = []; - if (input.length > pos) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - while (result2 !== null) { - result1.push(result2); - if (input.length > pos) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, stmt, other) { + }, + peg$c9 = function(stmt, other) { const text=stmt.join("")+other.join("") let index=Math.max(lines.length-1,0); lines[index]=lines[index]+other.join(""); return text; - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_comment() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_multiLine(); - if (result0 === null) { - result0 = parse_singleLine(); - } - if (result0 !== null) { - result0 = (function(offset, comment) { + }, + peg$c10 = function(comment) { return comment; - })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_singleLine() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_SINGLE_LINE_START(); - if (result0 !== null) { - result1 = []; - if (/^[^\r\n]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\\r\\n]"); - } - } - while (result2 !== null) { - result1.push(result2); - if (/^[^\r\n]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\\r\\n]"); - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, words) { + }, + peg$c11 = /^[^\r\n]/, + peg$c12 = peg$classExpectation(["\r", "\n"], true, false), + peg$c13 = function(start, words) { return start+words.join("") - })(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; + }, + peg$c14 = "*/", + peg$c15 = peg$literalExpectation("*/", false), + peg$c16 = function(start, word) {return word }, + peg$c17 = function(start, words, end) {return start+words.join("")+end }, + peg$c18 = "\"", + peg$c19 = peg$literalExpectation("\"", false), + peg$c20 = /^[^"]/, + peg$c21 = peg$classExpectation(["\""], true, false), + peg$c22 = function(start, words, end) {return start+words.join("")+end;}, + peg$c23 = "'", + peg$c24 = peg$literalExpectation("'", false), + peg$c25 = /^[^']/, + peg$c26 = peg$classExpectation(["'"], true, false), + peg$c27 = "--", + peg$c28 = peg$literalExpectation("--", false), + peg$c29 = /^[\r\n]/, + peg$c30 = peg$classExpectation(["\r", "\n"], false, false), + peg$c31 = "/*", + peg$c32 = peg$literalExpectation("/*", false), + peg$c33 = /^[ \t\r\n]/, + peg$c34 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), + + peg$currPos = 0, + peg$savedPos = 0, + peg$posDetailsCache = [{ line: 1, column: 1 }], + 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 + "\"."); } - - function parse_multiLine() { - var result0, result1, result2, result3; - var pos0, pos1, pos2, pos3, pos4; - - pos0 = pos; - pos1 = pos; - result0 = parse_KW_MULTI_LINE_START(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - pos3 = pos; - pos4 = pos; - reportFailures++; - if (input.substr(pos, 2) === "*/") { - result2 = "*/"; - pos += 2; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"*/\""); - } - } - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos4; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos3; - } - } else { - result2 = null; - pos = pos3; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word })(pos2, result2[1]); - } - if (result2 === null) { - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - pos3 = pos; - pos4 = pos; - reportFailures++; - if (input.substr(pos, 2) === "*/") { - result2 = "*/"; - pos += 2; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"*/\""); - } - } - reportFailures--; - if (result2 === null) { - result2 = ""; - } else { - result2 = null; - pos = pos4; - } - if (result2 !== null) { - if (input.length > pos) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos3; - } - } else { - result2 = null; - pos = pos3; - } - if (result2 !== null) { - result2 = (function(offset, word) {return word })(pos2, result2[1]); - } - if (result2 === null) { - pos = pos2; - } - } - if (result1 !== null) { - result2 = parse_KW_MULTI_LINE_END(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, words, end) {return start+words.join("")+end })(pos0, result0[0], result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_quote() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 34) { - result0 = "\""; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 !== null) { - result1 = []; - if (/^[^"]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\"]"); - } - } - while (result2 !== null) { - result1.push(result2); - if (/^[^"]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\"]"); - } - } - } - if (result1 !== null) { - if (input.charCodeAt(pos) === 34) { - result2 = "\""; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, words, end) {return start+words.join("")+end;})(pos0, result0[0], result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result0 !== null) { - result1 = []; - if (/^[^']/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^']"); - } - } - while (result2 !== null) { - result1.push(result2); - if (/^[^']/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^']"); - } - } - } - if (result1 !== null) { - if (input.charCodeAt(pos) === 39) { - result2 = "'"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, start, words, end) {return start+words.join("")+end;})(pos0, result0[0], result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - } - return result0; - } - - function parse_kw_start() { - var result0; - - result0 = parse_KW_SINGLE_LINE_START(); - if (result0 === null) { - result0 = parse_KW_MULTI_LINE_START(); - if (result0 === null) { - if (input.charCodeAt(pos) === 34) { - result0 = "\""; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - } - } - } - } - return result0; - } - - function parse_KW_SINGLE_LINE_START() { - var result0; - - if (input.substr(pos, 2) === "--") { - result0 = "--"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"--\""); - } - } - return result0; - } - - function parse_KW_SINGLE_LINE_END() { - var result0; - - if (/^[\r\n]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\r\\n]"); - } - } - return result0; - } - - function parse_KW_MULTI_LINE_START() { - var result0; - - if (input.substr(pos, 2) === "/*") { - result0 = "/*"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/*\""); - } - } - return result0; - } - - function parse_KW_MULTI_LINE_END() { - var result0; - - if (input.substr(pos, 2) === "*/") { - result0 = "*/"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*/\""); - } - } - return result0; - } - - function parse___() { - var result0, result1; - - result0 = []; - result1 = parse_whitespace(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_whitespace(); - } - return result0; - } - - function parse_whitespace() { - var result0; - - if (/^[ \t\r\n]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[ \\t\\r\\n]"); - } - } - return result0; - } - - - function cleanupExpected(expected) { - expected.sort(); - - var lastExpected = null; - var cleanExpected = []; - for (var i = 0; i < expected.length; i++) { - if (expected[i] !== lastExpected) { - cleanExpected.push(expected[i]); - lastExpected = expected[i]; - } - } - return cleanExpected; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { - var ch = input.charAt(i); - if (ch === "\n") { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - line++; - column = 1; - seenCR = true; - } else { - column++; - seenCR = false; - } - } - - return { line: line, column: column }; - } - - - let lines=[]; - let isSplit=false; - - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var offset = Math.max(pos, rightmostFailuresPos); - var found = offset < input.length ? input.charAt(offset) : null; - var errorPosition = computeErrorPosition(); - - throw new this.SyntaxError( - cleanupExpected(rightmostFailuresExpected), - found, - offset, - errorPosition.line, - errorPosition.column - ); - } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(expected, found, offset, line, column) { - function buildMessage(expected, found) { - var expectedHumanized, foundHumanized; - - switch (expected.length) { - case 0: - expectedHumanized = "end of input"; - break; - case 1: - expectedHumanized = expected[0]; - break; - default: - expectedHumanized = expected.slice(0, expected.length - 1).join(", ") - + " or " - + expected[expected.length - 1]; - } - - foundHumanized = found ? quote(found) : "end of input"; - - return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } - - this.name = "SyntaxError"; - this.expected = expected; - this.found = found; - this.message = buildMessage(expected, found); - this.offset = offset; - this.line = line; - this.column = column; + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildSimpleError(message, location); + } + + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + + function peg$classExpectation(parts, inverted, ignoreCase) { + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); + + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + 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$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parsestart() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseunion_stmt(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c0(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseunion_stmt() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = []; + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsekw_start(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c2(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsekw_start(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c2(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsecomment(); + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c3(s3, s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsequote(); + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c4(s3, s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 59) { + s5 = peg$c5; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c7(s3); + } + s4 = s5; + } + } + if (s4 !== peg$FAILED) { + peg$savedPos = s2; + s3 = peg$c8(s3, s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = []; + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsekw_start(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c2(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsekw_start(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c2(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsecomment(); + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c3(s3, s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsequote(); + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c4(s3, s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 59) { + s5 = peg$c5; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s4; + s5 = peg$c7(s3); + } + s4 = s5; + } + } + if (s4 !== peg$FAILED) { + peg$savedPos = s2; + s3 = peg$c8(s3, s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (input.length > peg$currPos) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (input.length > peg$currPos) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c9(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsecomment() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parsemultiLine(); + if (s1 === peg$FAILED) { + s1 = peg$parsesingleLine(); + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c10(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsesingleLine() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseKW_SINGLE_LINE_START(); + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c11.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c12); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c11.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c12); } + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c13(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsemultiLine() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseKW_MULTI_LINE_START(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c14) { + s5 = peg$c14; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c15); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = void 0; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c16(s1, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c14) { + s5 = peg$c14; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c15); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = void 0; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c1); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c16(s1, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseKW_MULTI_LINE_END(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c17(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsequote() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c18; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c19); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c20.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c21); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c20.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c21); } + } + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c18; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c19); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c22(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c23; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c25.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c26); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c25.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c26); } + } + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c23; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c22(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parsekw_start() { + var s0; + + s0 = peg$parseKW_SINGLE_LINE_START(); + if (s0 === peg$FAILED) { + s0 = peg$parseKW_MULTI_LINE_START(); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s0 = peg$c18; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c19); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s0 = peg$c23; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s0 = peg$c5; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + } + } + } + } + + return s0; + } + + function peg$parseKW_SINGLE_LINE_START() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c27) { + s0 = peg$c27; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + + return s0; + } + + function peg$parseKW_SINGLE_LINE_END() { + var s0; + + if (peg$c29.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c30); } + } + + return s0; + } + + function peg$parseKW_MULTI_LINE_START() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c31) { + s0 = peg$c31; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c32); } + } + + return s0; + } + + function peg$parseKW_MULTI_LINE_END() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c14) { + s0 = peg$c14; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c15); } + } + + 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$parsewhitespace() { + var s0; + + if (peg$c33.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c34); } + } + + return s0; + } + + + let lines=[]; + let isSplit=false; + + + 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(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } + } + + return { + SyntaxError: peg$SyntaxError, + parse: peg$parse }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); +}); diff --git a/package-lock.json b/package-lock.json index fbb89da..5c0de87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,9 @@ "dev": true }, "pegjs": { - "version": "0.7.0", - "resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.7.0.tgz", - "integrity": "sha1-qqH4JPnnGX7ETiKlevUi9wDdaJ4=", + "version": "0.10.0", + "resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.10.0.tgz", + "integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=", "dev": true } } diff --git a/package.json b/package.json index df2a2f5..7ac7603 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "description": "sql parser", "main": "index.js", "scripts": { - "build:parse": "pegjs peg/nquery.pegjs core/astParser.js", - "build:filter":"pegjs peg/comment.pegjs core/comment.js" + "build:parse": "pegjs -o core/astParser.js peg/nquery.pegjs ", + "build:filter": "pegjs -o core/comment.js peg/comment.pegjs " }, "author": "xiaokang", "license": "ISC", "devDependencies": { "node-query": "^0.3.3", - "pegjs": "^0.7.0" + "pegjs": "^0.10.0" }, "dependencies": {} } diff --git a/peg/build.js b/peg/build.js index 22a309b..92bfcf3 100644 --- a/peg/build.js +++ b/peg/build.js @@ -2,6 +2,8 @@ const pegjs=require("pegjs"); const path=require("path"); const fs=require("fs"); +const ENCODING="utf8" + const files=[{ source:path.resolve(process.cwd(),"./peg/comment.pegjs") , target:path.resolve(process.cwd(),"./core/comment.js") , @@ -10,5 +12,19 @@ const files=[{ target:path.resolve(process.cwd(),"./core/astParser.js") , }]; -const file=fs.readFileSync(files[0].source,{encoding:"utf8"}) -pegjs.buildParser(file); \ No newline at end of file + +function writeIn(file,data){ + fs.writeFileSync(file,data,{encoding:ENCODING}) +} +function build(content){ + return pegjs.generate(content,{ + output:"source", + format:"umd" + }); +} +files.forEach( + (file)=>{ + let fileContent=fs.readFileSync(file.source,{encoding:ENCODING}) + writeIn(file.target,build(fileContent)) + } +) diff --git a/peg/nquery.pegjs b/peg/nquery.pegjs index ce0c875..84a0f6a 100644 --- a/peg/nquery.pegjs +++ b/peg/nquery.pegjs @@ -278,7 +278,7 @@ table_name db : '', table : dt } - if (tail != '') { + if (tail) { obj.db = dt; obj.table = tail[3]; }