UNPKG

dmn-eval-js-es5

Version:

Evaluation of DMN 1.1 decision tables, limited to S-FEEL (Simple Friendly Enough Expression Language), es5 browser compatible

1,715 lines (1,508 loc) 121 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 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 literal(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function _class(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 any(expectation) { return "any character"; }, end: function end(expectation) { return "end of input"; }, other: function other(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$startRuleFunctions = { Start: peg$parseStart, SimpleExpressions: peg$parseSimpleExpressions, SimpleUnaryTests: peg$parseSimpleUnaryTests }, peg$startRuleFunction = peg$parseStart, peg$c0 = function peg$c0(program) { return new ast.ProgramNode(extractOptional(program, 0), location()); }, peg$c1 = "(", peg$c2 = peg$literalExpectation("(", false), peg$c3 = ")", peg$c4 = peg$literalExpectation(")", false), peg$c5 = function peg$c5(expr) { return expr; }, peg$c6 = ",", peg$c7 = peg$literalExpectation(",", false), peg$c8 = function peg$c8(head, tail) { return new ast.SimpleExpressionsNode(buildList(head, tail, 3), location()); }, peg$c9 = function peg$c9(head, tail) { return new ast.SimplePositiveUnaryTestNode(extractOptional(head, 0), tail, location()); }, peg$c10 = "<=", peg$c11 = peg$literalExpectation("<=", false), peg$c12 = ">=", peg$c13 = peg$literalExpectation(">=", false), peg$c14 = "<", peg$c15 = peg$literalExpectation("<", false), peg$c16 = ">", peg$c17 = peg$literalExpectation(">", false), peg$c18 = "..", peg$c19 = peg$literalExpectation("..", false), peg$c20 = function peg$c20(start, first, second, end) { return new ast.IntervalNode(start, first, second, end, location()); }, peg$c21 = function peg$c21() { return new ast.IntervalStartLiteralNode("<", location()); }, peg$c22 = function peg$c22() { return new ast.IntervalStartLiteralNode("<=", location()); }, peg$c23 = function peg$c23() { return new ast.IntervalEndLiteralNode(">", location()); }, peg$c24 = function peg$c24() { return new ast.IntervalEndLiteralNode(">=", location()); }, peg$c25 = "]", peg$c26 = peg$literalExpectation("]", false), peg$c27 = "[", peg$c28 = peg$literalExpectation("[", false), peg$c29 = function peg$c29(head, tail) { return buildList(head, tail, 3); }, peg$c30 = function peg$c30(expr) { return new ast.SimpleUnaryTestsNode(expr, null, location()); }, peg$c31 = function peg$c31(not, expr) { return new ast.SimpleUnaryTestsNode(expr, not, location()); }, peg$c32 = "-", peg$c33 = peg$literalExpectation("-", false), peg$c34 = function peg$c34() { return new ast.SimpleUnaryTestsNode(null, null, location()); }, peg$c35 = "not", peg$c36 = peg$literalExpectation("not", false), peg$c37 = ".", peg$c38 = peg$literalExpectation(".", false), peg$c39 = function peg$c39(head, tail) { return new ast.QualifiedNameNode(buildList(head, tail, 3), location()); }, peg$c40 = "+", peg$c41 = peg$literalExpectation("+", false), peg$c42 = function peg$c42(head, tail) { return new ast.ArithmeticExpressionNode('+', head, tail[3], location()); }, peg$c43 = function peg$c43(head, tail) { return new ast.ArithmeticExpressionNode('-', head, tail[3], location()); }, peg$c44 = "*", peg$c45 = peg$literalExpectation("*", false), peg$c46 = function peg$c46(head, tail) { return new ast.ArithmeticExpressionNode('*', head, tail[3], location()); }, peg$c47 = "/", peg$c48 = peg$literalExpectation("/", false), peg$c49 = function peg$c49(head, tail) { return new ast.ArithmeticExpressionNode('/', head, tail[3], location()); }, peg$c50 = "**", peg$c51 = peg$literalExpectation("**", false), peg$c52 = function peg$c52(head, tail) { return new ast.ArithmeticExpressionNode('**', head, tail[3], location()); }, peg$c53 = function peg$c53(expr) { return new ast.ArithmeticExpressionNode('-', null, expr[1], location()); }, peg$c54 = function peg$c54(head, tail) { return new ast.NameNode(buildName(head, tail, 0), location()); }, peg$c55 = function peg$c55(head, tail) { return buildList(head, tail, 0); }, peg$c56 = /^[?]/, peg$c57 = peg$classExpectation(["?"], false, false), peg$c58 = /^[A-Z]/, peg$c59 = peg$classExpectation([["A", "Z"]], false, false), peg$c60 = /^[_]/, peg$c61 = peg$classExpectation(["_"], false, false), peg$c62 = /^[a-z]/, peg$c63 = peg$classExpectation([["a", "z"]], false, false), peg$c64 = /^[\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962-\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2-\u09E3\u0A01-\u0A02\u0A3C\u0A41-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A51\u0A70-\u0A71\u0A75\u0A81-\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7-\u0AC8\u0ACD\u0AE2-\u0AE3\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62-\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C62-\u0C63\u0C81\u0CBC\u0CBF\u0CC6\u0CCC-\u0CCD\u0CE2-\u0CE3\u0D01\u0D41-\u0D44\u0D4D\u0D62-\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039-\u103A\u103D-\u103E\u1058-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B4-\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193B\u1A17-\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80-\u1B81\u1BA2-\u1BA5\u1BA8-\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8-\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8-\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099-\u309A\uA66F\uA674-\uA67D\uA69E-\uA69F\uA6F0-\uA6F1\uA802\uA806\uA80B\uA825-\uA826\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9E5\uAA29-\uAA2E\uAA31-\uAA32\uAA35-\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7-\uAAB8\uAABE-\uAABF\uAAC1\uAAEC-\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/, peg$c65 = peg$classExpectation([["\u0300", "\u036F"], ["\u0483", "\u0487"], ["\u0591", "\u05BD"], "\u05BF", ["\u05C1", "\u05C2"], ["\u05C4", "\u05C5"], "\u05C7", ["\u0610", "\u061A"], ["\u064B", "\u065F"], "\u0670", ["\u06D6", "\u06DC"], ["\u06DF", "\u06E4"], ["\u06E7", "\u06E8"], ["\u06EA", "\u06ED"], "\u0711", ["\u0730", "\u074A"], ["\u07A6", "\u07B0"], ["\u07EB", "\u07F3"], ["\u0816", "\u0819"], ["\u081B", "\u0823"], ["\u0825", "\u0827"], ["\u0829", "\u082D"], ["\u0859", "\u085B"], ["\u08E3", "\u0902"], "\u093A", "\u093C", ["\u0941", "\u0948"], "\u094D", ["\u0951", "\u0957"], ["\u0962", "\u0963"], "\u0981", "\u09BC", ["\u09C1", "\u09C4"], "\u09CD", ["\u09E2", "\u09E3"], ["\u0A01", "\u0A02"], "\u0A3C", ["\u0A41", "\u0A42"], ["\u0A47", "\u0A48"], ["\u0A4B", "\u0A4D"], "\u0A51", ["\u0A70", "\u0A71"], "\u0A75", ["\u0A81", "\u0A82"], "\u0ABC", ["\u0AC1", "\u0AC5"], ["\u0AC7", "\u0AC8"], "\u0ACD", ["\u0AE2", "\u0AE3"], "\u0B01", "\u0B3C", "\u0B3F", ["\u0B41", "\u0B44"], "\u0B4D", "\u0B56", ["\u0B62", "\u0B63"], "\u0B82", "\u0BC0", "\u0BCD", "\u0C00", ["\u0C3E", "\u0C40"], ["\u0C46", "\u0C48"], ["\u0C4A", "\u0C4D"], ["\u0C55", "\u0C56"], ["\u0C62", "\u0C63"], "\u0C81", "\u0CBC", "\u0CBF", "\u0CC6", ["\u0CCC", "\u0CCD"], ["\u0CE2", "\u0CE3"], "\u0D01", ["\u0D41", "\u0D44"], "\u0D4D", ["\u0D62", "\u0D63"], "\u0DCA", ["\u0DD2", "\u0DD4"], "\u0DD6", "\u0E31", ["\u0E34", "\u0E3A"], ["\u0E47", "\u0E4E"], "\u0EB1", ["\u0EB4", "\u0EB9"], ["\u0EBB", "\u0EBC"], ["\u0EC8", "\u0ECD"], ["\u0F18", "\u0F19"], "\u0F35", "\u0F37", "\u0F39", ["\u0F71", "\u0F7E"], ["\u0F80", "\u0F84"], ["\u0F86", "\u0F87"], ["\u0F8D", "\u0F97"], ["\u0F99", "\u0FBC"], "\u0FC6", ["\u102D", "\u1030"], ["\u1032", "\u1037"], ["\u1039", "\u103A"], ["\u103D", "\u103E"], ["\u1058", "\u1059"], ["\u105E", "\u1060"], ["\u1071", "\u1074"], "\u1082", ["\u1085", "\u1086"], "\u108D", "\u109D", ["\u135D", "\u135F"], ["\u1712", "\u1714"], ["\u1732", "\u1734"], ["\u1752", "\u1753"], ["\u1772", "\u1773"], ["\u17B4", "\u17B5"], ["\u17B7", "\u17BD"], "\u17C6", ["\u17C9", "\u17D3"], "\u17DD", ["\u180B", "\u180D"], "\u18A9", ["\u1920", "\u1922"], ["\u1927", "\u1928"], "\u1932", ["\u1939", "\u193B"], ["\u1A17", "\u1A18"], "\u1A1B", "\u1A56", ["\u1A58", "\u1A5E"], "\u1A60", "\u1A62", ["\u1A65", "\u1A6C"], ["\u1A73", "\u1A7C"], "\u1A7F", ["\u1AB0", "\u1ABD"], ["\u1B00", "\u1B03"], "\u1B34", ["\u1B36", "\u1B3A"], "\u1B3C", "\u1B42", ["\u1B6B", "\u1B73"], ["\u1B80", "\u1B81"], ["\u1BA2", "\u1BA5"], ["\u1BA8", "\u1BA9"], ["\u1BAB", "\u1BAD"], "\u1BE6", ["\u1BE8", "\u1BE9"], "\u1BED", ["\u1BEF", "\u1BF1"], ["\u1C2C", "\u1C33"], ["\u1C36", "\u1C37"], ["\u1CD0", "\u1CD2"], ["\u1CD4", "\u1CE0"], ["\u1CE2", "\u1CE8"], "\u1CED", "\u1CF4", ["\u1CF8", "\u1CF9"], ["\u1DC0", "\u1DF5"], ["\u1DFC", "\u1DFF"], ["\u20D0", "\u20DC"], "\u20E1", ["\u20E5", "\u20F0"], ["\u2CEF", "\u2CF1"], "\u2D7F", ["\u2DE0", "\u2DFF"], ["\u302A", "\u302D"], ["\u3099", "\u309A"], "\uA66F", ["\uA674", "\uA67D"], ["\uA69E", "\uA69F"], ["\uA6F0", "\uA6F1"], "\uA802", "\uA806", "\uA80B", ["\uA825", "\uA826"], "\uA8C4", ["\uA8E0", "\uA8F1"], ["\uA926", "\uA92D"], ["\uA947", "\uA951"], ["\uA980", "\uA982"], "\uA9B3", ["\uA9B6", "\uA9B9"], "\uA9BC", "\uA9E5", ["\uAA29", "\uAA2E"], ["\uAA31", "\uAA32"], ["\uAA35", "\uAA36"], "\uAA43", "\uAA4C", "\uAA7C", "\uAAB0", ["\uAAB2", "\uAAB4"], ["\uAAB7", "\uAAB8"], ["\uAABE", "\uAABF"], "\uAAC1", ["\uAAEC", "\uAAED"], "\uAAF6", "\uABE5", "\uABE8", "\uABED", "\uFB1E", ["\uFE00", "\uFE0F"], ["\uFE20", "\uFE2F"]], false, false), peg$c66 = /^[']/, peg$c67 = peg$classExpectation(["'"], false, false), peg$c68 = /^[\u0B70\u0300-\u036F\u203F-\u2040]/, peg$c69 = peg$classExpectation(["\u0B70", ["\u0300", "\u036F"], ["\u203F", "\u2040"]], false, false), peg$c70 = peg$otherExpectation("string"), peg$c71 = "\"", peg$c72 = peg$literalExpectation("\"", false), peg$c73 = function peg$c73(chars) { return new ast.LiteralNode(chars.join(""), location()); }, peg$c74 = "'", peg$c75 = peg$literalExpectation("'", false), peg$c76 = function peg$c76(chars) { return new ast.LiteralNode(chars.join(""), location()); }, peg$c77 = "\\", peg$c78 = peg$literalExpectation("\\", false), peg$c79 = function peg$c79() { return text(); }, peg$c80 = function peg$c80(sequence) { return sequence; }, peg$c81 = peg$anyExpectation(), peg$c82 = function peg$c82() { return ""; }, peg$c83 = "b", peg$c84 = peg$literalExpectation("b", false), peg$c85 = function peg$c85() { return "\b"; }, peg$c86 = "f", peg$c87 = peg$literalExpectation("f", false), peg$c88 = function peg$c88() { return "\f"; }, peg$c89 = "n", peg$c90 = peg$literalExpectation("n", false), peg$c91 = function peg$c91() { return "\n"; }, peg$c92 = "r", peg$c93 = peg$literalExpectation("r", false), peg$c94 = function peg$c94() { return "\r"; }, peg$c95 = "t", peg$c96 = peg$literalExpectation("t", false), peg$c97 = function peg$c97() { return "\t"; }, peg$c98 = "v", peg$c99 = peg$literalExpectation("v", false), peg$c100 = function peg$c100() { return "\v"; }, peg$c101 = /^[\n\r\u2028\u2029]/, peg$c102 = peg$classExpectation(["\n", "\r", "\u2028", "\u2029"], false, false), peg$c103 = peg$otherExpectation("end of line"), peg$c104 = "\n", peg$c105 = peg$literalExpectation("\n", false), peg$c106 = "\r\n", peg$c107 = peg$literalExpectation("\r\n", false), peg$c108 = "\r", peg$c109 = peg$literalExpectation("\r", false), peg$c110 = "\u2028", peg$c111 = peg$literalExpectation("\u2028", false), peg$c112 = "\u2029", peg$c113 = peg$literalExpectation("\u2029", false), peg$c114 = function peg$c114() { return new ast.LiteralNode(true, location()); }, peg$c115 = function peg$c115() { return new ast.LiteralNode(false, location()); }, peg$c116 = "true", peg$c117 = peg$literalExpectation("true", false), peg$c118 = "TRUE", peg$c119 = peg$literalExpectation("TRUE", false), peg$c120 = "True", peg$c121 = peg$literalExpectation("True", false), peg$c122 = "false", peg$c123 = peg$literalExpectation("false", false), peg$c124 = "FALSE", peg$c125 = peg$literalExpectation("FALSE", false), peg$c126 = "False", peg$c127 = peg$literalExpectation("False", false), peg$c128 = function peg$c128(negative, number) { return new ast.LiteralNode(Number((negative || "") + number), location()); }, peg$c129 = function peg$c129(integer, decimal) { return integer.join("") + "." + decimal.join(""); }, peg$c130 = function peg$c130(decimal) { return "." + decimal.join(""); }, peg$c131 = function peg$c131(integer) { return integer.join(""); }, peg$c132 = /^[0-9]/, peg$c133 = peg$classExpectation([["0", "9"]], false, false), peg$c134 = function peg$c134(symbol, head, tail) { return new ast.DateTimeLiteralNode(symbol[0], buildList(head, tail, 3), location()); }, peg$c135 = "date and time", peg$c136 = peg$literalExpectation("date and time", false), peg$c137 = "time", peg$c138 = peg$literalExpectation("time", false), peg$c139 = "date", peg$c140 = peg$literalExpectation("date", false), peg$c141 = "duration", peg$c142 = peg$literalExpectation("duration", false), peg$c143 = function peg$c143(head, tail) { return buildComparisonExpression(head, tail, location()); }, peg$c144 = "=", peg$c145 = peg$literalExpectation("=", false), peg$c146 = "!=", peg$c147 = peg$literalExpectation("!=", false), peg$c148 = function peg$c148(fnName, params) { return new ast.FunctionInvocationNode(fnName, extractOptional(params, 1), location()); }, peg$c149 = function peg$c149(head, tail) { return new ast.PositionalParametersNode(buildList(head, tail, 3), location()); }, peg$c150 = function peg$c150() { return new ast.LiteralNode(null, location()); }, peg$c151 = "null", peg$c152 = peg$literalExpectation("null", false), peg$c153 = peg$otherExpectation("whitespace"), peg$c154 = "\t", peg$c155 = peg$literalExpectation("\t", false), peg$c156 = "\x0B", peg$c157 = peg$literalExpectation("\x0B", false), peg$c158 = "\f", peg$c159 = peg$literalExpectation("\f", false), peg$c160 = " ", peg$c161 = peg$literalExpectation(" ", false), peg$c162 = "\xA0", peg$c163 = peg$literalExpectation("\xA0", false), peg$c164 = "\uFEFF", peg$c165 = peg$literalExpectation("\uFEFF", false), peg$c166 = /^[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, peg$c167 = peg$classExpectation([" ", "\xA0", "\u1680", ["\u2000", "\u200A"], "\u202F", "\u205F", "\u3000"], false, false), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$resultsCache = {}, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); } function peg$parseStart() { var s0, s1, s2, s3, s4; var key = peg$currPos * 65 + 0, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parseExpressionOrTests(); if (s3 !== peg$FAILED) { s4 = peg$parse__(); if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseExpressionOrTests() { var s0; var key = peg$currPos * 65 + 1, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parseSimpleExpression(); if (s0 === peg$FAILED) { s0 = peg$parseSimpleUnaryTests(); } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseArithmeticExpression() { var s0; var key = peg$currPos * 65 + 2, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parseAddition(); if (s0 === peg$FAILED) { s0 = peg$parseSubtraction(); if (s0 === peg$FAILED) { s0 = peg$parseMultiplication(); if (s0 === peg$FAILED) { s0 = peg$parseDivision(); if (s0 === peg$FAILED) { s0 = peg$parseExponentiation(); if (s0 === peg$FAILED) { s0 = peg$parseArithmeticNegation(); if (s0 === peg$FAILED) { s0 = peg$parseBrackenedArithmeticExpression(); } } } } } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseBrackenedArithmeticExpression() { var s0, s1, s2, s3, s4, s5; var key = peg$currPos * 65 + 3, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { s1 = peg$c1; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseArithmeticExpression(); if (s3 !== peg$FAILED) { s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s5 = peg$c3; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c5(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimpleExpression() { var s0; var key = peg$currPos * 65 + 4, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parseArithmeticExpression(); if (s0 === peg$FAILED) { s0 = peg$parseComparison(); if (s0 === peg$FAILED) { s0 = peg$parseSimpleValue(); } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimpleExpressions() { var s0, s1, s2, s3, s4, s5, s6, s7; var key = peg$currPos * 65 + 5, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseSimpleExpression(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s5 = peg$c6; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseSimpleExpression(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s5 = peg$c6; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseSimpleExpression(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c8(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimplePositiveUnaryTest() { var s0, s1, s2, s3; var key = peg$currPos * 65 + 6, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$currPos; s2 = peg$parseUnaryOperator(); if (s2 !== peg$FAILED) { s3 = peg$parse__(); if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseEndpoint(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c9(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$parseInterval(); } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseUnaryOperator() { var s0; var key = peg$currPos * 65 + 7, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } if (input.substr(peg$currPos, 2) === peg$c10) { s0 = peg$c10; peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c12) { s0 = peg$c12; peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c13); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 60) { s0 = peg$c14; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 62) { s0 = peg$c16; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } } } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseInterval() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; var key = peg$currPos * 65 + 8, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseIntervalStart(); if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; s3 = peg$parseIntervalStart(); if (s3 === peg$FAILED) { s3 = peg$parseIntervalEnd(); } peg$silentFails--; if (s3 === peg$FAILED) { s2 = void 0; } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s3 = peg$parse__(); if (s3 !== peg$FAILED) { s4 = peg$parseEndpoint(); if (s4 !== peg$FAILED) { s5 = peg$parse__(); if (s5 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c18) { s6 = peg$c18; peg$currPos += 2; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c19); } } if (s6 !== peg$FAILED) { s7 = peg$parse__(); if (s7 !== peg$FAILED) { s8 = peg$parseEndpoint(); if (s8 !== peg$FAILED) { s9 = peg$parse__(); if (s9 !== peg$FAILED) { s10 = peg$parseIntervalEnd(); if (s10 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c20(s1, s4, s8, s10); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseIntervalStart() { var s0, s1; var key = peg$currPos * 65 + 9, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseOpenIntervalStart(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c21(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseClosedIntervalStart(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(); } s0 = s1; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseIntervalEnd() { var s0, s1; var key = peg$currPos * 65 + 10, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseOpenIntervalEnd(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseClosedIntervalEnd(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c24(); } s0 = s1; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseOpenIntervalStart() { var s0; var key = peg$currPos * 65 + 11, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } if (input.charCodeAt(peg$currPos) === 40) { s0 = peg$c1; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { s0 = peg$c25; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseClosedIntervalStart() { var s0; var key = peg$currPos * 65 + 12, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } if (input.charCodeAt(peg$currPos) === 91) { s0 = peg$c27; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c28); } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseOpenIntervalEnd() { var s0; var key = peg$currPos * 65 + 13, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } if (input.charCodeAt(peg$currPos) === 41) { s0 = peg$c3; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 91) { s0 = peg$c27; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c28); } } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseClosedIntervalEnd() { var s0; var key = peg$currPos * 65 + 14, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } if (input.charCodeAt(peg$currPos) === 93) { s0 = peg$c25; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimplePositiveUnaryTests() { var s0, s1, s2, s3, s4, s5, s6, s7; var key = peg$currPos * 65 + 15, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseSimplePositiveUnaryTest(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s5 = peg$c6; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseSimplePositiveUnaryTest(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s5 = peg$c6; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseSimplePositiveUnaryTest(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c29(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimpleUnaryTests() { var s0, s1, s2, s3, s4, s5, s6, s7; var key = peg$currPos * 65 + 16, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseSimplePositiveUnaryTests(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c30(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$currPos; s2 = peg$parseNotToken(); if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s3 = peg$c1; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s3 !== peg$FAILED) { s4 = peg$parse__(); if (s4 !== peg$FAILED) { s5 = peg$parseSimplePositiveUnaryTests(); if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s7 = peg$c3; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c31(s1, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 45) { s1 = peg$c32; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c34(); } s0 = s1; } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseNotToken() { var s0, s1, s2, s3; var key = peg$currPos * 65 + 17, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; if (input.substr(peg$currPos, 3) === peg$c35) { s1 = peg$c35; peg$currPos += 3; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; s3 = peg$parseNamePartChar(); peg$silentFails--; if (s3 === peg$FAILED) { s2 = void 0; } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = [s1, s2]; s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseEndpoint() { var s0; var key = peg$currPos * 65 + 18, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parseArithmeticExpression(); if (s0 === peg$FAILED) { s0 = peg$parseSimpleValue(); } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseSimpleValue() { var s0; var key = peg$currPos * 65 + 19, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parseSimpleLiteral(); if (s0 === peg$FAILED) { s0 = peg$parseFunctionInvocation(); if (s0 === peg$FAILED) { s0 = peg$parseQualifiedName(); } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseQualifiedName() { var s0, s1, s2, s3, s4, s5, s6, s7; var key = peg$currPos * 65 + 20, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseName(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s5 = peg$c37; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseName(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s5 = peg$c37; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseName(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c39(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parseAddition() { var s0, s1, s2, s3, s4, s5, s6; var key = peg$currPos * 65 + 21, cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseNonRecursiveSimpleExpressionForArithmeticExpression(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parse__(); if (s3 !== peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 43) { s5 = peg$c40; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s5 !== peg$FAILED) { s4 = input.substring(s4, peg$currPos); } else { s4 = s5; } if (s4 !== peg$FAILED) { s5 = peg$parse__(); if (s5 !== peg$FAILED) { s6 = peg$parseSimpleExpression(); if (s6 !== peg$FAILED) { s3 = [s3, s4, s5, s6]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } } else {