/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ (function(root, factory) { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof module === "object" && module.exports) { module.exports = factory(); } })(this, function() { "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function(expectation) { return "any character"; }, end: function(expectation) { return "end of input"; }, other: function(expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleIndices = { start: 0 }, peg$startRuleIndex = 0, peg$consts = [ function(ast) { return { ast : ast, param : params } }, function(ast) { return { ast : ast } }, function() { params = []; return true; }, function(head, tail) { var cur = head; for (var i = 0; i < tail.length; i++) { cur._next = tail[i][3]; cur = cur._next } return head; }, "(", peg$literalExpectation("(", false), ")", peg$literalExpectation(")", false), function(s) { return s[2]; }, function(d, c, f, w, g, o, l) { return { type : 'select', distinct : d, columns : c, from : f, where : w, groupby : g, orderby : o, limit : l } }, function() { return '*'; }, function(head, tail) { return createList(head, tail); }, function(e, alias) { return { expr : e, as : alias }; }, function(i) { return i; }, function(l) { return l; }, function(head, tail) { tail.unshift(head); return tail; }, function(t) { return t; }, function(op, t, expr) { t.join = op; t.on = expr; return t; /* return { db : t.db, table : t.table, as : t.as, join : op, on : expr } */ }, function(t, alias) { if (t.type == 'var') { t.as = alias; return t; } else { return { db : t.db, table : t.table, as : alias } } }, function() { return 'LEFT JOIN'; }, function() { return 'INNER JOIN'; }, function(dt, tail) { var obj = { db : '', table : dt } if (tail) { obj.db = dt; obj.table = tail[3]; } return obj; }, function(v) { v.db = ''; v.table = v.name; return v; }, function(e) { return e; }, function(e, d) { var obj = { expr : e, type : 'ASC' } if (d == 'DESC') { obj.type = 'DESC'; } return obj; }, function(i1, tail) { var res = [i1]; if (tail == '') { res.unshift({ type : 'number', value : 0 }); } else { res.push(tail[2]); } return res; }, function(t, l, w) { return { type : 'update', db : t.db, table : t.table, set : l, where : w } }, "=", peg$literalExpectation("=", false), function(c, v) { return { column: c, value : v } }, function(ri, t, c, v) { return { type : ri, db : t.db, table : t.table, columns : c, values : v } }, function() { return 'insert'; }, function() { return 'replace' }, function(l) { return l; }, function(head, tail) { var el = { type : 'expr_list' } var l = createExprList(head, tail, el); el.value = l; return el; }, function() { return { type : 'expr_list', value : [] } }, function(head, tail) { return createBinaryExprChain(head, tail); }, "!", peg$literalExpectation("!", false), function(expr) { return createUnaryExpr('NOT', expr); }, function(left, rh) { if (rh == '') { return left; } else { var res = null; if (rh.type == 'arithmetic') { res = createBinaryExprChain(left, rh.tail); } else { res = createBinaryExpr(rh.op, left, rh.right); } return res; } }, function(l) { return { type : 'arithmetic', tail : l } }, ">=", peg$literalExpectation(">=", false), ">", peg$literalExpectation(">", false), "<=", peg$literalExpectation("<=", false), "<>", peg$literalExpectation("<>", false), "<", peg$literalExpectation("<", false), "!=", peg$literalExpectation("!=", false), function(op, right) { return { op : op, right : right } }, function(op, begin, end) { return { op : op, right : { type : 'expr_list', value : [begin, end] } } }, function(nk) { return nk[0] + ' ' + nk[2]; }, function(op, right) { return { op : op, right : right } }, function(op, l) { return { op : op, right : l } }, function(op, e) { return { op : op, right : e } }, "+", peg$literalExpectation("+", false), "-", peg$literalExpectation("-", false), function(head, tail) { return createBinaryExprChain(head, tail) }, "*", peg$literalExpectation("*", false), "/", peg$literalExpectation("/", false), "%", peg$literalExpectation("%", false), function(e) { e.paren = true; return e; }, function(tbl, col) { return { type : 'column_ref', table : tbl, column : col }; }, function(col) { return { type : 'column_ref', table : '', column: col }; }, function(name) { return reservedMap[name.toUpperCase()] === true; }, function(name) { return name; }, "`", peg$literalExpectation("`", false), /^[^`]/, peg$classExpectation(["`"], true, false), function(chars) { return chars.join(''); }, function(start, parts) { return start + parts.join(''); }, /^[A-Za-z_]/, peg$classExpectation([["A", "Z"], ["a", "z"], "_"], false, false), /^[A-Za-z0-9_]/, peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false), /^[A-Za-z0-9_:]/, peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", ":"], false, false), ":", peg$literalExpectation(":", false), function(l) { var p = { type : 'param', value: l[1] } //var key = 'L' + line + 'C' + column; //debug(key); //params[key] = p; params.push(p); return p; }, function(name, e) { return { type : 'aggr_func', name : name, args : { expr : e } } }, function(name, arg) { return { type : 'aggr_func', name : name, args : arg } }, function(e) { return { expr : e } }, function(d, c) { return { distinct : d, expr : c } }, function() { return { type : 'star', value : '*' } }, function(name, l) { return { type : 'function', name : name, args : l } }, function(head, tail) { return createList(head, tail); }, function() { return { type : 'null', value : null }; }, function() { return { type : 'bool', value : true }; }, function() { return { type : 'bool', value : false }; }, "\"", peg$literalExpectation("\"", false), "'", peg$literalExpectation("'", false), function(ca) { return { type : 'string', value : ca[1].join('') } }, /^[^'\\\0-\x1F\x7F]/, peg$classExpectation(["'", "\\", ["\0", "\x1F"], "\x7F"], true, false), /^[^"\\\0-\x1F\x7F]/, peg$classExpectation(["\"", "\\", ["\0", "\x1F"], "\x7F"], true, false), "\\'", peg$literalExpectation("\\'", false), function() { return "'"; }, "\\\"", peg$literalExpectation("\\\"", false), function() { return '"'; }, "\\\\", peg$literalExpectation("\\\\", false), function() { return "\\"; }, "\\/", peg$literalExpectation("\\/", false), function() { return "/"; }, "\\b", peg$literalExpectation("\\b", false), function() { return "\b"; }, "\\f", peg$literalExpectation("\\f", false), function() { return "\f"; }, "\\n", peg$literalExpectation("\\n", false), function() { return "\n"; }, "\\r", peg$literalExpectation("\\r", false), function() { return "\r"; }, "\\t", peg$literalExpectation("\\t", false), function() { return "\t"; }, "\\u", peg$literalExpectation("\\u", false), function(h1, h2, h3, h4) { return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); }, /^[\n\r]/, peg$classExpectation(["\n", "\r"], false, false), function(n) { return { type : 'number', value : n } }, function(int_, frac, exp) { return parseFloat(int_ + frac + exp); }, function(int_, frac) { return parseFloat(int_ + frac); }, function(int_, exp) { return parseFloat(int_ + exp); }, function(int_) { return parseFloat(int_); }, function(digit19, digits) { return digit19 + digits; }, function(op, digit19, digits) { return "-" + digit19 + digits; }, function(op, digit) { return "-" + digit; }, ".", peg$literalExpectation(".", false), function(digits) { return "." + digits; }, function(e, digits) { return e + digits; }, function(digits) { return digits.join(""); }, /^[0-9]/, peg$classExpectation([["0", "9"]], false, false), /^[1-9]/, peg$classExpectation([["1", "9"]], false, false), /^[0-9a-fA-F]/, peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), /^[eE]/, peg$classExpectation(["e", "E"], false, false), /^[+\-]/, peg$classExpectation(["+", "-"], false, false), function(e, sign) { return e + sign; }, "null", peg$literalExpectation("NULL", true), "true", peg$literalExpectation("TRUE", true), "false", peg$literalExpectation("FALSE", true), "show", peg$literalExpectation("SHOW", true), "drop", peg$literalExpectation("DROP", true), "select", peg$literalExpectation("SELECT", true), "update", peg$literalExpectation("UPDATE", true), "create", peg$literalExpectation("CREATE", true), "delete", peg$literalExpectation("DELETE", true), "insert", peg$literalExpectation("INSERT", true), "replace", peg$literalExpectation("REPLACE", true), "explain", peg$literalExpectation("EXPLAIN", true), "into", peg$literalExpectation("INTO", true), "from", peg$literalExpectation("FROM", true), "set", peg$literalExpectation("SET", true), "as", peg$literalExpectation("AS", true), "table", peg$literalExpectation("TABLE", true), "on", peg$literalExpectation("ON", true), "left", peg$literalExpectation("LEFT", true), "inner", peg$literalExpectation("INNER", true), "join", peg$literalExpectation("JOIN", true), "union", peg$literalExpectation("UNION", true), "values", peg$literalExpectation("VALUES", true), "exists", peg$literalExpectation("EXISTS", true), "where", peg$literalExpectation("WHERE", true), "group", peg$literalExpectation("GROUP", true), "by", peg$literalExpectation("BY", true), "order", peg$literalExpectation("ORDER", true), "having", peg$literalExpectation("HAVING", true), "limit", peg$literalExpectation("LIMIT", true), "asc", peg$literalExpectation("ASC", true), function() { return 'ASC'; }, "desc", peg$literalExpectation("DESC", true), function() { return 'DESC'; }, "all", peg$literalExpectation("ALL", true), function() { return 'ALL'; }, "distinct", peg$literalExpectation("DISTINCT", true), function() { return 'DISTINCT';}, "between", peg$literalExpectation("BETWEEN", true), function() { return 'BETWEEN'; }, "in", peg$literalExpectation("IN", true), function() { return 'IN'; }, "is", peg$literalExpectation("IS", true), function() { return 'IS'; }, "like", peg$literalExpectation("LIKE", true), function() { return 'LIKE'; }, "contains", peg$literalExpectation("CONTAINS", true), function() { return 'CONTAINS';}, "not", peg$literalExpectation("NOT", true), function() { return 'NOT'; }, "and", peg$literalExpectation("AND", true), function() { return 'AND'; }, "or", peg$literalExpectation("OR", true), function() { return 'OR'; }, "count", peg$literalExpectation("COUNT", true), function() { return 'COUNT'; }, "max", peg$literalExpectation("MAX", true), function() { return 'MAX'; }, "min", peg$literalExpectation("MIN", true), function() { return 'MIN'; }, "sum", peg$literalExpectation("SUM", true), function() { return 'SUM'; }, "avg", peg$literalExpectation("AVG", true), function() { return 'AVG'; }, ",", peg$literalExpectation(",", false), "[", peg$literalExpectation("[", false), "]", peg$literalExpectation("]", false), peg$anyExpectation(), /^[ \t\n\r]/, peg$classExpectation([" ", "\t", "\n", "\r"], false, false), function(s) { return { stmt : s, vars: varList } }, function() { varList = []; return true; }, function(va, e) { return { type : 'assign', left : va, right: e } }, function(e) { return { type : 'return', expr: e } }, function(lt, op, rt, expr) { return { type : 'join', ltable : lt, rtable : rt, op : op, on : expr } }, function(name, l) { //compatible with original func_call return { type : 'function', name : name, args : { type : 'expr_list', value : l } } }, function(l) { return { type : 'array', value : l } }, function(name, m) { //push for analysis varList.push(name); return { type : 'var', name : name, members : m } }, function(l) { var s = []; for (var i = 0; i < l.length; i++) { s.push(l[i][1]); } return s; }, "$", peg$literalExpectation("$", false), "return", peg$literalExpectation("return", true), ":=", peg$literalExpectation(":=", false) ], peg$bytecode = [ peg$decode("%%<;!=/##&'!&&#/F#;\xB1/=$;\".) &;9.# &;#;\x90/5$;\xB1/,$;#/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\x90/5$;\xB1/,$;#/#$+$)($'#(#'#(\"'#&'#&/)$8\":#\"\"! )(\"'#&'#"), peg$decode(";$.i &%%2$\"\"6$7%/M#;\xB1/D$;#/;$;\xB1/2$2&\"\"6&7'/#$+%)(%'#($'#(#'#(\"'#&'#/' 8!:(!! )"), peg$decode("%;\x80/\xCA#;\xB1/\xC1$;\x9C.\" &\"/\xB3$;\xB1/\xAA$;%/\xA1$;\xB1/\x98$;(.\" &\"/\x8A$;\xB1/\x81$;0.\" &\"/s$;\xB1/j$;1.\" &\"/\\$;\xB1/S$;4.\" &\"/E$;\xB1/<$;8.\" &\"/.$8/:)/',*(&$\" )(/'#(.'#(-'#(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\x9B.B &%;\xAC/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#/& 8!:*! ).\x8D &%;&/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;&/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;&/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;R/@#;\xB1/7$;'.\" &\"/)$8#:,#\"\" )(#'#(\"'#&'#"), peg$decode("%;\x8A.\" &\"/:#;\xB1/1$;Y/($8#:-#! )(#'#(\"'#&'#"), peg$decode("%;\x88/:#;\xB1/1$;)/($8#:.#! )(#'#(\"'#&'#"), peg$decode("%;,/9#$;*0#*;*&/)$8\":/\"\"! )(\"'#&'#"), peg$decode("%;\xB1/C#;\xAB/:$;\xB1/1$;,/($8$:0$! )($'#(#'#(\"'#&'#.; &%;\xB1/1#;+/($8\":0\"! )(\"'#&'#"), peg$decode("%;-/S#;\xB1/J$;,/A$;\xB1/8$;/.\" &\"/*$8%:1%#$\" )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;./W#;\xB1/N$;\x8A.\" &\"/@$;\xB1/7$;Y.\" &\"/)$8%:2%\"$ )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\x8D/9#;\xB1/0$;\x8F/'$8#:3# )(#'#(\"'#&'#.R &%%;\x8E/,#;\xB1/#$+\")(\"'#&'#.\" &\"/0#;\x8F/'$8\":4\" )(\"'#&'#"), peg$decode("%;Y/\\#%;\xB1/>#;\xAA/5$;\xB1/,$;\\/#$+$)($'#(#'#(\"'#&'#.\" &\"/)$8\":5\"\"! )(\"'#&'#./ &%;\xC3/' 8!:6!! )"), peg$decode("%;\x8C/:#;\xB1/1$;C/($8#:7#! )(#'#(\"'#&'#"), peg$decode("%;\x93/:#;\xB1/1$;C/($8#:7#! )(#'#(\"'#&'#"), peg$decode("%;\x94/L#;\xB1/C$;\x95/:$;\xB1/1$;2/($8%:.%! )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;W/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;W/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;W/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;\x97/1#;C/($8\":7\"! )(\"'#&'#"), peg$decode("%;\x96/L#;\xB1/C$;\x95/:$;\xB1/1$;5/($8%:.%! )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;6/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;6/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;6/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;C/F#;\xB1/=$;\x9A.# &;\x99.\" &\"/)$8#:8#\"\" )(#'#(\"'#&'#"), peg$decode(";q.# &;`"), peg$decode("%;\x98/n#;\xB1/e$;7/\\$;\xB1/S$%;\xAB/5#;\xB1/,$;7/#$+#)(#'#(\"'#&'#.\" &\"/)$8%:9%\"\" )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\x81/r#;\xB1/i$;./`$;\xB1/W$;\x89/N$;\xB1/E$;:/<$;\xB1/3$;0/*$8)::)#&\" )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;;/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;;/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;;/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;[/S#;\xB1/J$2;\"\"6;7/+$8-:>-$,($ )(-'#(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\x84/& 8!:?! ).. &%;\x85/& 8!:@! )"), peg$decode("%;\x91/:#;\xB1/1$;?/($8#:.#! )(#'#(\"'#&'#"), peg$decode("%;@/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;@/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;@/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;\xAD/L#;\xB1/C$;A/:$;\xB1/1$;\xAE/($8%:A%!\")(%'#($'#(#'#(\"'#&'#"), peg$decode("%;C/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;C/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;C/#$+$)($'#(#'#(\"'#&'#&/)$8\":B\"\"! )(\"'#&'#"), peg$decode(";A.- &9:C -\"\"&!&#"), peg$decode("%;D/\x83#$%;\xB1/>#;\xA4/5$;\xB1/,$;D/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xA4/5$;\xB1/,$;D/#$+$)($'#(#'#(\"'#&'#&/)$8\":D\"\"! )(\"'#&'#"), peg$decode("%;E/\x83#$%;\xB1/>#;\xA3/5$;\xB1/,$;E/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xA3/5$;\xB1/,$;E/#$+$)($'#(#'#(\"'#&'#&/)$8\":D\"\"! )(\"'#&'#"), peg$decode("%;\xA2.N &%2E\"\"6E7F/>#%<2;\"\"6;7<=.##&&!&'#/#$+\")(\"'#&'#/:#;\xB1/1$;E/($8#:G#! )(#'#(\"'#&'#.# &;F"), peg$decode("%;R/@#;\xB1/7$;G.\" &\"/)$8#:H#\"\" )(#'#(\"'#&'#"), peg$decode(";H.; &;P.5 &;K./ &;J.) &;O.# &;Q"), peg$decode("%$%;\xB1/>#;I/5$;\xB1/,$;R/#$+$)($'#(#'#(\"'#&'#/K#0H*%;\xB1/>#;I/5$;\xB1/,$;R/#$+$)($'#(#'#(\"'#&'#&&&#/' 8!:I!! )"), peg$decode("2J\"\"6J7K.e &2L\"\"6L7M.Y &2N\"\"6N7O.M &2P\"\"6P7Q.A &2R\"\"6R7S.5 &2;\"\"6;7<.) &2T\"\"6T7U"), peg$decode("%;\x9F/;#;\xB1/2$;R/)$8#:V#\"\" )(#'#(\"'#&'#"), peg$decode("%;\x9D/`#;\xB1/W$;R/N$;\xB1/E$;\xA3/<$;\xB1/3$;R/*$8':W'#&$ )(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%%;\xA2/5#;\xB1/,$;\xA0/#$+#)(#'#(\"'#&'#/' 8!:X!! ).# &;\xA0"), peg$decode("%%;\xA2/5#;\xB1/,$;\x9E/#$+#)(#'#(\"'#&'#/' 8!:X!! ).# &;\x9E"), peg$decode("%%;\xA2/5#;\xB1/,$;\xA1/#$+#)(#'#(\"'#&'#/' 8!:X!! ).# &;\xA1"), peg$decode("%;L/;#;\xB1/2$;F/)$8#:Y#\"\" )(#'#(\"'#&'#"), peg$decode("%;M/_#;\xB1/V$;\xAD/M$;\xB1/D$;A/;$;\xB1/2$;\xAE/)$8':Z'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#.E &%;M/;#;\xB1/2$;\xC3/)$8#:[#\"\" )(#'#(\"'#&'#"), peg$decode("%;N/_#;\xB1/V$;\xAD/M$;\xB1/D$;A/;$;\xB1/2$;\xAE/)$8':Z'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#.E &%;N/;#;\xB1/2$;\xC3/)$8#:[#\"\" )(#'#(\"'#&'#"), peg$decode("%;T/\x83#$%;\xB1/>#;S/5$;\xB1/,$;T/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;S/5$;\xB1/,$;T/#$+$)($'#(#'#(\"'#&'#&/)$8\":D\"\"! )(\"'#&'#"), peg$decode("2\\\"\"6\\7].) &2^\"\"6^7_"), peg$decode("%;V/\x83#$%;\xB1/>#;U/5$;\xB1/,$;V/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;U/5$;\xB1/,$;V/#$+$)($'#(#'#(\"'#&'#&/)$8\":`\"\"! )(\"'#&'#"), peg$decode("2a\"\"6a7b.5 &2c\"\"6c7d.) &2e\"\"6e7f"), peg$decode(";h.t &;a.n &;g.h &;W.b &;`.\\ &%;\xAD/L#;\xB1/C$;C/:$;\xB1/1$;\xAE/($8%:g%!\")(%'#($'#(#'#(\"'#&'#.# &;\xC3"), peg$decode("%;Y/M#;\xB1/D$;\xAA/;$;\xB1/2$;Z/)$8%:h%\"$ )(%'#($'#(#'#(\"'#&'#./ &%;Z/' 8!:i!! )"), peg$decode("%;Z/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;Z/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;Z/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;\\/<#9:j ! -\"\"&#&!/($8\":k\"!!)(\"'#&'#"), peg$decode("%;[/<#9:j ! -\"\"&#&!/($8\":k\"!!)(\"'#&'#.i &%2l\"\"6l7m/Y#$4n\"\"5!7o/,#0)*4n\"\"5!7o&&&#/7$2l\"\"6l7m/($8#:p#!!)(#'#(\"'#&'#"), peg$decode("%;]/9#$;_0#*;_&/)$8\":q\"\"! )(\"'#&'#"), peg$decode("%;]/9#$;^0#*;^&/)$8\":q\"\"! )(\"'#&'#"), peg$decode("4r\"\"5!7s"), peg$decode("4t\"\"5!7u"), peg$decode("4v\"\"5!7w"), peg$decode("%%2x\"\"6x7y/,#;\\/#$+\")(\"'#&'#/' 8!:z!! )"), peg$decode(";d.# &;b"), peg$decode("%;c/_#;\xB1/V$;\xAD/M$;\xB1/D$;R/;$;\xB1/2$;\xAE/)$8':{'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode(";\xA8./ &;\xA6.) &;\xA7.# &;\xA9"), peg$decode("%;\xA5/_#;\xB1/V$;\xAD/M$;\xB1/D$;e/;$;\xB1/2$;\xAE/)$8':|'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;f/' 8!:}!! ).J &%;\x9C.\" &\"/;#;\xB1/2$;W/)$8#:~#\"\" )(#'#(\"'#&'#"), peg$decode("%2a\"\"6a7b/& 8!:\x7F! )"), peg$decode("%;Y/_#;\xB1/V$;\xAD/M$;\xB1/D$;B/;$;\xB1/2$;\xAE/)$8':\x80'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode(";l./ &;q.) &;k.# &;j"), peg$decode("%;h/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;h/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;h/#$+$)($'#(#'#(\"'#&'#&/)$8\":\x81\"\"! )(\"'#&'#"), peg$decode("%;{/& 8!:\x82! )"), peg$decode("%;|/& 8!:\x83! ).. &%;}/& 8!:\x84! )"), peg$decode("%%2\x85\"\"6\x857\x86/B#$;n0#*;n&/2$2\x85\"\"6\x857\x86/#$+#)(#'#(\"'#&'#.R &%2\x87\"\"6\x877\x88/B#$;m0#*;m&/2$2\x87\"\"6\x877\x88/#$+#)(#'#(\"'#&'#/' 8!:\x89!! )"), peg$decode("4\x8A\"\"5!7\x8B.# &;o"), peg$decode("4\x8C\"\"5!7\x8D.# &;o"), peg$decode("%2\x8E\"\"6\x8E7\x8F/& 8!:\x90! ).\u0117 &%2\x91\"\"6\x917\x92/& 8!:\x93! ).\u0100 &%2\x94\"\"6\x947\x95/& 8!:\x96! ).\xE9 &%2\x97\"\"6\x977\x98/& 8!:\x99! ).\xD2 &%2\x9A\"\"6\x9A7\x9B/& 8!:\x9C! ).\xBB &%2\x9D\"\"6\x9D7\x9E/& 8!:\x9F! ).\xA4 &%2\xA0\"\"6\xA07\xA1/& 8!:\xA2! ).\x8D &%2\xA3\"\"6\xA37\xA4/& 8!:\xA5! ).v &%2\xA6\"\"6\xA67\xA7/& 8!:\xA8! )._ &%2\xA9\"\"6\xA97\xAA/O#;y/F$;y/=$;y/4$;y/+$8%:\xAB%$#\"! )(%'#($'#(#'#(\"'#&'#"), peg$decode("4\xAC\"\"5!7\xAD"), peg$decode("%;r/' 8!:\xAE!! )"), peg$decode("%;s/E#;t/<$;u/3$;\xB1/*$8$:\xAF$##\"!)($'#(#'#(\"'#&'#.\x8B &%;s/;#;t/2$;\xB1/)$8#:\xB0#\"\"!)(#'#(\"'#&'#.c &%;s/;#;u/2$;\xB1/)$8#:\xB1#\"\"!)(#'#(\"'#&'#.; &%;s/1#;\xB1/($8\":\xB2\"!!)(\"'#&'#"), peg$decode("%;x/2#;v/)$8\":\xB3\"\"! )(\"'#&'#.\x8F &;w.\x89 &%2^\"\"6^7_.) &2\\\"\"6\\7]/<#;x/3$;v/*$8#:\xB4##\"! )(#'#(\"'#&'#.N &%2^\"\"6^7_.) &2\\\"\"6\\7]/2#;w/)$8\":\xB5\"\"! )(\"'#&'#"), peg$decode("%2\xB6\"\"6\xB67\xB7/1#;v/($8\":\xB8\"! )(\"'#&'#"), peg$decode("%;z/2#;v/)$8\":\xB9\"\"! )(\"'#&'#"), peg$decode("%$;w/�#*;w&&&#/' 8!:\xBA!! )"), peg$decode("4\xBB\"\"5!7\xBC"), peg$decode("4\xBD\"\"5!7\xBE"), peg$decode("4\xBF\"\"5!7\xC0"), peg$decode("%4\xC1\"\"5!7\xC2/=#4\xC3\"\"5!7\xC4.\" &\"/)$8\":\xC5\"\"! )(\"'#&'#"), peg$decode("%3\xC6\"\"5$7\xC7/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xC8\"\"5$7\xC9/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xCA\"\"5%7\xCB/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xCC\"\"5$7\xCD/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xCE\"\"5$7\xCF/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xD0\"\"5&7\xD1/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xD2\"\"5&7\xD3/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xD4\"\"5&7\xD5/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xD6\"\"5&7\xD7/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xD8\"\"5&7\xD9/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xDA\"\"5'7\xDB/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xDC\"\"5'7\xDD/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xDE\"\"5$7\xDF/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xE0\"\"5$7\xE1/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xE2\"\"5#7\xE3/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xE4\"\"5\"7\xE5/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xE6\"\"5%7\xE7/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xE8\"\"5\"7\xE9/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xEA\"\"5$7\xEB/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xEC\"\"5%7\xED/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xEE\"\"5$7\xEF/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xF0\"\"5%7\xF1/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xF2\"\"5&7\xF3/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xF4\"\"5&7\xF5/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xF6\"\"5%7\xF7/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xF8\"\"5%7\xF9/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xFA\"\"5\"7\xFB/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xFC\"\"5%7\xFD/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\xFE\"\"5&7\xFF/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\u0100\"\"5%7\u0101/8#%<;]=.##&&!&'#/#$+\")(\"'#&'#"), peg$decode("%3\u0102\"\"5#7\u0103/<#%<;]=.##&&!&'#/'$8\":\u0104\" )(\"'#&'#"), peg$decode("%3\u0105\"\"5$7\u0106/<#%<;]=.##&&!&'#/'$8\":\u0107\" )(\"'#&'#"), peg$decode("%3\u0108\"\"5#7\u0109/<#%<;]=.##&&!&'#/'$8\":\u010A\" )(\"'#&'#"), peg$decode("%3\u010B\"\"5(7\u010C/<#%<;]=.##&&!&'#/'$8\":\u010D\" )(\"'#&'#"), peg$decode("%3\u010E\"\"5'7\u010F/<#%<;]=.##&&!&'#/'$8\":\u0110\" )(\"'#&'#"), peg$decode("%3\u0111\"\"5\"7\u0112/<#%<;]=.##&&!&'#/'$8\":\u0113\" )(\"'#&'#"), peg$decode("%3\u0114\"\"5\"7\u0115/<#%<;]=.##&&!&'#/'$8\":\u0116\" )(\"'#&'#"), peg$decode("%3\u0117\"\"5$7\u0118/<#%<;]=.##&&!&'#/'$8\":\u0119\" )(\"'#&'#"), peg$decode("%3\u011A\"\"5(7\u011B/<#%<;]=.##&&!&'#/'$8\":\u011C\" )(\"'#&'#"), peg$decode("%3\u011D\"\"5#7\u011E/<#%<;]=.##&&!&'#/'$8\":\u011F\" )(\"'#&'#"), peg$decode("%3\u0120\"\"5#7\u0121/<#%<;]=.##&&!&'#/'$8\":\u0122\" )(\"'#&'#"), peg$decode("%3\u0123\"\"5\"7\u0124/<#%<;]=.##&&!&'#/'$8\":\u0125\" )(\"'#&'#"), peg$decode("%3\u0126\"\"5%7\u0127/<#%<;]=.##&&!&'#/'$8\":\u0128\" )(\"'#&'#"), peg$decode("%3\u0129\"\"5#7\u012A/<#%<;]=.##&&!&'#/'$8\":\u012B\" )(\"'#&'#"), peg$decode("%3\u012C\"\"5#7\u012D/<#%<;]=.##&&!&'#/'$8\":\u012E\" )(\"'#&'#"), peg$decode("%3\u012F\"\"5#7\u0130/<#%<;]=.##&&!&'#/'$8\":\u0131\" )(\"'#&'#"), peg$decode("%3\u0132\"\"5#7\u0133/<#%<;]=.##&&!&'#/'$8\":\u0134\" )(\"'#&'#"), peg$decode("2\xB6\"\"6\xB67\xB7"), peg$decode("2\u0135\"\"6\u01357\u0136"), peg$decode("2a\"\"6a7b"), peg$decode("2$\"\"6$7%"), peg$decode("2&\"\"6&7'"), peg$decode("2\u0137\"\"6\u01377\u0138"), peg$decode("2\u0139\"\"6\u01397\u013A"), peg$decode("$;\xB30#*;\xB3&"), peg$decode("1\"\"5!7\u013B"), peg$decode("4\u013C\"\"5!7\u013D"), peg$decode(";\xB5.< &$4\xAC\"\"5!7\xAD/,#0)*4\xAC\"\"5!7\xAD&&&#"), peg$decode("%<1\"\"5!7\u013B=.##&&!&'#"), peg$decode("$;\xB70#*;\xB7&"), peg$decode("%%<;\xB8=/##&'!&&#/@#;\xB1/7$;\xB9.# &;\xBA/($8#:\u013E#! )(#'#(\"'#&'#"), peg$decode("9:\u013F -\"\"&!&#"), peg$decode("%;\xC3/M#;\xB1/D$;\xC7/;$;\xB1/2$;\xBB/)$8%:\u0140%\"$ )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\xC6/:#;\xB1/1$;\xBB/($8#:\u0141#! )(#'#(\"'#&'#"), peg$decode(";#./ &;\xBE.) &;\xBC.# &;\xC2"), peg$decode("%;\xBD/\x83#$%;\xB1/>#;S/5$;\xB1/,$;\xBD/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;S/5$;\xB1/,$;\xBD/#$+$)($'#(#'#(\"'#&'#&/)$8\":D\"\"! )(\"'#&'#"), peg$decode("%;\xBF/\x83#$%;\xB1/>#;U/5$;\xB1/,$;\xBF/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;U/5$;\xB1/,$;\xBF/#$+$)($'#(#'#(\"'#&'#&/)$8\":D\"\"! )(\"'#&'#"), peg$decode("%;\xC3/a#;\xB1/X$;-/O$;\xB1/F$;\xC3/=$;\xB1/4$;//+$8':\u0142'$&$\" )(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode(";h.h &;\xC3.b &;\xC0.\\ &;`.V &%;\xAD/L#;\xB1/C$;\xBC/:$;\xB1/1$;\xAE/($8%:g%!\")(%'#($'#(#'#(\"'#&'#"), peg$decode("%;Y/_#;\xB1/V$;\xAD/M$;\xB1/D$;\xC1/;$;\xB1/2$;\xAE/)$8':\u0143'\"&\")(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\xBF/\x83#$%;\xB1/>#;\xAB/5$;\xB1/,$;\xBF/#$+$)($'#(#'#(\"'#&'#0H*%;\xB1/>#;\xAB/5$;\xB1/,$;\xBF/#$+$)($'#(#'#(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), peg$decode("%;\xAF/L#;\xB1/C$;\xC1/:$;\xB1/1$;\xB0/($8%:\u0144%!\")(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\xC5/;#;\\/2$;\xC4/)$8#:\u0145#\"! )(#'#(\"'#&'#"), peg$decode("%$%2\xB6\"\"6\xB67\xB7/,#;\\/#$+\")(\"'#&'#0<*%2\xB6\"\"6\xB67\xB7/,#;\\/#$+\")(\"'#&'#&/' 8!:\u0146!! )"), peg$decode("2\u0147\"\"6\u01477\u0148"), peg$decode("3\u0149\"\"5&7\u014A"), peg$decode("2\u014B\"\"6\u014B7\u014C") ], peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleIndices)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleIndex = peg$startRuleIndices[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location ); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError( peg$SyntaxError.buildMessage(expected, found), expected, found, location ); } function peg$decode(s) { var bc = new Array(s.length), i; for (i = 0; i < s.length; i++) { bc[i] = s.charCodeAt(i) - 32; } return bc; } function peg$parseRule(index) { var bc = peg$bytecode[index], ip = 0, ips = [], end = bc.length, ends = [], stack = [], params, i; while (true) { while (ip < end) { switch (bc[ip]) { case 0: stack.push(peg$consts[bc[ip + 1]]); ip += 2; break; case 1: stack.push(void 0); ip++; break; case 2: stack.push(null); ip++; break; case 3: stack.push(peg$FAILED); ip++; break; case 4: stack.push([]); ip++; break; case 5: stack.push(peg$currPos); ip++; break; case 6: stack.pop(); ip++; break; case 7: peg$currPos = stack.pop(); ip++; break; case 8: stack.length -= bc[ip + 1]; ip += 2; break; case 9: stack.splice(-2, 1); ip++; break; case 10: stack[stack.length - 2].push(stack.pop()); ip++; break; case 11: stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1])); ip += 2; break; case 12: stack.push(input.substring(stack.pop(), peg$currPos)); ip++; break; case 13: ends.push(end); ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); if (stack[stack.length - 1]) { end = ip + 3 + bc[ip + 1]; ip += 3; } else { end = ip + 3 + bc[ip + 1] + bc[ip + 2]; ip += 3 + bc[ip + 1]; } break; case 14: ends.push(end); ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); if (stack[stack.length - 1] === peg$FAILED) { end = ip + 3 + bc[ip + 1]; ip += 3; } else { end = ip + 3 + bc[ip + 1] + bc[ip + 2]; ip += 3 + bc[ip + 1]; } break; case 15: ends.push(end); ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); if (stack[stack.length - 1] !== peg$FAILED) { end = ip + 3 + bc[ip + 1]; ip += 3; } else { end = ip + 3 + bc[ip + 1] + bc[ip + 2]; ip += 3 + bc[ip + 1]; } break; case 16: if (stack[stack.length - 1] !== peg$FAILED) { ends.push(end); ips.push(ip); end = ip + 2 + bc[ip + 1]; ip += 2; } else { ip += 2 + bc[ip + 1]; } break; case 17: ends.push(end); ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); if (input.length > peg$currPos) { end = ip + 3 + bc[ip + 1]; ip += 3; } else { end = ip + 3 + bc[ip + 1] + bc[ip + 2]; ip += 3 + bc[ip + 1]; } break; case 18: ends.push(end); ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]) { end = ip + 4 + bc[ip + 2]; ip += 4; } else { end = ip + 4 + bc[ip + 2] + bc[ip + 3]; ip += 4 + bc[ip + 2]; } break; case 19: ends.push(end); ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]) { end = ip + 4 + bc[ip + 2]; ip += 4; } else { end = ip + 4 + bc[ip + 2] + bc[ip + 3]; ip += 4 + bc[ip + 2]; } break; case 20: ends.push(end); ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); if (peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))) { end = ip + 4 + bc[ip + 2]; ip += 4; } else { end = ip + 4 + bc[ip + 2] + bc[ip + 3]; ip += 4 + bc[ip + 2]; } break; case 21: stack.push(input.substr(peg$currPos, bc[ip + 1])); peg$currPos += bc[ip + 1]; ip += 2; break; case 22: stack.push(peg$consts[bc[ip + 1]]); peg$currPos += peg$consts[bc[ip + 1]].length; ip += 2; break; case 23: stack.push(peg$FAILED); if (peg$silentFails === 0) { peg$fail(peg$consts[bc[ip + 1]]); } ip += 2; break; case 24: peg$savedPos = stack[stack.length - 1 - bc[ip + 1]]; ip += 2; break; case 25: peg$savedPos = peg$currPos; ip++; break; case 26: params = bc.slice(ip + 4, ip + 4 + bc[ip + 3]); for (i = 0; i < bc[ip + 3]; i++) { params[i] = stack[stack.length - 1 - params[i]]; } stack.splice( stack.length - bc[ip + 2], bc[ip + 2], peg$consts[bc[ip + 1]].apply(null, params) ); ip += 4 + bc[ip + 3]; break; case 27: stack.push(peg$parseRule(bc[ip + 1])); ip += 2; break; case 28: peg$silentFails++; ip++; break; case 29: peg$silentFails--; ip++; break; default: throw new Error("Invalid opcode: " + bc[ip] + "."); } } if (ends.length > 0) { end = ends.pop(); ip = ips.pop(); } else { break; } } return stack[0]; } var util = require('util'); function debug(str){ console.log(str); } function inspect(obj){ console.log(util.inspect(obj, false, 10)); } function createUnaryExpr(op, e) { return { type : 'unary_expr', operator : op, expr : e } } function createBinaryExpr(op, left, right) { return { type : 'binary_expr', operator : op, left : left, right : right } } function createList(head, tail) { var result = [head]; for (var i = 0; i < tail.length; i++) { result.push(tail[i][3]); } return result; } function createExprList(head, tail, room) { var epList = createList(head, tail); var exprList = []; var ep; for (var i = 0; i < epList.length; i++) { ep = epList[i]; //the ep has already added to the global params if (ep.type == 'param') { ep.room = room; ep.pos = i; } else { exprList.push(ep); } } return exprList; } function createBinaryExprChain(head, tail) { var result = head; for (var i = 0; i < tail.length; i++) { result = createBinaryExpr(tail[i][1], result, tail[i][3]); } return result; } var reservedMap = { 'SHOW' : true, 'DROP' : true, 'SELECT' : true, 'UPDATE' : true, 'CREATE' : true, 'DELETE' : true, 'INSERT' : true, 'REPLACE' : true, 'EXPLAIN' : true, 'ALL' : true, 'DISTINCT': true, 'AS' : true, 'TABLE' : true, 'INTO' : true, 'FROM' : true, 'SET' : true, 'LEFT' : true, 'ON' : true, 'INNER' : true, 'JOIN' : true, 'UNION' : true, 'VALUES' : true, 'EXISTS' : true, 'WHERE' : true, 'GROUP' : true, 'BY' : true, 'HAVING' : true, 'ORDER' : true, 'ASC' : true, 'DESC' : true, 'LIMIT' : true, 'BETWEEN' : true, 'IN' : true, 'IS' : true, 'LIKE' : true, 'CONTAINS': true, 'NOT' : true, 'AND' : true, 'OR' : true, //literal 'TRUE' : true, 'FALSE' : true, 'NULL' : true } var cmpPrefixMap = { '+' : true, '-' : true, '*' : true, '/' : true, '>' : true, '<' : true, '!' : true, '=' : true, //between 'B' : true, 'b' : true, //for is or in 'I' : true, 'i' : true, //for like 'L' : true, 'l' : true, //for not 'N' : true, 'n' : true, //for contains 'C' : true, 'c' : true, } //used for store refered parmas var params = []; //used for dependency analysis var varList = []; peg$result = peg$parseRule(peg$startRuleIndex); if (peg$result !== peg$FAILED && peg$currPos === input.length) { return peg$result; } else { if (peg$result !== peg$FAILED && peg$currPos < input.length) { peg$fail(peg$endExpectation()); } throw peg$buildStructuredError( peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) ); } } return { SyntaxError: peg$SyntaxError, parse: peg$parse }; });