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) + '"'; } 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(); } } 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, 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; var pos0, pos1; pos0 = pos; pos1 = pos; result0 = []; if (result0 !== null) { result0 = (function(offset) { params = []; return true; })(pos0); } if (result0 === null) { pos = pos0; } 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; } } 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) { 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) { 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) { return { type : 'select', distinct : d, columns : c, from : f, where : w, groupby : g, 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) { 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) { 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) { 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) { t.join = op; t.on = expr; return t; /* return { db : t.db, table : t.table, as : t.as, join : op, 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) { if (t.type == 'var') { t.as = alias; return t; } else { return { db : t.db, table : t.table, 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) { var obj = { db : '', table : dt } 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) { var obj = { expr : e, type : 'ASC' } if (d == 'DESC') { 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) { var res = [i1]; if (tail == '') { res.unshift({ type : 'number', value : 0 }); } else { 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) { return { type : 'update', db : t.db, table : t.table, 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) { 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) { return { type : ri, db : t.db, table : t.table, 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) { 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) { 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; var pos0, pos1; result0 = parse_expr_list(); if (result0 === null) { pos0 = pos; pos1 = pos; result0 = []; if (result0 !== null) { result0 = (function(offset) { return { type : 'expr_list', value : [] } })(pos0); } if (result0 === null) { pos = pos0; } } 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; } } 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) { 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) { 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) { if (rh == '') { return left; } else { var res = null; if (rh.type == 'arithmetic') { res = createBinaryExprChain(left, rh.tail); } else { res = createBinaryExpr(rh.op, left, rh.right); } return res; } })(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) { 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) { 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) { return { op : op, right : { type : 'expr_list', 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) { 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) { 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) { return { op : op, right : l } })(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) { 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) { 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) { 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) { var p = { type : 'param', value: l[1] } //var key = 'L' + line + 'C' + column; //debug(key); //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) { return { type : 'aggr_func', name : name, args : { 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) { 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) { 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; } } 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { return { stmt : s, vars: varList } })(pos0, result0[2]); } if (result0 === null) { pos = pos0; } return result0; } function parse_proc_init() { var result0; var pos0, pos1; pos0 = pos; pos1 = pos; result0 = []; if (result0 !== null) { result0 = (function(offset) { varList = []; return true; })(pos0); } if (result0 === null) { pos = pos0; } 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) { 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) { 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) { return { type : 'join', ltable : lt, rtable : rt, 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) { //compatible with original func_call return { type : 'function', name : name, args : { type : 'expr_list', 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) { 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) { //push for analysis varList.push(name); return { type : 'var', 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) { 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; } function parse_KW_VAR_PRE() { var result0; if (input.charCodeAt(pos) === 36) { result0 = "$"; pos++; } else { result0 = null; if (reportFailures === 0) { matchFailed("\"$\""); } } 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; } else { column++; seenCR = false; } } return { line: line, column: column }; } 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 = []; 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."; } this.name = "SyntaxError"; this.expected = expected; this.found = found; this.message = buildMessage(expected, found); this.offset = offset; this.line = line; this.column = column; }; result.SyntaxError.prototype = Error.prototype; return result; })();