From b88dc849443428541ecc8153ab3ea871e2bb69a3 Mon Sep 17 00:00:00 2001 From: lostfields Date: Thu, 7 Mar 2024 11:04:22 +0100 Subject: [PATCH] chore: replacing pegjs with peggy --- js-enumerable.code-workspace | 2 +- package-lock.json | 146 +- package.json | 6 +- src/linq/peg/parser/javascript-parser.js | 6033 +++++++++++++++++++--- src/linq/peg/parser/odata-parser.js | 5163 +++++++++++++++--- src/linq/peg/parser/parser.ts | 6 +- 6 files changed, 9820 insertions(+), 1536 deletions(-) diff --git a/js-enumerable.code-workspace b/js-enumerable.code-workspace index ced5398..6e292e8 100644 --- a/js-enumerable.code-workspace +++ b/js-enumerable.code-workspace @@ -77,7 +77,7 @@ }, "extensions": { "recommendations": [ - "maty.vscode-mocha-sidebar", "eamodio.toggle-excluded-files" + "maty.vscode-mocha-sidebar", "eamodio.toggle-excluded-files", "PeggyJS.peggy-language" ] } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5bc2efe..01296ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "eslint": "^8", "eslint-config-tfso": "npm:@tfso/eslint-config@^1.1.4", "mocha": "^10.2.0", - "pegjs": "^0.10.0", + "peggy": "^4.0.2", "ts-node": "^10.9.1", "typescript": "^4.9.5", "webpack": "^5.75.0", @@ -2168,6 +2168,51 @@ "node": ">= 8" } }, + "node_modules/@peggyjs/from-mem": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@peggyjs/from-mem/-/from-mem-1.2.1.tgz", + "integrity": "sha512-qh5zG8WKT36142/FqOYtpF0scRR3ZJ3H5XST1bJ/KV2FvyB5MvUB/tB9ZjihRe1iKjJD4PBOZczzwEx7hJtgMw==", + "dev": true, + "dependencies": { + "semver": "7.6.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@peggyjs/from-mem/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@peggyjs/from-mem/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@peggyjs/from-mem/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/@polka/url": { "version": "1.0.0-next.21", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz", @@ -6719,16 +6764,30 @@ "node": "*" } }, - "node_modules/pegjs": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", - "integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==", + "node_modules/peggy": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/peggy/-/peggy-4.0.2.tgz", + "integrity": "sha512-j4cepPgB20V7honmTAI+7U022y/n/wVi7Rbbd2QrMl2nifFECpngvA6Zhrz/JdmZ5LIBoTdkgHcDzzaA6C4ABg==", "dev": true, + "dependencies": { + "@peggyjs/from-mem": "1.2.1", + "commander": "^12.0.0", + "source-map-generator": "0.8.0" + }, "bin": { - "pegjs": "bin/pegjs" + "peggy": "bin/peggy.js" }, "engines": { - "node": ">=0.10" + "node": ">=18" + } + }, + "node_modules/peggy/node_modules/commander": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", + "dev": true, + "engines": { + "node": ">=18" } }, "node_modules/picocolors": { @@ -7175,6 +7234,15 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-generator": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/source-map-generator/-/source-map-generator-0.8.0.tgz", + "integrity": "sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, "node_modules/source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -9652,6 +9720,41 @@ "fastq": "^1.6.0" } }, + "@peggyjs/from-mem": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@peggyjs/from-mem/-/from-mem-1.2.1.tgz", + "integrity": "sha512-qh5zG8WKT36142/FqOYtpF0scRR3ZJ3H5XST1bJ/KV2FvyB5MvUB/tB9ZjihRe1iKjJD4PBOZczzwEx7hJtgMw==", + "dev": true, + "requires": { + "semver": "7.6.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, "@polka/url": { "version": "1.0.0-next.21", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz", @@ -13066,11 +13169,24 @@ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true }, - "pegjs": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", - "integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==", - "dev": true + "peggy": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/peggy/-/peggy-4.0.2.tgz", + "integrity": "sha512-j4cepPgB20V7honmTAI+7U022y/n/wVi7Rbbd2QrMl2nifFECpngvA6Zhrz/JdmZ5LIBoTdkgHcDzzaA6C4ABg==", + "dev": true, + "requires": { + "@peggyjs/from-mem": "1.2.1", + "commander": "^12.0.0", + "source-map-generator": "0.8.0" + }, + "dependencies": { + "commander": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", + "dev": true + } + } }, "picocolors": { "version": "1.0.0", @@ -13393,6 +13509,12 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "source-map-generator": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/source-map-generator/-/source-map-generator-0.8.0.tgz", + "integrity": "sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA==", + "dev": true + }, "source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", diff --git a/package.json b/package.json index 53461f1..17f8fe4 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "analyze": "webpack --profile --json > ./stats.json && webpack-bundle-analyzer ./stats.json", "browserify": "browserify src/test/index.ts -p [ tsify --noImplicitAny ] > lib/mocha-bundle.js", "grammar": "npm run grammar:javascript && npm run grammar:odata", - "grammar:javascript": "pegjs -O size -o ./src/linq/peg/parser/javascript-parser.js ./src/linq/peg/grammar/javascript.pegjs", - "grammar:odata": "pegjs -O size -o ./src/linq/peg/parser/odata-parser.js ./src/linq/peg/grammar/odata.pegjs" + "grammar:javascript": "peggy --format es -o ./src/linq/peg/parser/javascript-parser.js ./src/linq/peg/grammar/javascript.pegjs", + "grammar:odata": "peggy --format es -o ./src/linq/peg/parser/odata-parser.js ./src/linq/peg/grammar/odata.pegjs" }, "author": "Nicolai Gjærum", "license": "MIT", @@ -32,7 +32,6 @@ "@types/node": "^16.6.2", "@typescript-eslint/eslint-plugin": "^5", "@typescript-eslint/parser": "^5", - "pegjs": "^0.10.0", "babel-loader": "^8.2.3", "babelify": "^10.0.0", "chai": "^4.3.7", @@ -40,6 +39,7 @@ "eslint": "^8", "eslint-config-tfso": "npm:@tfso/eslint-config@^1.1.4", "mocha": "^10.2.0", + "peggy": "^4.0.2", "ts-node": "^10.9.1", "typescript": "^4.9.5", "webpack": "^5.75.0", diff --git a/src/linq/peg/parser/javascript-parser.js b/src/linq/peg/parser/javascript-parser.js index 5909695..2be2d8f 100644 --- a/src/linq/peg/parser/javascript-parser.js +++ b/src/linq/peg/parser/javascript-parser.js @@ -1,62 +1,99 @@ -/* - * Generated by PEG.js 0.10.0. - * - * http://pegjs.org/ - */ +// @generated by Peggy 4.0.2. +// +// https://peggyjs.org/ -"use strict"; function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); } 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); + var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments + if (Object.setPrototypeOf) { + Object.setPrototypeOf(self, peg$SyntaxError.prototype); } + self.expected = expected; + self.found = found; + self.location = location; + self.name = "SyntaxError"; + return self; } peg$subclass(peg$SyntaxError, Error); +function peg$padEnd(str, targetLength, padString) { + padString = padString || " "; + if (str.length > targetLength) { return str; } + targetLength -= str.length; + padString += padString.repeat(targetLength); + return str + padString.slice(0, targetLength); +} + +peg$SyntaxError.prototype.format = function(sources) { + var str = "Error: " + this.message; + if (this.location) { + var src = null; + var k; + for (k = 0; k < sources.length; k++) { + if (sources[k].source === this.location.source) { + src = sources[k].text.split(/\r\n|\n|\r/g); + break; + } + } + var s = this.location.start; + var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + if (src) { + var e = this.location.end; + var filler = peg$padEnd("", offset_s.line.toString().length, ' '); + var line = src[s.line - 1]; + var last = s.line === e.line ? e.column : line.length + 1; + var hatLen = (last - s.column) || 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + offset_s.line + " | " + line + "\n" + + filler + " | " + peg$padEnd("", s.column - 1, ' ') + + peg$padEnd("", hatLen, "^"); + } else { + str += "\n at " + loc; + } + } + return str; +}; + peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - "class": function(expectation) { - var escapedParts = "", - i; + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, - 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]); - } + class: function(expectation) { + var escapedParts = expectation.parts.map(function(part) { + return Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part); + }); - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; + }, - any: function(expectation) { - return "any character"; - }, + any: function() { + return "any character"; + }, - end: function(expectation) { - return "end of input"; - }, + end: function() { + return "end of input"; + }, - other: function(expectation) { - return expectation.description; - } - }; + other: function(expectation) { + return expectation.description; + } + }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); @@ -64,28 +101,28 @@ peg$SyntaxError.buildMessage = function(expected, found) { 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); }); + .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); }); + .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) { @@ -93,12 +130,8 @@ peg$SyntaxError.buildMessage = function(expected, found) { } function describeExpected(expected) { - var descriptions = new Array(expected.length), - i, j; - - for (i = 0; i < expected.length; i++) { - descriptions[i] = describeExpectation(expected[i]); - } + var descriptions = expected.map(describeExpectation); + var i, j; descriptions.sort(); @@ -134,488 +167,440 @@ peg$SyntaxError.buildMessage = function(expected, found) { }; function peg$parse(input, options) { - options = options !== void 0 ? options : {}; + options = options !== undefined ? options : {}; - var peg$FAILED = {}, + var peg$FAILED = {}; + var peg$source = options.grammarSource; - peg$startRuleIndices = { Start: 0 }, - peg$startRuleIndex = 0, + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; - peg$consts = [ - function(args, expr) { - return { - type: 'LambdaExpression', - arguments: [args], - expression: expr - } - }, - function(expr) { - return { - type: 'LambdaExpression', - arguments: [], - expression: expr - } - }, - function(first, rest) { return buildList(first, rest, 1); }, - function(args, expr) { - return { - type: 'LambdaExpression', - arguments: args, - expression: expr - } - }, - function(test, left, right) { - return { - type: 'ConditionalExpression', - test: test, - left: left, - right: right - } - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'LogicalExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'LogicalExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'BitwiseExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'RelationalExpression', - operator: element[0][0], - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'RelationalExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'ShiftExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'BinaryExpression', - operator: element[0][0].toLowerCase(), - left: result, - right: element[1] - }; - }); - }, - function(operator, operand) { return operand.type === 'NumberLiteral' && (operator === '-' || operator === '+') - ? - { - type: 'NumberLiteral', - value: (operator === '-' ? operator : '') + operand.value - } - : - (operator === '-' || operator === '+') && operand.type === 'PostfixExpression' && operand.argument.type === 'NumberLiteral' - ? - Object.assign(operand, {argument: { - type: 'NumberLiteral', - value: (operator === '-' ? operator : '') + operand.argument.value - }}) - : - { - type: 'UnaryExpression', - operator: operator, - argument: operand - }; - }, - function(operand, operator) { return operator - ? - { - type: 'PostfixExpression', - operator: operator, - argument: operand - } - : - operand - }, - function(expr) { return expr; }, - "includes", - peg$literalExpectation("includes", false), - function(left, right) { - return { - type: 'RelationalExpression', - operator: 'in', - left: right, - right: left - } - }, - function(qual, args) { - return { - type: 'CallExpression', - object: qual, - arguments: args - }; - }, - function(qual, expr) { - return { - type: 'ArrayExpression', - object: qual, - index: expr - }; - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'MemberExpression', - object: result, - property: element[1] - }; - }); - }, - function(op) { return op[0].toLowerCase(); }, - function(args) { return args || []; }, - function(exp) { return exp; }, - /^[ \t\r\n\f]/, - peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false), - function(first, last) { return { type: 'Identifier', name: first + last.join('') }; }, - /^[a-z]/, - peg$classExpectation([["a", "z"]], false, false), - /^[A-Z]/, - peg$classExpectation([["A", "Z"]], false, false), - /^[_$]/, - peg$classExpectation(["_", "$"], false, false), - /^[0-9]/, - peg$classExpectation([["0", "9"]], false, false), - "`", - peg$literalExpectation("`", false), - "\\$", - peg$literalExpectation("\\$", false), - /^[{]/, - peg$classExpectation(["{"], false, false), - peg$anyExpectation(), - "$", - peg$literalExpectation("$", false), - "\\${", - peg$literalExpectation("\\${", false), - "$\\{", - peg$literalExpectation("$\\{", false), - "\\$\\{", - peg$literalExpectation("\\$\\{", false), - /^[$`\\]/, - peg$classExpectation(["$", "`", "\\"], false, false), - function(capture) { return { - type: 'TemplateLiteral', - values: capture.reduce((r, v) => { - if(Array.isArray(v)) { - if(typeof(r[r.length - 1]) != 'string') - r.push('') - r[r.length - 1] += v[0] == undefined ? v[1] : v[0] + (v[1] == undefined ? v[2] : v[1]) - } else { - r.push(v); - } - return r; - }, []).map(v => typeof v == 'string' ? { type: 'Literal', value: v } : v ) - } - }, - function(expression) { return { - type: 'TemplateExpression', - value: expression - } - }, - "true", - peg$literalExpectation("true", false), - function() { return { type: 'BooleanLiteral', value: true }; }, - "false", - peg$literalExpectation("false", false), - function() { return { type: 'BooleanLiteral', value: false }; }, - "null", - peg$literalExpectation("null", false), - function() { return { type: 'NullLiteral' }; }, - function(literal) { return literal; }, - function(first, rest) { return buildList(first, rest, 2)}, - function(properties) { return { type: 'ObjectLiteral', properties: properties } }, - ":", - peg$literalExpectation(":", false), - function(key, value) { return { type: 'Property', key: key, value: value} }, - function(elements) { return { type: 'ArrayLiteral', elements: elements } }, - /^[lL]/, - peg$classExpectation(["l", "L"], false, false), - function() { return { type: 'NumberLiteral', value: text() }; }, - "0", - peg$literalExpectation("0", false), - /^[1-9]/, - peg$classExpectation([["1", "9"]], false, false), - /^[_]/, - peg$classExpectation(["_"], false, false), - "0x", - peg$literalExpectation("0x", false), - "0X", - peg$literalExpectation("0X", false), - "0b", - peg$literalExpectation("0b", false), - "0B", - peg$literalExpectation("0B", false), - /^[01]/, - peg$classExpectation(["0", "1"], false, false), - /^[0-7]/, - peg$classExpectation([["0", "7"]], false, false), - ".", - peg$literalExpectation(".", false), - /^[fFdD]/, - peg$classExpectation(["f", "F", "d", "D"], false, false), - /^[eE]/, - peg$classExpectation(["e", "E"], false, false), - /^[+\-]/, - peg$classExpectation(["+", "-"], false, false), - /^[pP]/, - peg$classExpectation(["p", "P"], false, false), - /^[a-f]/, - peg$classExpectation([["a", "f"]], false, false), - /^[A-F]/, - peg$classExpectation([["A", "F"]], false, false), - "'", - peg$literalExpectation("'", false), - /^['\\\n\r]/, - peg$classExpectation(["'", "\\", "\n", "\r"], false, false), - function(chars) { return { type: 'Literal', value: chars.map(l => l[0] == undefined ? l[1] : l[0] + l[1]).join('') } }, - "\"", - peg$literalExpectation("\"", false), - /^["\\\n\r]/, - peg$classExpectation(["\"", "\\", "\n", "\r"], false, false), - "\\", - peg$literalExpectation("\\", false), - /^[btnfr"'`\\]/, - peg$classExpectation(["b", "t", "n", "f", "r", "\"", "'", "`", "\\"], false, false), - /^[0-3]/, - peg$classExpectation([["0", "3"]], false, false), - "u", - peg$literalExpectation("u", false), - "=>", - peg$literalExpectation("=>", true), - "+", - peg$literalExpectation("+", true), - "&", - peg$literalExpectation("&", true), - "&&", - peg$literalExpectation("&&", true), - ",", - peg$literalExpectation(",", false), - "/", - peg$literalExpectation("/", true), - "==", - peg$literalExpectation("==", true), - "===", - peg$literalExpectation("===", true), - ">=", - peg$literalExpectation(">=", true), - ">", - peg$literalExpectation(">", true), - "-", - peg$literalExpectation("-", false), - "[", - peg$literalExpectation("[", false), - "{", - peg$literalExpectation("{", false), - "<=", - peg$literalExpectation("<=", true), - "(", - peg$literalExpectation("(", false), - "<", - peg$literalExpectation("<", true), - "<<", - peg$literalExpectation("<<", true), - ">>", - peg$literalExpectation(">>", true), - ">>>", - peg$literalExpectation(">>>", true), - "%", - peg$literalExpectation("%", true), - "!=", - peg$literalExpectation("!=", true), - "!==", - peg$literalExpectation("!==", true), - "!", - peg$literalExpectation("!", true), - "~", - peg$literalExpectation("~", true), - "|", - peg$literalExpectation("|", true), - "||", - peg$literalExpectation("||", true), - "^", - peg$literalExpectation("^", true), - peg$literalExpectation("+", false), - "++", - peg$literalExpectation("++", false), - "--", - peg$literalExpectation("--", false), - "]", - peg$literalExpectation("]", false), - "}", - peg$literalExpectation("}", false), - ")", - peg$literalExpectation(")", false), - peg$literalExpectation("-", true), - "*", - peg$literalExpectation("*", true), - "?", - peg$literalExpectation("?", true) - ], - - peg$bytecode = [ - peg$decode(";!"), - peg$decode("%;7/M#;6/D$;S/;$;6/2$;\"/)$8%: %\"$ )(%'#($'#(#'#(\"'#&'#.\u0126 &%;c/^#;6/U$;v/L$;6/C$;S/:$;6/1$;\"/($8':!'! )(''#(&'#(%'#($'#(#'#(\"'#&'#.\xDB &%;c/\xCB#%;7/\x85#$%%;X/,#;6/#$+\")(\"'#&'#/,#;7/#$+\")(\"'#&'#0I*%%;X/,#;6/#$+\")(\"'#&'#/,#;7/#$+\")(\"'#&'#&/)$8\":\"\"\"! )(\"'#&'#/V$;v/M$;6/D$;S/;$;6/2$;\"/)$8':#'\"% )(''#(&'#(%'#($'#(#'#(\"'#&'#.# &;\""), - peg$decode("%;#/r#;6/i$;y/`$;6/W$;\"/N$;6/E$;W/<$;6/3$;\"/*$8):$)#($ )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#.# &;#"), - peg$decode("%;$/\x85#$%%;o/,#;6/#$+\")(\"'#&'#/,#;$/#$+\")(\"'#&'#0I*%%;o/,#;6/#$+\")(\"'#&'#/,#;$/#$+\")(\"'#&'#&/)$8\":%\"\"! )(\"'#&'#"), - peg$decode("%;%/\x85#$%%;V/,#;6/#$+\")(\"'#&'#/,#;%/#$+\")(\"'#&'#0I*%%;V/,#;6/#$+\")(\"'#&'#/,#;%/#$+\")(\"'#&'#&/)$8\":&\"\"! )(\"'#&'#"), - peg$decode("%;&/\x85#$%%;n/,#;6/#$+\")(\"'#&'#/,#;&/#$+\")(\"'#&'#0I*%%;n/,#;6/#$+\")(\"'#&'#/,#;&/#$+\")(\"'#&'#&/)$8\":'\"\"! )(\"'#&'#"), - peg$decode("%;'/\x85#$%%;p/,#;6/#$+\")(\"'#&'#/,#;'/#$+\")(\"'#&'#0I*%%;p/,#;6/#$+\")(\"'#&'#/,#;'/#$+\")(\"'#&'#&/)$8\":'\"\"! )(\"'#&'#"), - peg$decode("%;(/\x85#$%%;U/,#;6/#$+\")(\"'#&'#/,#;(/#$+\")(\"'#&'#0I*%%;U/,#;6/#$+\")(\"'#&'#/,#;(/#$+\")(\"'#&'#&/)$8\":'\"\"! )(\"'#&'#"), - peg$decode("%;)/\u011B#$%%;[/,#;6/#$+\")(\"'#&'#.h &%;\\/,#;6/#$+\")(\"'#&'#.O &%;j/,#;6/#$+\")(\"'#&'#.6 &%;k/,#;6/#$+\")(\"'#&'#/,#;)/#$+\")(\"'#&'#0\x94*%%;[/,#;6/#$+\")(\"'#&'#.h &%;\\/,#;6/#$+\")(\"'#&'#.O &%;j/,#;6/#$+\")(\"'#&'#.6 &%;k/,#;6/#$+\")(\"'#&'#/,#;)/#$+\")(\"'#&'#&/)$8\":(\"\"! )(\"'#&'#"), - peg$decode("%;*/\u011B#$%%;b/,#;6/#$+\")(\"'#&'#.h &%;]/,#;6/#$+\")(\"'#&'#.O &%;d/,#;6/#$+\")(\"'#&'#.6 &%;^/,#;6/#$+\")(\"'#&'#/,#;*/#$+\")(\"'#&'#0\x94*%%;b/,#;6/#$+\")(\"'#&'#.h &%;]/,#;6/#$+\")(\"'#&'#.O &%;d/,#;6/#$+\")(\"'#&'#.6 &%;^/,#;6/#$+\")(\"'#&'#/,#;*/#$+\")(\"'#&'#&/)$8\":)\"\"! )(\"'#&'#"), - peg$decode("%;+/\xE9#$%%;g/,#;6/#$+\")(\"'#&'#.O &%;e/,#;6/#$+\")(\"'#&'#.6 &%;f/,#;6/#$+\")(\"'#&'#/,#;+/#$+\")(\"'#&'#0{*%%;g/,#;6/#$+\")(\"'#&'#.O &%;e/,#;6/#$+\")(\"'#&'#.6 &%;f/,#;6/#$+\")(\"'#&'#/,#;+/#$+\")(\"'#&'#&/)$8\":*\"\"! )(\"'#&'#"), - peg$decode("%;,/\xB7#$%%;T/,#;6/#$+\")(\"'#&'#.6 &%;w/,#;6/#$+\")(\"'#&'#/,#;,/#$+\")(\"'#&'#0b*%%;T/,#;6/#$+\")(\"'#&'#.6 &%;w/,#;6/#$+\")(\"'#&'#/,#;,/#$+\")(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), - peg$decode("%;-/\xE9#$%%;x/,#;6/#$+\")(\"'#&'#.O &%;Y/,#;6/#$+\")(\"'#&'#.6 &%;i/,#;6/#$+\")(\"'#&'#/,#;-/#$+\")(\"'#&'#0{*%%;x/,#;6/#$+\")(\"'#&'#.O &%;Y/,#;6/#$+\")(\"'#&'#.6 &%;i/,#;6/#$+\")(\"'#&'#/,#;-/#$+\")(\"'#&'#&/)$8\":+\"\"! )(\"'#&'#"), - peg$decode("%;2/2#;./)$8\":,\"\"! )(\"'#&'#.# &;."), - peg$decode("%;//F#;r.# &;s.\" &\"/2$;6/)$8#:-#\"\"!)(#'#(\"'#&'#"), - peg$decode(";0./ &;1.) &;:.# &;<"), - peg$decode("%;c/L#;6/C$;\"/:$;v/1$;6/($8%:.%!\")(%'#($'#(#'#(\"'#&'#"), - peg$decode("%%<;R=.##&&!&'#/}#;?.# &;7/n$;Z/e$2/\"\"6/70/V$;c/M$;6/D$;//;$;6/2$;v/)$8):1)\"'\")()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#.\u0141 &%%<;R=.##&&!&'#/;#;7/2$;3/)$8#:2#\"! )(#'#(\"'#&'#.\u010D &%%<;R=.##&&!&'#/e#;7.# &;#;6/5$;t/,$;6/#$+$)($'#(#'#(\"'#&'#"), - peg$decode("%;`/L#;6/C$;\"/:$;t/1$;6/($8%:7%!\")(%'#($'#(#'#(\"'#&'#"), - peg$decode("$$48\"\"5!79/,#0)*48\"\"5!79&&�<*$48\"\"5!79/,#0)*48\"\"5!79&&&#&"), - peg$decode("%;8/B#$;90#*;9&/2$;6/)$8#::#\"\"!)(#'#(\"'#&'#"), - peg$decode("4;\"\"5!7<.5 &4=\"\"5!7>.) &4?\"\"5!7@"), - peg$decode("4;\"\"5!7<.A &4=\"\"5!7>.5 &4A\"\"5!7B.) &4?\"\"5!7@"), - peg$decode("%2C\"\"6C7D/\u0287#$;;.\u013D &;O.\u0137 &%2E\"\"6E7F/L#%<4G\"\"5!7H=.##&&!&'#/1$1\"\"5!7I/#$+#)(#'#(\"'#&'#.\xF8 &%2J\"\"6J7K/L#%<4G\"\"5!7H=.##&&!&'#/1$1\"\"5!7I/#$+#)(#'#(\"'#&'#.\xB9 &%2L\"\"6L7M/1#1\"\"5!7I/#$+\")(\"'#&'#.\x95 &%2N\"\"6N7O/1#1\"\"5!7I/#$+\")(\"'#&'#.q &%2P\"\"6P7Q/1#1\"\"5!7I/#$+\")(\"'#&'#.M &%%<4R\"\"5!7S=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#0\u0143*;;.\u013D &;O.\u0137 &%2E\"\"6E7F/L#%<4G\"\"5!7H=.##&&!&'#/1$1\"\"5!7I/#$+#)(#'#(\"'#&'#.\xF8 &%2J\"\"6J7K/L#%<4G\"\"5!7H=.##&&!&'#/1$1\"\"5!7I/#$+#)(#'#(\"'#&'#.\xB9 &%2L\"\"6L7M/1#1\"\"5!7I/#$+\")(\"'#&'#.\x95 &%2N\"\"6N7O/1#1\"\"5!7I/#$+\")(\"'#&'#.q &%2P\"\"6P7Q/1#1\"\"5!7I/#$+\")(\"'#&'#.M &%%<4R\"\"5!7S=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#&/7$2C\"\"6C7D/($8#:T#!!)(#'#(\"'#&'#"), - peg$decode("%2J\"\"6J7K/L#;a/C$;6/:$;\"/1$;u/($8%:U%!!)(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;=.\xC2 &;E.\xBC &;@.\xB6 &;N.\xB0 &;?.\xAA &%2V\"\"6V7W/<#%<;9=.##&&!&'#/'$8\":X\" )(\"'#&'#.{ &%2Y\"\"6Y7Z/<#%<;9=.##&&!&'#/'$8\":[\" )(\"'#&'#.L &%2\\\"\"6\\7]/<#%<;9=.##&&!&'#/'$8\":^\" )(\"'#&'#/1#;6/($8\":_\"!!)(\"'#&'#"), - peg$decode("%;a/\xD3#;6/\xCA$%;>/q#$%;X/5#;6/,$;>/#$+#)(#'#(\"'#&'#0?*%;X/5#;6/,$;>/#$+#)(#'#(\"'#&'#&/)$8\":`\"\"! )(\"'#&'#.\" &\"/d$%;X/,#;6/#$+\")(\"'#&'#.\" &\"/C$;6/:$;u/1$;6/($8':a'!$)(''#(&'#(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;6/q#;7.) &;@.# &;N/\\$;6/S$2b\"\"6b7c/D$;6/;$;\"/2$;6/)$8':d'\"%!)(''#(&'#(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;`/\xD3#;6/\xCA$%;\"/q#$%;X/5#;6/,$;\"/#$+#)(#'#(\"'#&'#0?*%;X/5#;6/,$;\"/#$+#)(#'#(\"'#&'#&/)$8\":`\"\"! )(\"'#&'#.\" &\"/d$%;X/,#;6/#$+\")(\"'#&'#.\" &\"/C$;6/:$;t/1$;6/($8':e'!$)(''#(&'#(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;B./ &;C.) &;D.# &;A/;#4f\"\"5!7g.\" &\"/'$8\":h\" )(\"'#&'#"), - peg$decode("2i\"\"6i7j.\x9B &%4k\"\"5!7l/\x8B#$%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4A\"\"5!7B/#$+\")(\"'#&'#0O*%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4A\"\"5!7B/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("%2o\"\"6o7p.) &2q\"\"6q7r/,#;L/#$+\")(\"'#&'#"), - peg$decode("%2s\"\"6s7t.) &2u\"\"6u7v/\x9A#4w\"\"5!7x/\x8B$$%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4w\"\"5!7x/#$+\")(\"'#&'#0O*%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4w\"\"5!7x/#$+\")(\"'#&'#&/#$+#)(#'#(\"'#&'#"), - peg$decode("%2i\"\"6i7j/\x91#$%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4y\"\"5!7z/#$+\")(\"'#&'#/R#0O*%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4y\"\"5!7z/#$+\")(\"'#&'#&&&#/#$+\")(\"'#&'#"), - peg$decode("%;H.# &;F/& 8!:h! )"), - peg$decode("%;K/b#2{\"\"6{7|/S$;K.\" &\"/E$;G.\" &\"/7$4}\"\"5!7~.\" &\"/#$+%)(%'#($'#(#'#(\"'#&'#.\xB8 &%2{\"\"6{7|/N#;K/E$;G.\" &\"/7$4}\"\"5!7~.\" &\"/#$+$)($'#(#'#(\"'#&'#.w &%;K/@#;G/7$4}\"\"5!7~.\" &\"/#$+#)(#'#(\"'#&'#.J &%;K/@#;G.\" &\"/2$4}\"\"5!7~/#$+#)(#'#(\"'#&'#"), - peg$decode("%4\x7F\"\"5!7\x80/@#4\x81\"\"5!7\x82.\" &\"/,$;K/#$+#)(#'#(\"'#&'#"), - peg$decode("%;I/@#;J/7$4}\"\"5!7~.\" &\"/#$+#)(#'#(\"'#&'#"), - peg$decode("%2o\"\"6o7p.) &2q\"\"6q7r/I#;L.\" &\"/;$2{\"\"6{7|/,$;L/#$+$)($'#(#'#(\"'#&'#.A &%;B/7#2{\"\"6{7|.\" &\"/#$+\")(\"'#&'#"), - peg$decode("%4\x83\"\"5!7\x84/@#4\x81\"\"5!7\x82.\" &\"/,$;K/#$+#)(#'#(\"'#&'#"), - peg$decode("%4A\"\"5!7B/\x8B#$%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4A\"\"5!7B/#$+\")(\"'#&'#0O*%$4m\"\"5!7n0)*4m\"\"5!7n&/2#4A\"\"5!7B/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("%;M/\x7F#$%$4m\"\"5!7n0)*4m\"\"5!7n&/,#;M/#$+\")(\"'#&'#0I*%$4m\"\"5!7n0)*4m\"\"5!7n&/,#;M/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("4\x85\"\"5!7\x86.5 &4\x87\"\"5!7\x88.) &4A\"\"5!7B"), - peg$decode("%2\x89\"\"6\x897\x8A/\xA7#$;O.M &%%<4\x8B\"\"5!7\x8C=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#0S*;O.M &%%<4\x8B\"\"5!7\x8C=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#&/7$2\x89\"\"6\x897\x8A/($8#:\x8D#!!)(#'#(\"'#&'#.\xB7 &%2\x8E\"\"6\x8E7\x8F/\xA7#$;O.M &%%<4\x90\"\"5!7\x91=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#0S*;O.M &%%<4\x90\"\"5!7\x91=.##&&!&'#/1#1\"\"5!7I/#$+\")(\"'#&'#&/7$2\x8E\"\"6\x8E7\x8F/($8#:\x8D#!!)(#'#(\"'#&'#"), - peg$decode("%2\x92\"\"6\x927\x93/>#4\x94\"\"5!7\x95.) &;P.# &;Q/#$+\")(\"'#&'#"), - peg$decode("%4\x96\"\"5!7\x97/A#4y\"\"5!7z/2$4y\"\"5!7z/#$+#)(#'#(\"'#&'#.N &%4y\"\"5!7z/2#4y\"\"5!7z/#$+\")(\"'#&'#.) &4y\"\"5!7z"), - peg$decode("%$2\x98\"\"6\x987\x99/,#0)*2\x98\"\"6\x987\x99&&&#/G#;M/>$;M/5$;M/,$;M/#$+%)(%'#($'#(#'#(\"'#&'#"), - peg$decode("%2V\"\"6V7W/8#%<;9=.##&&!&'#/#$+\")(\"'#&'#.s &%2Y\"\"6Y7Z/8#%<;9=.##&&!&'#/#$+\")(\"'#&'#.H &%2\\\"\"6\\7]/8#%<;9=.##&&!&'#/#$+\")(\"'#&'#"), - peg$decode("3\x9A\"\"5\"7\x9B"), - peg$decode("3\x9C\"\"5!7\x9D"), - peg$decode("3\x9E\"\"5!7\x9F"), - peg$decode("3\xA0\"\"5\"7\xA1"), - peg$decode("2b\"\"6b7c"), - peg$decode("2\xA2\"\"6\xA27\xA3"), - peg$decode("3\xA4\"\"5!7\xA5"), - peg$decode("2{\"\"6{7|"), - peg$decode("3\xA6\"\"5\"7\xA7"), - peg$decode("3\xA8\"\"5#7\xA9"), - peg$decode("3\xAA\"\"5\"7\xAB"), - peg$decode("3\xAC\"\"5!7\xAD"), - peg$decode("2\xAE\"\"6\xAE7\xAF"), - peg$decode("2\xB0\"\"6\xB07\xB1"), - peg$decode("2\xB2\"\"6\xB27\xB3"), - peg$decode("3\xB4\"\"5\"7\xB5"), - peg$decode("2\xB6\"\"6\xB67\xB7"), - peg$decode("3\xB8\"\"5!7\xB9"), - peg$decode("3\xBA\"\"5\"7\xBB"), - peg$decode("3\xBC\"\"5\"7\xBD"), - peg$decode("3\xBE\"\"5#7\xBF"), - peg$decode("2\xAE\"\"6\xAE7\xAF"), - peg$decode("3\xC0\"\"5!7\xC1"), - peg$decode("3\xC2\"\"5\"7\xC3"), - peg$decode("3\xC4\"\"5#7\xC5"), - peg$decode("3\xC6\"\"5!7\xC7"), - peg$decode("3\xC8\"\"5!7\xC9"), - peg$decode("3\xCA\"\"5!7\xCB"), - peg$decode("3\xCC\"\"5\"7\xCD"), - peg$decode("3\xCE\"\"5!7\xCF"), - peg$decode("2\x9C\"\"6\x9C7\xD0"), - peg$decode("2\xD1\"\"6\xD17\xD2"), - peg$decode("2\xD3\"\"6\xD37\xD4"), - peg$decode("2\xD5\"\"6\xD57\xD6"), - peg$decode("2\xD7\"\"6\xD77\xD8"), - peg$decode("2\xD9\"\"6\xD97\xDA"), - peg$decode("3\xAE\"\"5!7\xDB"), - peg$decode("3\xDC\"\"5!7\xDD"), - peg$decode("3\xDE\"\"5!7\xDF") - ], - - 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)) { + var peg$c0 = "includes"; + var peg$c1 = "`"; + var peg$c2 = "\\$"; + var peg$c3 = "$"; + var peg$c4 = "\\${"; + var peg$c5 = "$\\{"; + var peg$c6 = "\\$\\{"; + var peg$c7 = "true"; + var peg$c8 = "false"; + var peg$c9 = "null"; + var peg$c10 = ":"; + var peg$c11 = "0"; + var peg$c12 = "0x"; + var peg$c13 = "0X"; + var peg$c14 = "0b"; + var peg$c15 = "0B"; + var peg$c16 = "."; + var peg$c17 = "'"; + var peg$c18 = "\""; + var peg$c19 = "\\"; + var peg$c20 = "u"; + var peg$c21 = "=>"; + var peg$c22 = "+"; + var peg$c23 = "&"; + var peg$c24 = "&&"; + var peg$c25 = ","; + var peg$c26 = "/"; + var peg$c27 = "=="; + var peg$c28 = "==="; + var peg$c29 = ">="; + var peg$c30 = ">"; + var peg$c31 = "-"; + var peg$c32 = "["; + var peg$c33 = "{"; + var peg$c34 = "<="; + var peg$c35 = "("; + var peg$c36 = "<"; + var peg$c37 = "<<"; + var peg$c38 = ">>"; + var peg$c39 = ">>>"; + var peg$c40 = "%"; + var peg$c41 = "!="; + var peg$c42 = "!=="; + var peg$c43 = "!"; + var peg$c44 = "~"; + var peg$c45 = "|"; + var peg$c46 = "||"; + var peg$c47 = "^"; + var peg$c48 = "++"; + var peg$c49 = "--"; + var peg$c50 = "]"; + var peg$c51 = "}"; + var peg$c52 = ")"; + var peg$c53 = "*"; + var peg$c54 = "?"; + + var peg$r0 = /^[ \t\r\n\f]/; + var peg$r1 = /^[$A-Z_a-z]/; + var peg$r2 = /^[$0-9A-Z_a-z]/; + var peg$r3 = /^[{]/; + var peg$r4 = /^[$`\\]/; + var peg$r5 = /^[lL]/; + var peg$r6 = /^[1-9]/; + var peg$r7 = /^[_]/; + var peg$r8 = /^[0-9]/; + var peg$r9 = /^[01]/; + var peg$r10 = /^[0-7]/; + var peg$r11 = /^[fFdD]/; + var peg$r12 = /^[eE]/; + var peg$r13 = /^[+\-]/; + var peg$r14 = /^[pP]/; + var peg$r15 = /^[0-9A-Fa-f]/; + var peg$r16 = /^['\\\n\r]/; + var peg$r17 = /^["\\\n\r]/; + var peg$r18 = /^[btnfr"'`\\]/; + var peg$r19 = /^[0-3]/; + + var peg$e0 = peg$literalExpectation("includes", false); + var peg$e1 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false); + var peg$e2 = peg$classExpectation(["$", ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e3 = peg$classExpectation(["$", ["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e4 = peg$literalExpectation("`", false); + var peg$e5 = peg$literalExpectation("\\$", false); + var peg$e6 = peg$classExpectation(["{"], false, false); + var peg$e7 = peg$anyExpectation(); + var peg$e8 = peg$literalExpectation("$", false); + var peg$e9 = peg$literalExpectation("\\${", false); + var peg$e10 = peg$literalExpectation("$\\{", false); + var peg$e11 = peg$literalExpectation("\\$\\{", false); + var peg$e12 = peg$classExpectation(["$", "`", "\\"], false, false); + var peg$e13 = peg$literalExpectation("true", false); + var peg$e14 = peg$literalExpectation("false", false); + var peg$e15 = peg$literalExpectation("null", false); + var peg$e16 = peg$literalExpectation(":", false); + var peg$e17 = peg$classExpectation(["l", "L"], false, false); + var peg$e18 = peg$literalExpectation("0", false); + var peg$e19 = peg$classExpectation([["1", "9"]], false, false); + var peg$e20 = peg$classExpectation(["_"], false, false); + var peg$e21 = peg$classExpectation([["0", "9"]], false, false); + var peg$e22 = peg$literalExpectation("0x", false); + var peg$e23 = peg$literalExpectation("0X", false); + var peg$e24 = peg$literalExpectation("0b", false); + var peg$e25 = peg$literalExpectation("0B", false); + var peg$e26 = peg$classExpectation(["0", "1"], false, false); + var peg$e27 = peg$classExpectation([["0", "7"]], false, false); + var peg$e28 = peg$literalExpectation(".", false); + var peg$e29 = peg$classExpectation(["f", "F", "d", "D"], false, false); + var peg$e30 = peg$classExpectation(["e", "E"], false, false); + var peg$e31 = peg$classExpectation(["+", "-"], false, false); + var peg$e32 = peg$classExpectation(["p", "P"], false, false); + var peg$e33 = peg$classExpectation([["0", "9"], ["A", "F"], ["a", "f"]], false, false); + var peg$e34 = peg$literalExpectation("'", false); + var peg$e35 = peg$classExpectation(["'", "\\", "\n", "\r"], false, false); + var peg$e36 = peg$literalExpectation("\"", false); + var peg$e37 = peg$classExpectation(["\"", "\\", "\n", "\r"], false, false); + var peg$e38 = peg$literalExpectation("\\", false); + var peg$e39 = peg$classExpectation(["b", "t", "n", "f", "r", "\"", "'", "`", "\\"], false, false); + var peg$e40 = peg$classExpectation([["0", "3"]], false, false); + var peg$e41 = peg$literalExpectation("u", false); + var peg$e42 = peg$literalExpectation("=>", true); + var peg$e43 = peg$literalExpectation("+", true); + var peg$e44 = peg$literalExpectation("&", true); + var peg$e45 = peg$literalExpectation("&&", true); + var peg$e46 = peg$literalExpectation(",", false); + var peg$e47 = peg$literalExpectation("/", true); + var peg$e48 = peg$literalExpectation("==", true); + var peg$e49 = peg$literalExpectation("===", true); + var peg$e50 = peg$literalExpectation(">=", true); + var peg$e51 = peg$literalExpectation(">", true); + var peg$e52 = peg$literalExpectation("-", false); + var peg$e53 = peg$literalExpectation("[", false); + var peg$e54 = peg$literalExpectation("{", false); + var peg$e55 = peg$literalExpectation("<=", true); + var peg$e56 = peg$literalExpectation("(", false); + var peg$e57 = peg$literalExpectation("<", true); + var peg$e58 = peg$literalExpectation("<<", true); + var peg$e59 = peg$literalExpectation(">>", true); + var peg$e60 = peg$literalExpectation(">>>", true); + var peg$e61 = peg$literalExpectation("%", true); + var peg$e62 = peg$literalExpectation("!=", true); + var peg$e63 = peg$literalExpectation("!==", true); + var peg$e64 = peg$literalExpectation("!", true); + var peg$e65 = peg$literalExpectation("~", true); + var peg$e66 = peg$literalExpectation("|", true); + var peg$e67 = peg$literalExpectation("||", true); + var peg$e68 = peg$literalExpectation("^", true); + var peg$e69 = peg$literalExpectation("+", false); + var peg$e70 = peg$literalExpectation("++", false); + var peg$e71 = peg$literalExpectation("--", false); + var peg$e72 = peg$literalExpectation("]", false); + var peg$e73 = peg$literalExpectation("}", false); + var peg$e74 = peg$literalExpectation(")", false); + var peg$e75 = peg$literalExpectation("-", true); + var peg$e76 = peg$literalExpectation("*", true); + var peg$e77 = peg$literalExpectation("?", true); + + var peg$f0 = function(args, expr) { + return { + type: 'LambdaExpression', + arguments: [args], + expression: expr + } + }; + var peg$f1 = function(expr) { + return { + type: 'LambdaExpression', + arguments: [], + expression: expr + } + }; + var peg$f2 = function(first, rest) { return buildList(first, rest, 1); }; + var peg$f3 = function(args, expr) { + return { + type: 'LambdaExpression', + arguments: args, + expression: expr + } + }; + var peg$f4 = function(test, left, right) { + return { + type: 'ConditionalExpression', + test: test, + left: left, + right: right + } + }; + var peg$f5 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'LogicalExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f6 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'LogicalExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f7 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'BitwiseExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f8 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'BitwiseExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f9 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'BitwiseExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f10 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'RelationalExpression', + operator: element[0][0], + left: result, + right: element[1] + }; + }); + }; + var peg$f11 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'RelationalExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f12 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'ShiftExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f13 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'BinaryExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f14 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'BinaryExpression', + operator: element[0][0].toLowerCase(), + left: result, + right: element[1] + }; + }); + }; + var peg$f15 = function(operator, operand) { return operand.type === 'NumberLiteral' && (operator === '-' || operator === '+') + ? + { + type: 'NumberLiteral', + value: (operator === '-' ? operator : '') + operand.value + } + : + (operator === '-' || operator === '+') && operand.type === 'PostfixExpression' && operand.argument.type === 'NumberLiteral' + ? + Object.assign(operand, {argument: { + type: 'NumberLiteral', + value: (operator === '-' ? operator : '') + operand.argument.value + }}) + : + { + type: 'UnaryExpression', + operator: operator, + argument: operand + }; + }; + var peg$f16 = function(operand, operator) { return operator + ? + { + type: 'PostfixExpression', + operator: operator, + argument: operand + } + : + operand + }; + var peg$f17 = function(expr) { return expr; }; + var peg$f18 = function(left, right) { + return { + type: 'RelationalExpression', + operator: 'in', + left: right, + right: left + } + }; + var peg$f19 = function(qual, args) { + return { + type: 'CallExpression', + object: qual, + arguments: args + }; + }; + var peg$f20 = function(qual, expr) { + return { + type: 'ArrayExpression', + object: qual, + index: expr + }; + }; + var peg$f21 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'MemberExpression', + object: result, + property: element[1] + }; + }); + }; + var peg$f22 = function(op) { return op[0].toLowerCase(); }; + var peg$f23 = function(first, rest) { return buildList(first, rest, 1); }; + var peg$f24 = function(args) { return args || []; }; + var peg$f25 = function(exp) { return exp; }; + var peg$f26 = function(first, last) { return { type: 'Identifier', name: first + last.join('') }; }; + var peg$f27 = function(capture) { return { + type: 'TemplateLiteral', + values: capture.reduce((r, v) => { + if(Array.isArray(v)) { + if(typeof(r[r.length - 1]) != 'string') + r.push('') + r[r.length - 1] += v[0] == undefined ? v[1] : v[0] + (v[1] == undefined ? v[2] : v[1]) + } else { + r.push(v); + } + return r; + }, []).map(v => typeof v == 'string' ? { type: 'Literal', value: v } : v ) + } + }; + var peg$f28 = function(expression) { return { + type: 'TemplateExpression', + value: expression + } + }; + var peg$f29 = function() { return { type: 'BooleanLiteral', value: true }; }; + var peg$f30 = function() { return { type: 'BooleanLiteral', value: false }; }; + var peg$f31 = function() { return { type: 'NullLiteral' }; }; + var peg$f32 = function(literal) { return literal; }; + var peg$f33 = function(first, rest) { return buildList(first, rest, 2)}; + var peg$f34 = function(properties) { return { type: 'ObjectLiteral', properties: properties } }; + var peg$f35 = function(key, value) { return { type: 'Property', key: key, value: value} }; + var peg$f36 = function(first, rest) { return buildList(first, rest, 2)}; + var peg$f37 = function(elements) { return { type: 'ArrayLiteral', elements: elements } }; + var peg$f38 = function() { return { type: 'NumberLiteral', value: text() }; }; + var peg$f39 = function() { return { type: 'NumberLiteral', value: text() }; }; + var peg$f40 = function(chars) { return { type: 'Literal', value: chars.map(l => l[0] == undefined ? l[1] : l[0] + l[1]).join('') } }; + var peg$f41 = function(chars) { return { type: 'Literal', value: chars.map(l => l[0] == undefined ? l[1] : l[0] + l[1]).join('') } }; + var peg$currPos = options.peg$currPos | 0; + var peg$savedPos = peg$currPos; + var peg$posDetailsCache = [{ line: 1, column: 1 }]; + var peg$maxFailPos = peg$currPos; + var peg$maxFailExpected = options.peg$maxFailExpected || []; + var peg$silentFails = options.peg$silentFails | 0; + + var peg$result; + + if (options.startRule) { + if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } - peg$startRuleIndex = peg$startRuleIndices[options.startRule]; + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } + function offset() { + return peg$savedPos; + } + + function range() { + return { + source: peg$source, + start: peg$savedPos, + end: 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) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -625,7 +610,9 @@ function peg$parse(input, options) { } function error(message, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } @@ -651,19 +638,22 @@ function peg$parse(input, options) { } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos], p; + var details = peg$posDetailsCache[pos]; + var p; if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} } details = peg$posDetailsCache[p]; details = { - line: details.line, + line: details.line, column: details.column }; @@ -679,26 +669,33 @@ function peg$parse(input, options) { } peg$posDetailsCache[pos] = details; + return details; } } - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos), - endPosDetails = peg$computePosDetails(endPos); + function peg$computeLocation(startPos, endPos, offset) { + var startPosDetails = peg$computePosDetails(startPos); + var endPosDetails = peg$computePosDetails(endPos); - return { + var res = { + source: peg$source, start: { offset: startPos, - line: startPosDetails.line, + line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, - line: endPosDetails.line, + line: endPosDetails.line, column: endPosDetails.column } }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; } function peg$fail(expected) { @@ -725,322 +722,4734 @@ function peg$parse(input, options) { ); } - 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; + function peg$parseStart() { + var s0; - 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]; - } + s0 = peg$parseArrowExpression(); - break; + return s0; + } - case 15: - ends.push(end); - ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); + function peg$parseArrowExpression() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; - if (stack[stack.length - 1] !== peg$FAILED) { - end = ip + 3 + bc[ip + 1]; - ip += 3; + s0 = peg$currPos; + s1 = peg$parseIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseARROW(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseConditionalExpression(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f0(s1, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseRPAR(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseARROW(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parseConditionalExpression(); + if (s7 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f1(s7); } else { - end = ip + 3 + bc[ip + 1] + bc[ip + 2]; - ip += 3 + bc[ip + 1]; + peg$currPos = s0; + s0 = peg$FAILED; } - - 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 { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = peg$parseIdentifier(); + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$currPos; + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s7 = [s7, s8]; + s6 = s7; } else { - ip += 2 + bc[ip + 1]; + peg$currPos = s6; + s6 = peg$FAILED; } - - 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; + if (s6 !== peg$FAILED) { + s7 = peg$parseIdentifier(); + if (s7 !== peg$FAILED) { + s6 = [s6, s7]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } else { - end = ip + 3 + bc[ip + 1] + bc[ip + 2]; - ip += 3 + bc[ip + 1]; + peg$currPos = s5; + s5 = peg$FAILED; } - - 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]; + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$currPos; + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = peg$parseIdentifier(); + if (s7 !== peg$FAILED) { + s6 = [s6, s7]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } - - 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; + peg$savedPos = s2; + s2 = peg$f2(s3, s4); + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseRPAR(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseARROW(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parseConditionalExpression(); + if (s7 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f3(s2, s7); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { - end = ip + 4 + bc[ip + 2] + bc[ip + 3]; - ip += 4 + bc[ip + 2]; + 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$parseConditionalExpression(); + } + } + } - break; + return s0; + } - case 20: - ends.push(end); - ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); + function peg$parseConditionalExpression() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - if (peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))) { - end = ip + 4 + bc[ip + 2]; - ip += 4; + s0 = peg$currPos; + s1 = peg$parseLogicalOrExpression(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseQMARK(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseConditionalExpression(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parseCOLON(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseConditionalExpression(); + if (s9 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f4(s1, s5, s9); } else { - end = ip + 4 + bc[ip + 2] + bc[ip + 3]; - ip += 4 + bc[ip + 2]; + 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$parseLogicalOrExpression(); + } - break; - - case 21: - stack.push(input.substr(peg$currPos, bc[ip + 1])); - peg$currPos += bc[ip + 1]; - ip += 2; - break; + return s0; + } - case 22: - stack.push(peg$consts[bc[ip + 1]]); - peg$currPos += peg$consts[bc[ip + 1]].length; - ip += 2; - break; + function peg$parseLogicalOrExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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]]; - } + s0 = peg$currPos; + s1 = peg$parseLogicalAndExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOROR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseLogicalAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOROR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseLogicalAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f5(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - stack.splice( - stack.length - bc[ip + 2], - bc[ip + 2], - peg$consts[bc[ip + 1]].apply(null, params) - ); + return s0; + } - ip += 4 + bc[ip + 3]; - break; + function peg$parseLogicalAndExpression() { + var s0, s1, s2, s3, s4, s5, s6; - case 27: - stack.push(peg$parseRule(bc[ip + 1])); - ip += 2; - break; + s0 = peg$currPos; + s1 = peg$parseBitwiseOrExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseANDAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseOrExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseANDAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseOrExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f6(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - case 28: - peg$silentFails++; - ip++; - break; + return s0; + } - case 29: - peg$silentFails--; - ip++; - break; + function peg$parseBitwiseOrExpression() { + var s0, s1, s2, s3, s4, s5, s6; - default: - throw new Error("Invalid opcode: " + bc[ip] + "."); - } + s0 = peg$currPos; + s1 = peg$parseBitwiseXOrExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; } - - if (ends.length > 0) { - end = ends.pop(); - ip = ips.pop(); + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseXOrExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } else { - break; + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseXOrExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } + peg$savedPos = s0; + s0 = peg$f7(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return stack[0]; + return s0; } + function peg$parseBitwiseXOrExpression() { + var s0, s1, s2, s3, s4, s5, s6; - function buildList(first, rest, index) { - var result = new Array(rest.length), i; - - for (i = 0; i < rest.length; i++) { - result[i] = rest[i][index]; + s0 = peg$currPos; + s1 = peg$parseBitwiseAndExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseXOR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseXOR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseBitwiseAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } - - return [first].concat(result); + peg$savedPos = s0; + s0 = peg$f8(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - function buildTree(first, rest, builder) { - var result = first, i; + return s0; + } + + function peg$parseBitwiseAndExpression() { + var s0, s1, s2, s3, s4, s5, s6; - for (i = 0; i < rest.length; i++) { - result = builder(result, rest[i]); + s0 = peg$currPos; + s1 = peg$parseEqualityExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; } - - return result; + if (s4 !== peg$FAILED) { + s5 = peg$parseEqualityExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseEqualityExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f9(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + return s0; + } - peg$result = peg$parseRule(peg$startRuleIndex); + function peg$parseEqualityExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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()); + s0 = peg$currPos; + s1 = peg$parseRelationalExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseEQUALSTRICT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUALSTRICT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseRelationalExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseEQUALSTRICT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUALSTRICT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseRelationalExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f10(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - 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 s0; } -} -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse + function peg$parseRelationalExpression() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseShiftExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseLE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseShiftExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseLE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseShiftExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f11(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseShiftExpression() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseAdditiveExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseRSHIFTZEROFILL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLSHIFT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseRSHIFT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseAdditiveExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseRSHIFTZEROFILL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLSHIFT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseRSHIFT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseAdditiveExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f12(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseAdditiveExpression() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseMultiplicativeExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseADD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseSUB(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseMultiplicativeExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseADD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseSUB(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseMultiplicativeExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f13(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseMultiplicativeExpression() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseUnaryExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseMUL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseDIV(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseMOD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseUnaryExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseMUL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseDIV(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseMOD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseUnaryExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f14(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseUnaryExpression() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parsePrefixOp(); + if (s1 !== peg$FAILED) { + s2 = peg$parsePostfixExpression(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f15(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parsePostfixExpression(); + } + + return s0; + } + + function peg$parsePostfixExpression() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parsePrimary(); + if (s1 !== peg$FAILED) { + s2 = peg$parseINCREMENT(); + if (s2 === peg$FAILED) { + s2 = peg$parseDECREMENT(); + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f16(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsePrimary() { + var s0; + + s0 = peg$parseParExpression(); + if (s0 === peg$FAILED) { + s0 = peg$parseQualifiedIdentifier(); + if (s0 === peg$FAILED) { + s0 = peg$parseTemplateLiteral(); + if (s0 === peg$FAILED) { + s0 = peg$parseLiteral(); + } + } + } + + return s0; + } + + function peg$parseParExpression() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseConditionalExpression(); + if (s3 !== peg$FAILED) { + s4 = peg$parseRPAR(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f17(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseQualifiedIdentifier() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseArrayLiteral(); + if (s2 === peg$FAILED) { + s2 = peg$parseIdentifier(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseDOT(); + if (s3 !== peg$FAILED) { + if (input.substr(peg$currPos, 8) === peg$c0) { + s4 = peg$c0; + peg$currPos += 8; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseLPAR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parsePrimary(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseRPAR(); + if (s9 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f18(s2, s7); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$parseArguments(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f19(s2, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 === peg$FAILED) { + s2 = peg$parseLiteral(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseLBRK(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseConditionalExpression(); + if (s5 !== peg$FAILED) { + s6 = peg$parseRBRK(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f20(s2, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 === peg$FAILED) { + s2 = peg$parseStringLiteral(); + if (s2 === peg$FAILED) { + s2 = peg$parseTemplateLiteral(); + } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + s5 = peg$parseDOT(); + if (s5 !== peg$FAILED) { + s6 = peg$parseQualifiedIdentifier(); + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = peg$parseDOT(); + if (s5 !== peg$FAILED) { + s6 = peg$parseQualifiedIdentifier(); + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f21(s2, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + } + + return s0; + } + + function peg$parsePrefixOp() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseNOT(); + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parseINCREMENT(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parseDECREMENT(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parsePLUS(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parseMINUS(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parseBNOT(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + } + } + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f22(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseArguments() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$currPos; + s4 = peg$parseArrowExpression(); + if (s4 === peg$FAILED) { + s4 = peg$parseConditionalExpression(); + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$currPos; + s8 = peg$parseCOMMA(); + if (s8 !== peg$FAILED) { + s9 = peg$parse__(); + s8 = [s8, s9]; + s7 = s8; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + s8 = peg$parseArrowExpression(); + if (s8 === peg$FAILED) { + s8 = peg$parseConditionalExpression(); + } + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$currPos; + s8 = peg$parseCOMMA(); + if (s8 !== peg$FAILED) { + s9 = peg$parse__(); + s8 = [s8, s9]; + s7 = s8; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + s8 = peg$parseArrowExpression(); + if (s8 === peg$FAILED) { + s8 = peg$parseConditionalExpression(); + } + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } + peg$savedPos = s3; + s3 = peg$f23(s4, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$parseRPAR(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f24(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDim() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseLBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseRBRK(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDimExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseLBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseConditionalExpression(); + if (s3 !== peg$FAILED) { + s4 = peg$parseRBRK(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f25(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parse__() { + var s0, s1, s2; + + s0 = []; + s1 = []; + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s1 = peg$FAILED; + } + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = []; + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s1 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseIdentifier() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseLetter(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseLetterOrDigit(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseLetterOrDigit(); + } + s3 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f26(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseLetter() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r1.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + + return s0; + } + + function peg$parseLetterOrDigit() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r2.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + + return s0; + } + + function peg$parseTemplateLiteral() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 96) { + s1 = peg$c1; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseTemplateExpression(); + if (s3 === peg$FAILED) { + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c2) { + s4 = peg$c2; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = input.charAt(peg$currPos); + if (peg$r3.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = undefined; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s6 !== peg$FAILED) { + s4 = [s4, s5, s6]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 36) { + s4 = peg$c3; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = input.charAt(peg$currPos); + if (peg$r3.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = undefined; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s6 !== peg$FAILED) { + s4 = [s4, s5, s6]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c4) { + s4 = peg$c4; + peg$currPos += 3; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c5) { + s4 = peg$c5; + peg$currPos += 3; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c6) { + s4 = peg$c6; + peg$currPos += 4; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r4.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + } + } + } + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseTemplateExpression(); + if (s3 === peg$FAILED) { + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c2) { + s4 = peg$c2; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = input.charAt(peg$currPos); + if (peg$r3.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = undefined; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s6 !== peg$FAILED) { + s4 = [s4, s5, s6]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 36) { + s4 = peg$c3; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = input.charAt(peg$currPos); + if (peg$r3.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = undefined; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s6 !== peg$FAILED) { + s4 = [s4, s5, s6]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c4) { + s4 = peg$c4; + peg$currPos += 3; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c5) { + s4 = peg$c5; + peg$currPos += 3; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c6) { + s4 = peg$c6; + peg$currPos += 4; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r4.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + } + } + } + } + } + } + if (input.charCodeAt(peg$currPos) === 96) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f27(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseTemplateExpression() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 36) { + s1 = peg$c3; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseLCBRK(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s4 = peg$parseConditionalExpression(); + if (s4 !== peg$FAILED) { + s5 = peg$parseRCBRK(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f28(s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseLiteral() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseObjectLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseFloatLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseIntegerLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseStringLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseArrayLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c7) { + s2 = peg$c7; + peg$currPos += 4; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f29(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c8) { + s2 = peg$c8; + peg$currPos += 5; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f30(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c9) { + s2 = peg$c9; + peg$currPos += 4; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f31(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + } + } + } + } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f32(s1); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseObjectLiteral() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseLCBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$currPos; + s4 = peg$parseObjectProperty(); + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseObjectProperty(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseObjectProperty(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } + peg$savedPos = s3; + s3 = peg$f33(s4, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$currPos; + s5 = peg$parseCOMMA(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = null; + } + s5 = peg$parse__(); + s6 = peg$parseRCBRK(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f34(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseObjectProperty() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parse__(); + s2 = peg$parseIdentifier(); + if (s2 === peg$FAILED) { + s2 = peg$parseIntegerLiteral(); + if (s2 === peg$FAILED) { + s2 = peg$parseStringLiteral(); + } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c10; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + s6 = peg$parseConditionalExpression(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f35(s2, s6); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseArrayLiteral() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseLBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$currPos; + s4 = peg$parseConditionalExpression(); + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseConditionalExpression(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseConditionalExpression(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } + peg$savedPos = s3; + s3 = peg$f36(s4, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$currPos; + s5 = peg$parseCOMMA(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = null; + } + s5 = peg$parse__(); + s6 = peg$parseRBRK(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f37(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseIntegerLiteral() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parseHexNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseBinaryNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseOctalNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseDecimalNumeral(); + } + } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r5.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + peg$savedPos = s0; + s0 = peg$f38(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDecimalNumeral() { + var s0, s1, s2, s3, s4, s5; + + if (input.charCodeAt(peg$currPos) === 48) { + s0 = peg$c11; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r6.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseHexNumeral() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c12) { + s1 = peg$c12; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c13) { + s1 = peg$c13; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e23); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigits(); + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseBinaryNumeral() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c14) { + s1 = peg$c14; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c15) { + s1 = peg$c15; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e25); } + } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r9.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s6 = input.charAt(peg$currPos); + if (peg$r9.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s6 = input.charAt(peg$currPos); + if (peg$r9.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOctalNumeral() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 48) { + s1 = peg$c11; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r10.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r10.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseFloatLiteral() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseHexFloat(); + if (s1 === peg$FAILED) { + s1 = peg$parseDecimalFloat(); + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f39(); + } + s0 = s1; + + return s0; + } + + function peg$parseDecimalFloat() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c16; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseDigits(); + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$parseExponent(); + if (s4 === peg$FAILED) { + s4 = null; + } + s5 = input.charAt(peg$currPos); + if (peg$r11.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + s1 = [s1, s2, s3, s4, s5]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c16; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseDigits(); + if (s2 !== peg$FAILED) { + s3 = peg$parseExponent(); + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = input.charAt(peg$currPos); + if (peg$r11.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + s2 = peg$parseExponent(); + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r11.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + s2 = peg$parseExponent(); + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = input.charAt(peg$currPos); + if (peg$r11.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + + return s0; + } + + function peg$parseExponent() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r12.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e30); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r13.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parseDigits(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexFloat() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseHexSignificand(); + if (s1 !== peg$FAILED) { + s2 = peg$parseBinaryExponent(); + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r11.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexSignificand() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c12) { + s1 = peg$c12; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c13) { + s1 = peg$c13; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e23); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigits(); + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c16; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseHexDigits(); + if (s4 !== peg$FAILED) { + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseHexNumeral(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c16; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseBinaryExponent() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r14.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e32); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r13.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parseDigits(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDigits() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r8.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexDigits() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseHexDigit(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r7.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + } + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexDigit() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r15.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e33); } + } + + return s0; + } + + function peg$parseStringLiteral() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c17; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e34); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r16.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e35); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r16.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e35); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c17; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e34); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f40(s2); + } 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) === 34) { + s1 = peg$c18; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e36); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r17.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r17.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c18; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e36); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f41(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseEscape() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c19; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e38); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r18.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e39); } + } + if (s2 === peg$FAILED) { + s2 = peg$parseOctalEscape(); + if (s2 === peg$FAILED) { + s2 = peg$parseUnicodeEscape(); + } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOctalEscape() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r19.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e40); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r10.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r10.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r10.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r10.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = input.charAt(peg$currPos); + if (peg$r10.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + } + } + + return s0; + } + + function peg$parseUnicodeEscape() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = []; + if (input.charCodeAt(peg$currPos) === 117) { + s2 = peg$c20; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e41); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (input.charCodeAt(peg$currPos) === 117) { + s2 = peg$c20; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e41); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigit(); + if (s2 !== peg$FAILED) { + s3 = peg$parseHexDigit(); + if (s3 !== peg$FAILED) { + s4 = peg$parseHexDigit(); + if (s4 !== peg$FAILED) { + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseReservedWord() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c7) { + s1 = peg$c7; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } 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; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c8) { + s1 = peg$c8; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } 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; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c9) { + s1 = peg$c9; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + + return s0; + } + + function peg$parseARROW() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c21) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e42); } + } + + return s0; + } + + function peg$parseADD() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c22) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e43); } + } + + return s0; + } + + function peg$parseAND() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c23) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e44); } + } + + return s0; + } + + function peg$parseANDAND() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c24) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e45); } + } + + return s0; + } + + function peg$parseCOLON() { + var s0; + + if (input.charCodeAt(peg$currPos) === 58) { + s0 = peg$c10; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + + return s0; + } + + function peg$parseCOMMA() { + var s0; + + if (input.charCodeAt(peg$currPos) === 44) { + s0 = peg$c25; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e46); } + } + + return s0; + } + + function peg$parseDIV() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c26) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e47); } + } + + return s0; + } + + function peg$parseDOT() { + var s0; + + if (input.charCodeAt(peg$currPos) === 46) { + s0 = peg$c16; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + + return s0; + } + + function peg$parseEQUAL() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c27) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e48); } + } + + return s0; + } + + function peg$parseEQUALSTRICT() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c28) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e49); } + } + + return s0; + } + + function peg$parseGE() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c29) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e50); } + } + + return s0; + } + + function peg$parseGT() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c30) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e51); } + } + + return s0; + } + + function peg$parseHYPHEN() { + var s0; + + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c31; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e52); } + } + + return s0; + } + + function peg$parseLBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 91) { + s0 = peg$c32; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e53); } + } + + return s0; + } + + function peg$parseLCBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 123) { + s0 = peg$c33; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e54); } + } + + return s0; + } + + function peg$parseLE() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c34) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e55); } + } + + return s0; + } + + function peg$parseLPAR() { + var s0; + + if (input.charCodeAt(peg$currPos) === 40) { + s0 = peg$c35; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e56); } + } + + return s0; + } + + function peg$parseLT() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c36) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e57); } + } + + return s0; + } + + function peg$parseLSHIFT() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c37) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e58); } + } + + return s0; + } + + function peg$parseRSHIFT() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c38) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e59); } + } + + return s0; + } + + function peg$parseRSHIFTZEROFILL() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c39) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e60); } + } + + return s0; + } + + function peg$parseMINUS() { + var s0; + + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c31; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e52); } + } + + return s0; + } + + function peg$parseMOD() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c40) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e61); } + } + + return s0; + } + + function peg$parseNOTEQUAL() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c41) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e62); } + } + + return s0; + } + + function peg$parseNOTEQUALSTRICT() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c42) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e63); } + } + + return s0; + } + + function peg$parseNOT() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c43) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e64); } + } + + return s0; + } + + function peg$parseBNOT() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c44) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e65); } + } + + return s0; + } + + function peg$parseOR() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c45) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e66); } + } + + return s0; + } + + function peg$parseOROR() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c46) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e67); } + } + + return s0; + } + + function peg$parseXOR() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c47) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e68); } + } + + return s0; + } + + function peg$parsePLUS() { + var s0; + + if (input.charCodeAt(peg$currPos) === 43) { + s0 = peg$c22; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e69); } + } + + return s0; + } + + function peg$parseINCREMENT() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c48) { + s0 = peg$c48; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e70); } + } + + return s0; + } + + function peg$parseDECREMENT() { + var s0; + + if (input.substr(peg$currPos, 2) === peg$c49) { + s0 = peg$c49; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e71); } + } + + return s0; + } + + function peg$parseRBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 93) { + s0 = peg$c50; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e72); } + } + + return s0; + } + + function peg$parseRCBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 125) { + s0 = peg$c51; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e73); } + } + + return s0; + } + + function peg$parseRPAR() { + var s0; + + if (input.charCodeAt(peg$currPos) === 41) { + s0 = peg$c52; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e74); } + } + + return s0; + } + + function peg$parseSUB() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c31) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e75); } + } + + return s0; + } + + function peg$parseMUL() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c53) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e76); } + } + + return s0; + } + + function peg$parseQMARK() { + var s0; + + s0 = input.charAt(peg$currPos); + if (s0.toLowerCase() === peg$c54) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e77); } + } + + return s0; + } + + + function buildList(first, rest, index) { + var result = new Array(rest.length), i; + + for (i = 0; i < rest.length; i++) { + result[i] = rest[i][index]; + } + + return [first].concat(result); + } + + function buildTree(first, rest, builder) { + var result = first, i; + + for (i = 0; i < rest.length; i++) { + result = builder(result, rest[i]); + } + + return result; + } + + peg$result = peg$startRuleFunction(); + + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos + }); + } + 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) + ); + } +} + +const peg$allowedStartRules = [ + "Start" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse }; diff --git a/src/linq/peg/parser/odata-parser.js b/src/linq/peg/parser/odata-parser.js index 6b9be11..f21334e 100644 --- a/src/linq/peg/parser/odata-parser.js +++ b/src/linq/peg/parser/odata-parser.js @@ -1,62 +1,99 @@ -/* - * Generated by PEG.js 0.10.0. - * - * http://pegjs.org/ - */ +// @generated by Peggy 4.0.2. +// +// https://peggyjs.org/ -"use strict"; function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); } 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); + var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments + if (Object.setPrototypeOf) { + Object.setPrototypeOf(self, peg$SyntaxError.prototype); } + self.expected = expected; + self.found = found; + self.location = location; + self.name = "SyntaxError"; + return self; } peg$subclass(peg$SyntaxError, Error); +function peg$padEnd(str, targetLength, padString) { + padString = padString || " "; + if (str.length > targetLength) { return str; } + targetLength -= str.length; + padString += padString.repeat(targetLength); + return str + padString.slice(0, targetLength); +} + +peg$SyntaxError.prototype.format = function(sources) { + var str = "Error: " + this.message; + if (this.location) { + var src = null; + var k; + for (k = 0; k < sources.length; k++) { + if (sources[k].source === this.location.source) { + src = sources[k].text.split(/\r\n|\n|\r/g); + break; + } + } + var s = this.location.start; + var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + if (src) { + var e = this.location.end; + var filler = peg$padEnd("", offset_s.line.toString().length, ' '); + var line = src[s.line - 1]; + var last = s.line === e.line ? e.column : line.length + 1; + var hatLen = (last - s.column) || 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + offset_s.line + " | " + line + "\n" + + filler + " | " + peg$padEnd("", s.column - 1, ' ') + + peg$padEnd("", hatLen, "^"); + } else { + str += "\n at " + loc; + } + } + return str; +}; + peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - "class": function(expectation) { - var escapedParts = "", - i; + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, - 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]); - } + class: function(expectation) { + var escapedParts = expectation.parts.map(function(part) { + return Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part); + }); - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; + }, - any: function(expectation) { - return "any character"; - }, + any: function() { + return "any character"; + }, - end: function(expectation) { - return "end of input"; - }, + end: function() { + return "end of input"; + }, - other: function(expectation) { - return expectation.description; - } - }; + other: function(expectation) { + return expectation.description; + } + }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); @@ -64,28 +101,28 @@ peg$SyntaxError.buildMessage = function(expected, found) { 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); }); + .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); }); + .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) { @@ -93,12 +130,8 @@ peg$SyntaxError.buildMessage = function(expected, found) { } function describeExpected(expected) { - var descriptions = new Array(expected.length), - i, j; - - for (i = 0; i < expected.length; i++) { - descriptions[i] = describeExpectation(expected[i]); - } + var descriptions = expected.map(describeExpectation); + var i, j; descriptions.sort(); @@ -134,380 +167,321 @@ peg$SyntaxError.buildMessage = function(expected, found) { }; function peg$parse(input, options) { - options = options !== void 0 ? options : {}; + options = options !== undefined ? options : {}; - var peg$FAILED = {}, + var peg$FAILED = {}; + var peg$source = options.grammarSource; - peg$startRuleIndices = { Start: 0 }, - peg$startRuleIndex = 0, + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; - peg$consts = [ - function(args, expr) { - return { - type: 'LambdaExpression', - arguments: [args], - expression: expr - } - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'LogicalExpression', - operator: '||', - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'LogicalExpression', - operator: '&&', - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - let map = { 'eq': '==', 'ne': '!=' } - - return { - type: 'RelationalExpression', - operator: map[element[0][0].toLowerCase()], - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - let map = { 'le': '<=', 'ge': '>=', 'lt': '<', 'gt': '>' } - - return { - type: 'RelationalExpression', - operator: map[element[0][0].toLowerCase()], - left: result, - right: element[1] - }; - }); - }, - "in", - peg$literalExpectation("IN", true), - function(first, rest) { - return buildTree(first, rest, function(result, element) { - return { - type: 'RelationalExpression', - operator: 'in', - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - let map = { 'add': '+', 'sub': '-' } - - return { - type: 'BinaryExpression', - operator: map[element[0][0].toLowerCase()], - left: result, - right: element[1] - }; - }); - }, - function(first, rest) { - return buildTree(first, rest, function(result, element) { - let map = { 'mul': '*', 'div': '/', 'mod': '%' } - - return { - type: 'BinaryExpression', - operator: map[element[0][0].toLowerCase()], - left: result, - right: element[1] - }; - }); - }, - function(operator, operand) { - return operand.type === 'NumberLiteral' && (operator === '-' || operator === '+') - ? - { - type: 'NumberLiteral', - value: (operator === '-' ? operator : '') + operand.value - } - : - { - type: 'UnaryExpression', - operator: operator, - argument: operand - }; - }, - function(expr) { return expr; }, - function(qual, args) { - return { - type: 'CallExpression', - object: qual, - arguments: args - }; - }, - function(qual, expr) { - return { - type: 'ArrayExpression', - array: qual, - index: expr - }; - }, - function(first, i) { return i; }, - function(first, list) { - if(list) { - return { - type: 'MemberExpression', - object: first, - property: list - } - } - return first; - }, - function(op) { - let map = { 'not': '!', '+': '+', '-': '-' } - return map[op[0].toLowerCase()]; - }, - function(first, rest) { return buildList(first, rest, 1); }, - function(args) { return args || []; }, - function(exp) { return exp; }, - /^[ \t\r\n\f]/, - peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false), - function(first, last) { return { type: 'Identifier', name: first + last.join('') }; }, - /^[a-z]/, - peg$classExpectation([["a", "z"]], false, false), - /^[A-Z]/, - peg$classExpectation([["A", "Z"]], false, false), - /^[_$]/, - peg$classExpectation(["_", "$"], false, false), - /^[0-9]/, - peg$classExpectation([["0", "9"]], false, false), - "true", - peg$literalExpectation("true", false), - function() { return { type: 'BooleanLiteral', value: true }; }, - "false", - peg$literalExpectation("false", false), - function() { return { type: 'BooleanLiteral', value: false }; }, - "null", - peg$literalExpectation("null", false), - function() { return { type: 'NullLiteral' }; }, - function(literal) { return literal; }, - /^[lL]/, - peg$classExpectation(["l", "L"], false, false), - function() { return { type: 'NumberLiteral', value: text() }; }, - "0", - peg$literalExpectation("0", false), - /^[1-9]/, - peg$classExpectation([["1", "9"]], false, false), - /^[_]/, - peg$classExpectation(["_"], false, false), - "0x", - peg$literalExpectation("0x", false), - "0X", - peg$literalExpectation("0X", false), - "0b", - peg$literalExpectation("0b", false), - "0B", - peg$literalExpectation("0B", false), - /^[01]/, - peg$classExpectation(["0", "1"], false, false), - /^[0-7]/, - peg$classExpectation([["0", "7"]], false, false), - "-", - peg$literalExpectation("-", false), - "T", - peg$literalExpectation("T", false), - ":", - peg$literalExpectation(":", false), - ".", - peg$literalExpectation(".", false), - "Z", - peg$literalExpectation("Z", false), - function(value) { return { type: 'DateTimeLiteral', value: flattenArray(value).join('') }; }, - "datetime", - peg$literalExpectation("datetime", true), - "'", - peg$literalExpectation("'", false), - function(first, value, last) { return { type: 'DateTimeLiteral', value: flattenArray(value).join('') }; }, - function(value) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; }, - "date", - peg$literalExpectation("date", true), - function(first, value, last) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; }, - /^[fFdD]/, - peg$classExpectation(["f", "F", "d", "D"], false, false), - /^[eE]/, - peg$classExpectation(["e", "E"], false, false), - /^[+\-]/, - peg$classExpectation(["+", "-"], false, false), - /^[pP]/, - peg$classExpectation(["p", "P"], false, false), - /^[a-f]/, - peg$classExpectation([["a", "f"]], false, false), - /^[A-F]/, - peg$classExpectation([["A", "F"]], false, false), - /^['\\\n\r]/, - peg$classExpectation(["'", "\\", "\n", "\r"], false, false), - peg$anyExpectation(), - function(chars) { return { type: 'Literal', value: chars.map(l => l[0] == undefined ? l[1] : l[0] + l[1]).join('').replace(/\\(["'\\])|'(')/g, '$1$2') } }, - function(first, rest) { return buildList(first, rest, 2)}, - function(elements) { return { type: 'ArrayLiteral', elements: elements } }, - "''", - peg$literalExpectation("''", false), - "\\", - peg$literalExpectation("\\", false), - /^[btnfr"'\\]/, - peg$classExpectation(["b", "t", "n", "f", "r", "\"", "'", "\\"], false, false), - /^[0-3]/, - peg$classExpectation([["0", "3"]], false, false), - "u", - peg$literalExpectation("u", false), - "add", - peg$literalExpectation("add", true), - "and", - peg$literalExpectation("and", true), - ",", - peg$literalExpectation(",", false), - "div", - peg$literalExpectation("div", true), - "/", - peg$literalExpectation("/", false), - "eq", - peg$literalExpectation("eq", true), - "ge", - peg$literalExpectation("ge", true), - "gt", - peg$literalExpectation("gt", true), - "[", - peg$literalExpectation("[", false), - "le", - peg$literalExpectation("le", true), - "(", - peg$literalExpectation("(", false), - "lt", - peg$literalExpectation("lt", true), - "mod", - peg$literalExpectation("mod", true), - "ne", - peg$literalExpectation("ne", true), - "not", - peg$literalExpectation("not", true), - "or", - peg$literalExpectation("or", true), - "+", - peg$literalExpectation("+", false), - "]", - peg$literalExpectation("]", false), - ")", - peg$literalExpectation(")", false), - "sub", - peg$literalExpectation("sub", true), - "mul", - peg$literalExpectation("mul", true) - ], - - peg$bytecode = [ - peg$decode(";\""), - peg$decode("%;2/M#;1/D$;N/;$;1/2$;\"/)$8%: %\"$ )(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;#/\x85#$%%;^/,#;1/#$+\")(\"'#&'#/,#;#/#$+\")(\"'#&'#0I*%%;^/,#;1/#$+\")(\"'#&'#/,#;#/#$+\")(\"'#&'#&/)$8\":!\"\"! )(\"'#&'#"), - peg$decode("%;$/\x85#$%%;M/,#;1/#$+\")(\"'#&'#/,#;$/#$+\")(\"'#&'#0I*%%;M/,#;1/#$+\")(\"'#&'#/,#;$/#$+\")(\"'#&'#&/)$8\":\"\"\"! )(\"'#&'#"), - peg$decode("%;%/\xB7#$%%;R/,#;1/#$+\")(\"'#&'#.6 &%;\\/,#;1/#$+\")(\"'#&'#/,#;%/#$+\")(\"'#&'#0b*%%;R/,#;1/#$+\")(\"'#&'#.6 &%;\\/,#;1/#$+\")(\"'#&'#/,#;%/#$+\")(\"'#&'#&/)$8\":#\"\"! )(\"'#&'#"), - peg$decode("%;&/\u011B#$%%;W/,#;1/#$+\")(\"'#&'#.h &%;S/,#;1/#$+\")(\"'#&'#.O &%;Y/,#;1/#$+\")(\"'#&'#.6 &%;T/,#;1/#$+\")(\"'#&'#/,#;&/#$+\")(\"'#&'#0\x94*%%;W/,#;1/#$+\")(\"'#&'#.h &%;S/,#;1/#$+\")(\"'#&'#.O &%;Y/,#;1/#$+\")(\"'#&'#.6 &%;T/,#;1/#$+\")(\"'#&'#/,#;&/#$+\")(\"'#&'#&/)$8\":$\"\"! )(\"'#&'#"), - peg$decode("%;'/\x91#$%%3%\"\"5\"7&/,#;1/#$+\")(\"'#&'#/,#;'/#$+\")(\"'#&'#0O*%%3%\"\"5\"7&/,#;1/#$+\")(\"'#&'#/,#;'/#$+\")(\"'#&'#&/)$8\":'\"\"! )(\"'#&'#"), - peg$decode("%;(/\xB7#$%%;L/,#;1/#$+\")(\"'#&'#.6 &%;b/,#;1/#$+\")(\"'#&'#/,#;(/#$+\")(\"'#&'#0b*%%;L/,#;1/#$+\")(\"'#&'#.6 &%;b/,#;1/#$+\")(\"'#&'#/,#;(/#$+\")(\"'#&'#&/)$8\":(\"\"! )(\"'#&'#"), - peg$decode("%;)/\xE9#$%%;c/,#;1/#$+\")(\"'#&'#.O &%;P/,#;1/#$+\")(\"'#&'#.6 &%;[/,#;1/#$+\")(\"'#&'#/,#;)/#$+\")(\"'#&'#0{*%%;c/,#;1/#$+\")(\"'#&'#.O &%;P/,#;1/#$+\")(\"'#&'#.6 &%;[/,#;1/#$+\")(\"'#&'#/,#;)/#$+\")(\"'#&'#&/)$8\":)\"\"! )(\"'#&'#"), - peg$decode("%;-/2#;*/)$8\":*\"\"! )(\"'#&'#.# &;*"), - peg$decode(";+.5 &;;./ &;<.) &;,.# &;5"), - peg$decode("%;X/L#;1/C$;\"/:$;a/1$;1/($8%:+%!\")(%'#($'#(#'#(\"'#&'#"), - peg$decode("%%<;K=.##&&!&'#/;#;2/2$;./)$8#:,#\"! )(#'#(\"'#&'#.\xC7 &%%<;K=.##&&!&'#/_#;2/V$;V/M$;1/D$;\"/;$;`/2$;1/)$8':-'\"%\")(''#(&'#(%'#($'#(#'#(\"'#&'#.o &%%<;K=.##&&!&'#/Y#;2/P$%;Q/2#;,/)$8\":.\"\"# )(\"'#&'#.\" &\"/)$8#:/#\"! )(#'#(\"'#&'#"), - peg$decode("%%;]/,#;1/#$+\")(\"'#&'#.O &%;_/,#;1/#$+\")(\"'#&'#.6 &%;Z/,#;1/#$+\")(\"'#&'#/' 8!:0!! )"), - peg$decode("%;X/\xCF#;1/\xC6$%;!.# &;\"/\x91#$%%;O/,#;1/#$+\")(\"'#&'#/2#;!.# &;\"/#$+\")(\"'#&'#0O*%%;O/,#;1/#$+\")(\"'#&'#/2#;!.# &;\"/#$+\")(\"'#&'#&/)$8\":1\"\"! )(\"'#&'#.\" &\"/:$;a/1$;1/($8%:2%!\")(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;V/>#;1/5$;`/,$;1/#$+$)($'#(#'#(\"'#&'#"), - peg$decode("%;V/L#;1/C$;\"/:$;`/1$;1/($8%:3%!\")(%'#($'#(#'#(\"'#&'#"), - peg$decode("$$44\"\"5!75/,#0)*44\"\"5!75&&�<*$44\"\"5!75/,#0)*44\"\"5!75&&&#&"), - peg$decode("%;3/B#$;40#*;4&/2$;1/)$8#:6#\"\"!)(#'#(\"'#&'#"), - peg$decode("47\"\"5!78.5 &49\"\"5!7:.) &4;\"\"5!7<"), - peg$decode("47\"\"5!78.A &49\"\"5!7:.5 &4=\"\"5!7>.) &4;\"\"5!7<"), - peg$decode("%;=.\xBC &;6.\xB6 &;F.\xB0 &;G.\xAA &%2?\"\"6?7@/<#%<;4=.##&&!&'#/'$8\":A\" )(\"'#&'#.{ &%2B\"\"6B7C/<#%<;4=.##&&!&'#/'$8\":D\" )(\"'#&'#.L &%2E\"\"6E7F/<#%<;4=.##&&!&'#/'$8\":G\" )(\"'#&'#/1#;1/($8\":H\"!!)(\"'#&'#"), - peg$decode("%;8./ &;9.) &;:.# &;7/;#4I\"\"5!7J.\" &\"/'$8\":K\" )(\"'#&'#"), - peg$decode("2L\"\"6L7M.\x9B &%4N\"\"5!7O/\x8B#$%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4=\"\"5!7>/#$+\")(\"'#&'#0O*%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4=\"\"5!7>/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("%2R\"\"6R7S.) &2T\"\"6T7U/,#;D/#$+\")(\"'#&'#"), - peg$decode("%2V\"\"6V7W.) &2X\"\"6X7Y/\x9A#4Z\"\"5!7[/\x8B$$%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4Z\"\"5!7[/#$+\")(\"'#&'#0O*%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4Z\"\"5!7[/#$+\")(\"'#&'#&/#$+#)(#'#(\"'#&'#"), - peg$decode("%2L\"\"6L7M/\x91#$%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4\\\"\"5!7]/#$+\")(\"'#&'#/R#0O*%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4\\\"\"5!7]/#$+\")(\"'#&'#&&&#/#$+\")(\"'#&'#"), - peg$decode("%%4=\"\"5!7>/\u0198#4=\"\"5!7>/\u0189$4=\"\"5!7>/\u017A$4=\"\"5!7>/\u016B$2^\"\"6^7_/\u015C$4=\"\"5!7>/\u014D$4=\"\"5!7>/\u013E$2^\"\"6^7_/\u012F$4=\"\"5!7>/\u0120$4=\"\"5!7>/\u0111$%2`\"\"6`7a/\xE4#4=\"\"5!7>/\xD5$4=\"\"5!7>/\xC6$2b\"\"6b7c/\xB7$4=\"\"5!7>/\xA8$4=\"\"5!7>/\x99$%2b\"\"6b7c/{#4=\"\"5!7>/l$4=\"\"5!7>/]$%2d\"\"6d7e/?#$4=\"\"5!7>0)*4=\"\"5!7>&/#$+\")(\"'#&'#.\" &\"/#$+$)($'#(#'#(\"'#&'#.\" &\"/#$+')(''#(&'#(%'#($'#(#'#(\"'#&'#/7$2f\"\"6f7g.\" &\"/#$+,)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#/1#;1/($8\":h\"!!)(\"'#&'#.\u01F4 &%3i\"\"5(7j/\u01E4#2k\"\"6k7l/\u01D5$%4=\"\"5!7>/\u019D#4=\"\"5!7>/\u018E$4=\"\"5!7>/\u017F$4=\"\"5!7>/\u0170$2^\"\"6^7_/\u0161$4=\"\"5!7>/\u0152$4=\"\"5!7>/\u0143$2^\"\"6^7_/\u0134$4=\"\"5!7>/\u0125$4=\"\"5!7>/\u0116$%2`\"\"6`7a/\xE4#4=\"\"5!7>/\xD5$4=\"\"5!7>/\xC6$2b\"\"6b7c/\xB7$4=\"\"5!7>/\xA8$4=\"\"5!7>/\x99$%2b\"\"6b7c/{#4=\"\"5!7>/l$4=\"\"5!7>/]$%2d\"\"6d7e/?#$4=\"\"5!7>0)*4=\"\"5!7>&/#$+\")(\"'#&'#.\" &\"/#$+$)($'#(#'#(\"'#&'#.\" &\"/#$+')(''#(&'#(%'#($'#(#'#(\"'#&'#.\" &\"/7$2f\"\"6f7g.\" &\"/#$+,)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#/B$2k\"\"6k7l/3$;1/*$8%:m%#$\"!)(%'#($'#(#'#(\"'#&'#"), - peg$decode("%%4=\"\"5!7>/\xBE#4=\"\"5!7>/\xAF$4=\"\"5!7>/\xA0$4=\"\"5!7>/\x91$2^\"\"6^7_/\x82$4=\"\"5!7>/s$4=\"\"5!7>/d$2^\"\"6^7_/U$4=\"\"5!7>/F$4=\"\"5!7>/7$2f\"\"6f7g.\" &\"/#$++)(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#/1#;1/($8\":n\"!!)(\"'#&'#.\u0115 &%3o\"\"5$7p/\u0105#2k\"\"6k7l/\xF6$%4=\"\"5!7>/\xBE#4=\"\"5!7>/\xAF$4=\"\"5!7>/\xA0$4=\"\"5!7>/\x91$2^\"\"6^7_/\x82$4=\"\"5!7>/s$4=\"\"5!7>/d$2^\"\"6^7_/U$4=\"\"5!7>/F$4=\"\"5!7>/7$2f\"\"6f7g.\" &\"/#$++)(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#/B$2k\"\"6k7l/3$;1/*$8%:q%#$\"!)(%'#($'#(#'#(\"'#&'#"), - peg$decode("%;@.# &;>/& 8!:K! )"), - peg$decode("%;C/b#2d\"\"6d7e/S$;C.\" &\"/E$;?.\" &\"/7$4r\"\"5!7s.\" &\"/#$+%)(%'#($'#(#'#(\"'#&'#.\xB8 &%2d\"\"6d7e/N#;C/E$;?.\" &\"/7$4r\"\"5!7s.\" &\"/#$+$)($'#(#'#(\"'#&'#.w &%;C/@#;?/7$4r\"\"5!7s.\" &\"/#$+#)(#'#(\"'#&'#.J &%;C/@#;?.\" &\"/2$4r\"\"5!7s/#$+#)(#'#(\"'#&'#"), - peg$decode("%4t\"\"5!7u/@#4v\"\"5!7w.\" &\"/,$;C/#$+#)(#'#(\"'#&'#"), - peg$decode("%;A/@#;B/7$4r\"\"5!7s.\" &\"/#$+#)(#'#(\"'#&'#"), - peg$decode("%2R\"\"6R7S.) &2T\"\"6T7U/I#;D.\" &\"/;$2d\"\"6d7e/,$;D/#$+$)($'#(#'#(\"'#&'#.A &%;8/7#2d\"\"6d7e.\" &\"/#$+\")(\"'#&'#"), - peg$decode("%4x\"\"5!7y/@#4v\"\"5!7w.\" &\"/,$;C/#$+#)(#'#(\"'#&'#"), - peg$decode("%4=\"\"5!7>/\x8B#$%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4=\"\"5!7>/#$+\")(\"'#&'#0O*%$4P\"\"5!7Q0)*4P\"\"5!7Q&/2#4=\"\"5!7>/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("%;E/\x7F#$%$4P\"\"5!7Q0)*4P\"\"5!7Q&/,#;E/#$+\")(\"'#&'#0I*%$4P\"\"5!7Q0)*4P\"\"5!7Q&/,#;E/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"), - peg$decode("4z\"\"5!7{.5 &4|\"\"5!7}.) &4=\"\"5!7>"), - peg$decode("%2k\"\"6k7l/\xA7#$;H.M &%%<4~\"\"5!7\x7F=.##&&!&'#/1#1\"\"5!7\x80/#$+\")(\"'#&'#0S*;H.M &%%<4~\"\"5!7\x7F=.##&&!&'#/1#1\"\"5!7\x80/#$+\")(\"'#&'#&/7$2k\"\"6k7l/($8#:\x81#!!)(#'#(\"'#&'#"), - peg$decode("%;X/\xD3#;1/\xCA$%;\"/q#$%;O/5#;1/,$;\"/#$+#)(#'#(\"'#&'#0?*%;O/5#;1/,$;\"/#$+#)(#'#(\"'#&'#&/)$8\":\x82\"\"! )(\"'#&'#.\" &\"/d$%;O/,#;1/#$+\")(\"'#&'#.\" &\"/C$;1/:$;a/1$;1/($8':\x83'!$)(''#(&'#(%'#($'#(#'#(\"'#&'#"), - peg$decode("2\x84\"\"6\x847\x85.N &%2\x86\"\"6\x867\x87/>#4\x88\"\"5!7\x89.) &;I.# &;J/#$+\")(\"'#&'#"), - peg$decode("%4\x8A\"\"5!7\x8B/A#4\\\"\"5!7]/2$4\\\"\"5!7]/#$+#)(#'#(\"'#&'#.N &%4\\\"\"5!7]/2#4\\\"\"5!7]/#$+\")(\"'#&'#.) &4\\\"\"5!7]"), - peg$decode("%$2\x8C\"\"6\x8C7\x8D/,#0)*2\x8C\"\"6\x8C7\x8D&&&#/G#;E/>$;E/5$;E/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#"), - peg$decode("%2?\"\"6?7@/8#%<;4=.##&&!&'#/#$+\")(\"'#&'#.s &%2B\"\"6B7C/8#%<;4=.##&&!&'#/#$+\")(\"'#&'#.H &%2E\"\"6E7F/8#%<;4=.##&&!&'#/#$+\")(\"'#&'#"), - peg$decode("3\x8E\"\"5#7\x8F"), - peg$decode("3\x90\"\"5#7\x91"), - peg$decode("2b\"\"6b7c"), - peg$decode("2\x92\"\"6\x927\x93"), - peg$decode("3\x94\"\"5#7\x95"), - peg$decode("2\x96\"\"6\x967\x97"), - peg$decode("3\x98\"\"5\"7\x99"), - peg$decode("3\x9A\"\"5\"7\x9B"), - peg$decode("3\x9C\"\"5\"7\x9D"), - peg$decode("2^\"\"6^7_"), - peg$decode("2\x9E\"\"6\x9E7\x9F"), - peg$decode("3\xA0\"\"5\"7\xA1"), - peg$decode("2\xA2\"\"6\xA27\xA3"), - peg$decode("3\xA4\"\"5\"7\xA5"), - peg$decode("2^\"\"6^7_"), - peg$decode("3\xA6\"\"5#7\xA7"), - peg$decode("3\xA8\"\"5\"7\xA9"), - peg$decode("3\xAA\"\"5#7\xAB"), - peg$decode("3\xAC\"\"5\"7\xAD"), - peg$decode("2\xAE\"\"6\xAE7\xAF"), - peg$decode("2\xB0\"\"6\xB07\xB1"), - peg$decode("2\xB2\"\"6\xB27\xB3"), - peg$decode("3\xB4\"\"5#7\xB5"), - peg$decode("3\xB6\"\"5#7\xB7") - ], - - 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)) { + var peg$c0 = "in"; + var peg$c1 = "true"; + var peg$c2 = "false"; + var peg$c3 = "null"; + var peg$c4 = "0"; + var peg$c5 = "0x"; + var peg$c6 = "0X"; + var peg$c7 = "0b"; + var peg$c8 = "0B"; + var peg$c9 = "-"; + var peg$c10 = "T"; + var peg$c11 = ":"; + var peg$c12 = "."; + var peg$c13 = "Z"; + var peg$c14 = "datetime"; + var peg$c15 = "'"; + var peg$c16 = "date"; + var peg$c17 = "''"; + var peg$c18 = "\\"; + var peg$c19 = "u"; + var peg$c20 = "add"; + var peg$c21 = "and"; + var peg$c22 = ","; + var peg$c23 = "div"; + var peg$c24 = "/"; + var peg$c25 = "eq"; + var peg$c26 = "ge"; + var peg$c27 = "gt"; + var peg$c28 = "["; + var peg$c29 = "le"; + var peg$c30 = "("; + var peg$c31 = "lt"; + var peg$c32 = "mod"; + var peg$c33 = "ne"; + var peg$c34 = "not"; + var peg$c35 = "or"; + var peg$c36 = "+"; + var peg$c37 = "]"; + var peg$c38 = ")"; + var peg$c39 = "sub"; + var peg$c40 = "mul"; + + var peg$r0 = /^[ \t\r\n\f]/; + var peg$r1 = /^[$A-Z_a-z]/; + var peg$r2 = /^[$0-9A-Z_a-z]/; + var peg$r3 = /^[lL]/; + var peg$r4 = /^[1-9]/; + var peg$r5 = /^[_]/; + var peg$r6 = /^[0-9]/; + var peg$r7 = /^[01]/; + var peg$r8 = /^[0-7]/; + var peg$r9 = /^[fFdD]/; + var peg$r10 = /^[eE]/; + var peg$r11 = /^[+\-]/; + var peg$r12 = /^[pP]/; + var peg$r13 = /^[0-9A-Fa-f]/; + var peg$r14 = /^['\\\n\r]/; + var peg$r15 = /^[btnfr"'\\]/; + var peg$r16 = /^[0-3]/; + + var peg$e0 = peg$literalExpectation("IN", true); + var peg$e1 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false); + var peg$e2 = peg$classExpectation(["$", ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e3 = peg$classExpectation(["$", ["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e4 = peg$literalExpectation("true", false); + var peg$e5 = peg$literalExpectation("false", false); + var peg$e6 = peg$literalExpectation("null", false); + var peg$e7 = peg$classExpectation(["l", "L"], false, false); + var peg$e8 = peg$literalExpectation("0", false); + var peg$e9 = peg$classExpectation([["1", "9"]], false, false); + var peg$e10 = peg$classExpectation(["_"], false, false); + var peg$e11 = peg$classExpectation([["0", "9"]], false, false); + var peg$e12 = peg$literalExpectation("0x", false); + var peg$e13 = peg$literalExpectation("0X", false); + var peg$e14 = peg$literalExpectation("0b", false); + var peg$e15 = peg$literalExpectation("0B", false); + var peg$e16 = peg$classExpectation(["0", "1"], false, false); + var peg$e17 = peg$classExpectation([["0", "7"]], false, false); + var peg$e18 = peg$literalExpectation("-", false); + var peg$e19 = peg$literalExpectation("T", false); + var peg$e20 = peg$literalExpectation(":", false); + var peg$e21 = peg$literalExpectation(".", false); + var peg$e22 = peg$literalExpectation("Z", false); + var peg$e23 = peg$literalExpectation("datetime", true); + var peg$e24 = peg$literalExpectation("'", false); + var peg$e25 = peg$literalExpectation("date", true); + var peg$e26 = peg$classExpectation(["f", "F", "d", "D"], false, false); + var peg$e27 = peg$classExpectation(["e", "E"], false, false); + var peg$e28 = peg$classExpectation(["+", "-"], false, false); + var peg$e29 = peg$classExpectation(["p", "P"], false, false); + var peg$e30 = peg$classExpectation([["0", "9"], ["A", "F"], ["a", "f"]], false, false); + var peg$e31 = peg$classExpectation(["'", "\\", "\n", "\r"], false, false); + var peg$e32 = peg$anyExpectation(); + var peg$e33 = peg$literalExpectation("''", false); + var peg$e34 = peg$literalExpectation("\\", false); + var peg$e35 = peg$classExpectation(["b", "t", "n", "f", "r", "\"", "'", "\\"], false, false); + var peg$e36 = peg$classExpectation([["0", "3"]], false, false); + var peg$e37 = peg$literalExpectation("u", false); + var peg$e38 = peg$literalExpectation("add", true); + var peg$e39 = peg$literalExpectation("and", true); + var peg$e40 = peg$literalExpectation(",", false); + var peg$e41 = peg$literalExpectation("div", true); + var peg$e42 = peg$literalExpectation("/", false); + var peg$e43 = peg$literalExpectation("eq", true); + var peg$e44 = peg$literalExpectation("ge", true); + var peg$e45 = peg$literalExpectation("gt", true); + var peg$e46 = peg$literalExpectation("[", false); + var peg$e47 = peg$literalExpectation("le", true); + var peg$e48 = peg$literalExpectation("(", false); + var peg$e49 = peg$literalExpectation("lt", true); + var peg$e50 = peg$literalExpectation("mod", true); + var peg$e51 = peg$literalExpectation("ne", true); + var peg$e52 = peg$literalExpectation("not", true); + var peg$e53 = peg$literalExpectation("or", true); + var peg$e54 = peg$literalExpectation("+", false); + var peg$e55 = peg$literalExpectation("]", false); + var peg$e56 = peg$literalExpectation(")", false); + var peg$e57 = peg$literalExpectation("sub", true); + var peg$e58 = peg$literalExpectation("mul", true); + + var peg$f0 = function(args, expr) { + return { + type: 'LambdaExpression', + arguments: [args], + expression: expr + } + }; + var peg$f1 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'LogicalExpression', + operator: '||', + left: result, + right: element[1] + }; + }); + }; + var peg$f2 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'LogicalExpression', + operator: '&&', + left: result, + right: element[1] + }; + }); + }; + var peg$f3 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + let map = { 'eq': '==', 'ne': '!=' } + + return { + type: 'RelationalExpression', + operator: map[element[0][0].toLowerCase()], + left: result, + right: element[1] + }; + }); + }; + var peg$f4 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + let map = { 'le': '<=', 'ge': '>=', 'lt': '<', 'gt': '>' } + + return { + type: 'RelationalExpression', + operator: map[element[0][0].toLowerCase()], + left: result, + right: element[1] + }; + }); + }; + var peg$f5 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + return { + type: 'RelationalExpression', + operator: 'in', + left: result, + right: element[1] + }; + }); + }; + var peg$f6 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + let map = { 'add': '+', 'sub': '-' } + + return { + type: 'BinaryExpression', + operator: map[element[0][0].toLowerCase()], + left: result, + right: element[1] + }; + }); + }; + var peg$f7 = function(first, rest) { + return buildTree(first, rest, function(result, element) { + let map = { 'mul': '*', 'div': '/', 'mod': '%' } + + return { + type: 'BinaryExpression', + operator: map[element[0][0].toLowerCase()], + left: result, + right: element[1] + }; + }); + }; + var peg$f8 = function(operator, operand) { + return operand.type === 'NumberLiteral' && (operator === '-' || operator === '+') + ? + { + type: 'NumberLiteral', + value: (operator === '-' ? operator : '') + operand.value + } + : + { + type: 'UnaryExpression', + operator: operator, + argument: operand + }; + }; + var peg$f9 = function(expr) { return expr; }; + var peg$f10 = function(qual, args) { + return { + type: 'CallExpression', + object: qual, + arguments: args + }; + }; + var peg$f11 = function(qual, expr) { + return { + type: 'ArrayExpression', + array: qual, + index: expr + }; + }; + var peg$f12 = function(first, i) { return i; }; + var peg$f13 = function(first, list) { + if(list) { + return { + type: 'MemberExpression', + object: first, + property: list + } + } + return first; + }; + var peg$f14 = function(op) { + let map = { 'not': '!', '+': '+', '-': '-' } + return map[op[0].toLowerCase()]; + }; + var peg$f15 = function(first, rest) { return buildList(first, rest, 1); }; + var peg$f16 = function(args) { return args || []; }; + var peg$f17 = function(exp) { return exp; }; + var peg$f18 = function(first, last) { return { type: 'Identifier', name: first + last.join('') }; }; + var peg$f19 = function() { return { type: 'BooleanLiteral', value: true }; }; + var peg$f20 = function() { return { type: 'BooleanLiteral', value: false }; }; + var peg$f21 = function() { return { type: 'NullLiteral' }; }; + var peg$f22 = function(literal) { return literal; }; + var peg$f23 = function() { return { type: 'NumberLiteral', value: text() }; }; + var peg$f24 = function(value) { return { type: 'DateTimeLiteral', value: flattenArray(value).join('') }; }; + var peg$f25 = function(first, value, last) { return { type: 'DateTimeLiteral', value: flattenArray(value).join('') }; }; + var peg$f26 = function(value) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; }; + var peg$f27 = function(first, value, last) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; }; + var peg$f28 = function() { return { type: 'NumberLiteral', value: text() }; }; + var peg$f29 = function(chars) { return { type: 'Literal', value: chars.map(l => l[0] == undefined ? l[1] : l[0] + l[1]).join('').replace(/\\(["'\\])|'(')/g, '$1$2') } }; + var peg$f30 = function(first, rest) { return buildList(first, rest, 2)}; + var peg$f31 = function(elements) { return { type: 'ArrayLiteral', elements: elements } }; + var peg$currPos = options.peg$currPos | 0; + var peg$savedPos = peg$currPos; + var peg$posDetailsCache = [{ line: 1, column: 1 }]; + var peg$maxFailPos = peg$currPos; + var peg$maxFailExpected = options.peg$maxFailExpected || []; + var peg$silentFails = options.peg$silentFails | 0; + + var peg$result; + + if (options.startRule) { + if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } - peg$startRuleIndex = peg$startRuleIndices[options.startRule]; + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } + function offset() { + return peg$savedPos; + } + + function range() { + return { + source: peg$source, + start: peg$savedPos, + end: 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) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -517,7 +491,9 @@ function peg$parse(input, options) { } function error(message, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } @@ -543,19 +519,22 @@ function peg$parse(input, options) { } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos], p; + var details = peg$posDetailsCache[pos]; + var p; if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} } details = peg$posDetailsCache[p]; details = { - line: details.line, + line: details.line, column: details.column }; @@ -571,26 +550,33 @@ function peg$parse(input, options) { } peg$posDetailsCache[pos] = details; + return details; } } - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos), - endPosDetails = peg$computePosDetails(endPos); + function peg$computeLocation(startPos, endPos, offset) { + var startPosDetails = peg$computePosDetails(startPos); + var endPosDetails = peg$computePosDetails(endPos); - return { + var res = { + source: peg$source, start: { offset: startPos, - line: startPosDetails.line, + line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, - line: endPosDetails.line, + line: endPosDetails.line, column: endPosDetails.column } }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; } function peg$fail(expected) { @@ -617,326 +603,4095 @@ function peg$parse(input, options) { ); } - 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; + function peg$parseStart() { + var s0; - case 14: - ends.push(end); - ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); + s0 = peg$parseLogicalOrExpression(); - 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; + return s0; + } - case 15: - ends.push(end); - ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); + function peg$parseLambdaExpression() { + var s0, s1, s2, s3, s4, s5; - 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]; - } + s0 = peg$currPos; + s1 = peg$parseIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseCOLON(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseLogicalOrExpression(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f0(s1, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - break; + return s0; + } - case 16: - if (stack[stack.length - 1] !== peg$FAILED) { - ends.push(end); - ips.push(ip); + function peg$parseLogicalOrExpression() { + var s0, s1, s2, s3, s4, s5, s6; - end = ip + 2 + bc[ip + 1]; - ip += 2; - } else { - ip += 2 + bc[ip + 1]; - } + s0 = peg$currPos; + s1 = peg$parseLogicalAndExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOROR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseLogicalAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseOROR(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseLogicalAndExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f1(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - break; + return s0; + } - case 17: - ends.push(end); - ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]); + function peg$parseLogicalAndExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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]; - } + s0 = peg$currPos; + s1 = peg$parseEqualityExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseANDAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseEqualityExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseANDAND(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseEqualityExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f2(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - break; + return s0; + } - case 18: - ends.push(end); - ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); + function peg$parseEqualityExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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]; - } + s0 = peg$currPos; + s1 = peg$parseRelationalExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseRelationalExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseNOTEQUAL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseRelationalExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f3(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - break; + return s0; + } - case 19: - ends.push(end); - ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]); + function peg$parseRelationalExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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; + s0 = peg$currPos; + s1 = peg$parseInExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseLE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; } else { - end = ip + 4 + bc[ip + 2] + bc[ip + 3]; - ip += 4 + bc[ip + 2]; + peg$currPos = s4; + s4 = peg$FAILED; } - - 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; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseInExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseLE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGE(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseLT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; } else { - end = ip + 4 + bc[ip + 2] + bc[ip + 3]; - ip += 4 + bc[ip + 2]; + peg$currPos = s4; + s4 = peg$FAILED; } - - 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]]); + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseGT(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } } - ip += 2; - break; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseInExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f4(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - case 24: - peg$savedPos = stack[stack.length - 1 - bc[ip + 1]]; - ip += 2; - break; + return s0; + } - case 25: - peg$savedPos = peg$currPos; - ip++; - break; + function peg$parseInExpression() { + var s0, s1, s2, s3, s4, s5, s6; - 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]]; - } + s0 = peg$currPos; + s1 = peg$parseAdditiveExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = input.substr(peg$currPos, 2); + if (s5.toLowerCase() === peg$c0) { + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseAdditiveExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = input.substr(peg$currPos, 2); + if (s5.toLowerCase() === peg$c0) { + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseAdditiveExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f5(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - stack.splice( - stack.length - bc[ip + 2], - bc[ip + 2], - peg$consts[bc[ip + 1]].apply(null, params) - ); + return s0; + } - ip += 4 + bc[ip + 3]; - break; + function peg$parseAdditiveExpression() { + var s0, s1, s2, s3, s4, s5, s6; - case 27: - stack.push(peg$parseRule(bc[ip + 1])); - ip += 2; - break; + s0 = peg$currPos; + s1 = peg$parseMultiplicativeExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseADD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseSUB(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseMultiplicativeExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseADD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseSUB(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseMultiplicativeExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + peg$savedPos = s0; + s0 = peg$f6(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - case 28: - peg$silentFails++; - ip++; - break; + return s0; + } - case 29: - peg$silentFails--; - ip++; - break; + function peg$parseMultiplicativeExpression() { + var s0, s1, s2, s3, s4, s5, s6; - default: - throw new Error("Invalid opcode: " + bc[ip] + "."); + s0 = peg$currPos; + s1 = peg$parseUnaryExpression(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseMUL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseDIV(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseMOD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } } } - - if (ends.length > 0) { - end = ends.pop(); - ip = ips.pop(); + if (s4 !== peg$FAILED) { + s5 = peg$parseUnaryExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } else { - break; + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + s5 = peg$parseMUL(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseDIV(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parseMOD(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseUnaryExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } + peg$savedPos = s0; + s0 = peg$f7(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return stack[0]; + return s0; } + function peg$parseUnaryExpression() { + var s0, s1, s2; - function buildList(first, rest, index) { - var result = new Array(rest.length), i; - - for (i = 0; i < rest.length; i++) { - result[i] = rest[i][index]; + s0 = peg$currPos; + s1 = peg$parsePrefixOp(); + if (s1 !== peg$FAILED) { + s2 = peg$parsePrimary(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f8(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - - return [first].concat(result); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$parsePrimary(); } - function buildTree(first, rest, builder) { - var result = first, i; + return s0; + } - for (i = 0; i < rest.length; i++) { - result = builder(result, rest[i]); - } + function peg$parsePrimary() { + var s0; - return result; - } - - function flattenArray(value) { - return Array.isArray(value) ? [].concat.apply([], value.map(function(v) { return flattenArray(v) })) : value + s0 = peg$parseParExpression(); + if (s0 === peg$FAILED) { + s0 = peg$parseDateTimeLiteral(); + if (s0 === peg$FAILED) { + s0 = peg$parseDateLiteral(); + if (s0 === peg$FAILED) { + s0 = peg$parseQualifiedIdentifier(); + if (s0 === peg$FAILED) { + s0 = peg$parseLiteral(); + } + } + } } + return s0; + } - peg$result = peg$parseRule(peg$startRuleIndex); + function peg$parseParExpression() { + var s0, s1, s2, s3, s4, s5; - 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()); + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseLogicalOrExpression(); + if (s3 !== peg$FAILED) { + s4 = peg$parseRPAR(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f9(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - 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 s0; } -} -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse + function peg$parseQualifiedIdentifier() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$parseArguments(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f10(s2, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$parseLBRK(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s5 = peg$parseLogicalOrExpression(); + if (s5 !== peg$FAILED) { + s6 = peg$parseRBRK(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f11(s2, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseReservedWord(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = undefined; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = peg$parseDOT(); + if (s4 !== peg$FAILED) { + s5 = peg$parseQualifiedIdentifier(); + if (s5 !== peg$FAILED) { + peg$savedPos = s3; + s3 = peg$f12(s2, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + peg$savedPos = s0; + s0 = peg$f13(s2, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + + return s0; + } + + function peg$parsePrefixOp() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = peg$parseNOT(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parsePLUS(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + s2 = peg$parseMINUS(); + if (s2 !== peg$FAILED) { + s3 = peg$parse__(); + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f14(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseArguments() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$currPos; + s4 = peg$parseLambdaExpression(); + if (s4 === peg$FAILED) { + s4 = peg$parseLogicalOrExpression(); + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$currPos; + s8 = peg$parseCOMMA(); + if (s8 !== peg$FAILED) { + s9 = peg$parse__(); + s8 = [s8, s9]; + s7 = s8; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + s8 = peg$parseLambdaExpression(); + if (s8 === peg$FAILED) { + s8 = peg$parseLogicalOrExpression(); + } + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$currPos; + s8 = peg$parseCOMMA(); + if (s8 !== peg$FAILED) { + s9 = peg$parse__(); + s8 = [s8, s9]; + s7 = s8; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + s8 = peg$parseLambdaExpression(); + if (s8 === peg$FAILED) { + s8 = peg$parseLogicalOrExpression(); + } + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } + peg$savedPos = s3; + s3 = peg$f15(s4, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$parseRPAR(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f16(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDim() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseLBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseRBRK(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDimExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseLBRK(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$parseLogicalOrExpression(); + if (s3 !== peg$FAILED) { + s4 = peg$parseRBRK(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f17(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parse__() { + var s0, s1, s2; + + s0 = []; + s1 = []; + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s1 = peg$FAILED; + } + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = []; + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s1 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseIdentifier() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseLetter(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseLetterOrDigit(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseLetterOrDigit(); + } + s3 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f18(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseLetter() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r1.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + + return s0; + } + + function peg$parseLetterOrDigit() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r2.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + + return s0; + } + + function peg$parseLiteral() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseFloatLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseIntegerLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseStringLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$parseArrayLiteral(); + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c1) { + s2 = peg$c1; + peg$currPos += 4; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f19(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c2) { + s2 = peg$c2; + peg$currPos += 5; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f20(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c3) { + s2 = peg$c3; + peg$currPos += 4; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = undefined; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s1 = peg$f21(); + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + } + } + } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f22(s1); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseIntegerLiteral() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parseHexNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseBinaryNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseOctalNumeral(); + if (s1 === peg$FAILED) { + s1 = peg$parseDecimalNumeral(); + } + } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r3.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + peg$savedPos = s0; + s0 = peg$f23(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDecimalNumeral() { + var s0, s1, s2, s3, s4, s5; + + if (input.charCodeAt(peg$currPos) === 48) { + s0 = peg$c4; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r4.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseHexNumeral() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c5) { + s1 = peg$c5; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c6) { + s1 = peg$c6; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigits(); + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseBinaryNumeral() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c7) { + s1 = peg$c7; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c8) { + s1 = peg$c8; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r7.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r5.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r5.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r5.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r5.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s6 = input.charAt(peg$currPos); + if (peg$r7.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOctalNumeral() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 48) { + s1 = peg$c4; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r8.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDateTimeLiteral() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28; + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = input.charAt(peg$currPos); + if (peg$r6.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r6.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s3 !== peg$FAILED) { + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s6 = peg$c9; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s6 !== peg$FAILED) { + s7 = input.charAt(peg$currPos); + if (peg$r6.test(s7)) { + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s7 !== peg$FAILED) { + s8 = input.charAt(peg$currPos); + if (peg$r6.test(s8)) { + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s8 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s9 = peg$c9; + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s9 !== peg$FAILED) { + s10 = input.charAt(peg$currPos); + if (peg$r6.test(s10)) { + peg$currPos++; + } else { + s10 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s10 !== peg$FAILED) { + s11 = input.charAt(peg$currPos); + if (peg$r6.test(s11)) { + peg$currPos++; + } else { + s11 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s11 !== peg$FAILED) { + s12 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 84) { + s13 = peg$c10; + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + if (s13 !== peg$FAILED) { + s14 = input.charAt(peg$currPos); + if (peg$r6.test(s14)) { + peg$currPos++; + } else { + s14 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s14 !== peg$FAILED) { + s15 = input.charAt(peg$currPos); + if (peg$r6.test(s15)) { + peg$currPos++; + } else { + s15 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s15 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s16 = peg$c11; + peg$currPos++; + } else { + s16 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s16 !== peg$FAILED) { + s17 = input.charAt(peg$currPos); + if (peg$r6.test(s17)) { + peg$currPos++; + } else { + s17 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s17 !== peg$FAILED) { + s18 = input.charAt(peg$currPos); + if (peg$r6.test(s18)) { + peg$currPos++; + } else { + s18 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s18 !== peg$FAILED) { + s19 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s20 = peg$c11; + peg$currPos++; + } else { + s20 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s20 !== peg$FAILED) { + s21 = input.charAt(peg$currPos); + if (peg$r6.test(s21)) { + peg$currPos++; + } else { + s21 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s21 !== peg$FAILED) { + s22 = input.charAt(peg$currPos); + if (peg$r6.test(s22)) { + peg$currPos++; + } else { + s22 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s22 !== peg$FAILED) { + s23 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s24 = peg$c12; + peg$currPos++; + } else { + s24 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s24 !== peg$FAILED) { + s25 = []; + s26 = input.charAt(peg$currPos); + if (peg$r6.test(s26)) { + peg$currPos++; + } else { + s26 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + while (s26 !== peg$FAILED) { + s25.push(s26); + s26 = input.charAt(peg$currPos); + if (peg$r6.test(s26)) { + peg$currPos++; + } else { + s26 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + } + s24 = [s24, s25]; + s23 = s24; + } else { + peg$currPos = s23; + s23 = peg$FAILED; + } + if (s23 === peg$FAILED) { + s23 = null; + } + s20 = [s20, s21, s22, s23]; + s19 = s20; + } else { + peg$currPos = s19; + s19 = peg$FAILED; + } + } else { + peg$currPos = s19; + s19 = peg$FAILED; + } + } else { + peg$currPos = s19; + s19 = peg$FAILED; + } + if (s19 === peg$FAILED) { + s19 = null; + } + s13 = [s13, s14, s15, s16, s17, s18, s19]; + s12 = s13; + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + } else { + peg$currPos = s12; + s12 = peg$FAILED; + } + if (s12 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 90) { + s13 = peg$c13; + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s13 === peg$FAILED) { + s13 = null; + } + s2 = [s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f24(s1); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 8); + if (s1.toLowerCase() === peg$c14) { + peg$currPos += 8; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e23); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c15; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s6 = input.charAt(peg$currPos); + if (peg$r6.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s6 !== peg$FAILED) { + s7 = input.charAt(peg$currPos); + if (peg$r6.test(s7)) { + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s7 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s8 = peg$c9; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s8 !== peg$FAILED) { + s9 = input.charAt(peg$currPos); + if (peg$r6.test(s9)) { + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s9 !== peg$FAILED) { + s10 = input.charAt(peg$currPos); + if (peg$r6.test(s10)) { + peg$currPos++; + } else { + s10 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s10 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s11 = peg$c9; + peg$currPos++; + } else { + s11 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s11 !== peg$FAILED) { + s12 = input.charAt(peg$currPos); + if (peg$r6.test(s12)) { + peg$currPos++; + } else { + s12 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s12 !== peg$FAILED) { + s13 = input.charAt(peg$currPos); + if (peg$r6.test(s13)) { + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s13 !== peg$FAILED) { + s14 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 84) { + s15 = peg$c10; + peg$currPos++; + } else { + s15 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + if (s15 !== peg$FAILED) { + s16 = input.charAt(peg$currPos); + if (peg$r6.test(s16)) { + peg$currPos++; + } else { + s16 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s16 !== peg$FAILED) { + s17 = input.charAt(peg$currPos); + if (peg$r6.test(s17)) { + peg$currPos++; + } else { + s17 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s17 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s18 = peg$c11; + peg$currPos++; + } else { + s18 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s18 !== peg$FAILED) { + s19 = input.charAt(peg$currPos); + if (peg$r6.test(s19)) { + peg$currPos++; + } else { + s19 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s19 !== peg$FAILED) { + s20 = input.charAt(peg$currPos); + if (peg$r6.test(s20)) { + peg$currPos++; + } else { + s20 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s20 !== peg$FAILED) { + s21 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s22 = peg$c11; + peg$currPos++; + } else { + s22 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s22 !== peg$FAILED) { + s23 = input.charAt(peg$currPos); + if (peg$r6.test(s23)) { + peg$currPos++; + } else { + s23 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s23 !== peg$FAILED) { + s24 = input.charAt(peg$currPos); + if (peg$r6.test(s24)) { + peg$currPos++; + } else { + s24 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s24 !== peg$FAILED) { + s25 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s26 = peg$c12; + peg$currPos++; + } else { + s26 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s26 !== peg$FAILED) { + s27 = []; + s28 = input.charAt(peg$currPos); + if (peg$r6.test(s28)) { + peg$currPos++; + } else { + s28 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + while (s28 !== peg$FAILED) { + s27.push(s28); + s28 = input.charAt(peg$currPos); + if (peg$r6.test(s28)) { + peg$currPos++; + } else { + s28 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + } + s26 = [s26, s27]; + s25 = s26; + } else { + peg$currPos = s25; + s25 = peg$FAILED; + } + if (s25 === peg$FAILED) { + s25 = null; + } + s22 = [s22, s23, s24, s25]; + s21 = s22; + } else { + peg$currPos = s21; + s21 = peg$FAILED; + } + } else { + peg$currPos = s21; + s21 = peg$FAILED; + } + } else { + peg$currPos = s21; + s21 = peg$FAILED; + } + if (s21 === peg$FAILED) { + s21 = null; + } + s15 = [s15, s16, s17, s18, s19, s20, s21]; + s14 = s15; + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + } else { + peg$currPos = s14; + s14 = peg$FAILED; + } + if (s14 === peg$FAILED) { + s14 = null; + } + if (input.charCodeAt(peg$currPos) === 90) { + s15 = peg$c13; + peg$currPos++; + } else { + s15 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s15 === peg$FAILED) { + s15 = null; + } + s4 = [s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15]; + 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; + } + } 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; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s4 = peg$c15; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f25(s1, s3, s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseDateLiteral() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14; + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = input.charAt(peg$currPos); + if (peg$r6.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r6.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s3 !== peg$FAILED) { + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s6 = peg$c9; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s6 !== peg$FAILED) { + s7 = input.charAt(peg$currPos); + if (peg$r6.test(s7)) { + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s7 !== peg$FAILED) { + s8 = input.charAt(peg$currPos); + if (peg$r6.test(s8)) { + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s8 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s9 = peg$c9; + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s9 !== peg$FAILED) { + s10 = input.charAt(peg$currPos); + if (peg$r6.test(s10)) { + peg$currPos++; + } else { + s10 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s10 !== peg$FAILED) { + s11 = input.charAt(peg$currPos); + if (peg$r6.test(s11)) { + peg$currPos++; + } else { + s11 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s11 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 90) { + s12 = peg$c13; + peg$currPos++; + } else { + s12 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s12 === peg$FAILED) { + s12 = null; + } + s2 = [s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f26(s1); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 4); + if (s1.toLowerCase() === peg$c16) { + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e25); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c15; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s4 !== peg$FAILED) { + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s6 = input.charAt(peg$currPos); + if (peg$r6.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s6 !== peg$FAILED) { + s7 = input.charAt(peg$currPos); + if (peg$r6.test(s7)) { + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s7 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s8 = peg$c9; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s8 !== peg$FAILED) { + s9 = input.charAt(peg$currPos); + if (peg$r6.test(s9)) { + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s9 !== peg$FAILED) { + s10 = input.charAt(peg$currPos); + if (peg$r6.test(s10)) { + peg$currPos++; + } else { + s10 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s10 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s11 = peg$c9; + peg$currPos++; + } else { + s11 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s11 !== peg$FAILED) { + s12 = input.charAt(peg$currPos); + if (peg$r6.test(s12)) { + peg$currPos++; + } else { + s12 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s12 !== peg$FAILED) { + s13 = input.charAt(peg$currPos); + if (peg$r6.test(s13)) { + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s13 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 90) { + s14 = peg$c13; + peg$currPos++; + } else { + s14 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s14 === peg$FAILED) { + s14 = null; + } + s4 = [s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14]; + 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; + } + } 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; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s4 = peg$c15; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f27(s1, s3, s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseFloatLiteral() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseHexFloat(); + if (s1 === peg$FAILED) { + s1 = peg$parseDecimalFloat(); + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f28(); + } + s0 = s1; + + return s0; + } + + function peg$parseDecimalFloat() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c12; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseDigits(); + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$parseExponent(); + if (s4 === peg$FAILED) { + s4 = null; + } + s5 = input.charAt(peg$currPos); + if (peg$r9.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + s1 = [s1, s2, s3, s4, s5]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c12; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseDigits(); + if (s2 !== peg$FAILED) { + s3 = peg$parseExponent(); + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = input.charAt(peg$currPos); + if (peg$r9.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + s2 = peg$parseExponent(); + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r9.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseDigits(); + if (s1 !== peg$FAILED) { + s2 = peg$parseExponent(); + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = input.charAt(peg$currPos); + if (peg$r9.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + + return s0; + } + + function peg$parseExponent() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r10.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r11.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parseDigits(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexFloat() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseHexSignificand(); + if (s1 !== peg$FAILED) { + s2 = peg$parseBinaryExponent(); + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r9.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexSignificand() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c5) { + s1 = peg$c5; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c6) { + s1 = peg$c6; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigits(); + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c12; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseHexDigits(); + if (s4 !== peg$FAILED) { + s1 = [s1, s2, s3, s4]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseHexNumeral(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c12; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseBinaryExponent() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r12.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r11.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parseDigits(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDigits() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r6.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = input.charAt(peg$currPos); + if (peg$r6.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexDigits() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseHexDigit(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = input.charAt(peg$currPos); + if (peg$r5.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + } + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseHexDigit() { + var s0; + + s0 = input.charAt(peg$currPos); + if (peg$r13.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e30); } + } + + return s0; + } + + function peg$parseStringLiteral() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c15; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r14.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e32); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseEscape(); + if (s3 === peg$FAILED) { + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + s5 = input.charAt(peg$currPos); + if (peg$r14.test(s5)) { + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = undefined; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e32); } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c15; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f29(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseArrayLiteral() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseLPAR(); + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + s3 = peg$currPos; + s4 = peg$parseLogicalOrExpression(); + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseLogicalOrExpression(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$parseCOMMA(); + if (s7 !== peg$FAILED) { + s8 = peg$parse__(); + s9 = peg$parseLogicalOrExpression(); + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + } + peg$savedPos = s3; + s3 = peg$f30(s4, s5); + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$currPos; + s5 = peg$parseCOMMA(); + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + if (s4 === peg$FAILED) { + s4 = null; + } + s5 = peg$parse__(); + s6 = peg$parseRPAR(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + peg$savedPos = s0; + s0 = peg$f31(s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseEscape() { + var s0, s1, s2; + + if (input.substr(peg$currPos, 2) === peg$c17) { + s0 = peg$c17; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e33); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c18; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e34); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r15.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e35); } + } + if (s2 === peg$FAILED) { + s2 = peg$parseOctalEscape(); + if (s2 === peg$FAILED) { + s2 = peg$parseUnicodeEscape(); + } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseOctalEscape() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r16.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e36); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r8.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s2 !== peg$FAILED) { + s3 = input.charAt(peg$currPos); + if (peg$r8.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.charAt(peg$currPos); + if (peg$r8.test(s1)) { + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s1 !== peg$FAILED) { + s2 = input.charAt(peg$currPos); + if (peg$r8.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = input.charAt(peg$currPos); + if (peg$r8.test(s0)) { + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + } + } + + return s0; + } + + function peg$parseUnicodeEscape() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = []; + if (input.charCodeAt(peg$currPos) === 117) { + s2 = peg$c19; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (input.charCodeAt(peg$currPos) === 117) { + s2 = peg$c19; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHexDigit(); + if (s2 !== peg$FAILED) { + s3 = peg$parseHexDigit(); + if (s3 !== peg$FAILED) { + s4 = peg$parseHexDigit(); + if (s4 !== peg$FAILED) { + s5 = peg$parseHexDigit(); + if (s5 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseReservedWord() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c1) { + s1 = peg$c1; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } 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; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c2) { + s1 = peg$c2; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } 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; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c3) { + s1 = peg$c3; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLetterOrDigit(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = undefined; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + + return s0; + } + + function peg$parseADD() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c20) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e38); } + } + + return s0; + } + + function peg$parseANDAND() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c21) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e39); } + } + + return s0; + } + + function peg$parseCOLON() { + var s0; + + if (input.charCodeAt(peg$currPos) === 58) { + s0 = peg$c11; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + + return s0; + } + + function peg$parseCOMMA() { + var s0; + + if (input.charCodeAt(peg$currPos) === 44) { + s0 = peg$c22; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e40); } + } + + return s0; + } + + function peg$parseDIV() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c23) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e41); } + } + + return s0; + } + + function peg$parseDOT() { + var s0; + + if (input.charCodeAt(peg$currPos) === 47) { + s0 = peg$c24; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e42); } + } + + return s0; + } + + function peg$parseEQUAL() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c25) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e43); } + } + + return s0; + } + + function peg$parseGE() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c26) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e44); } + } + + return s0; + } + + function peg$parseGT() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c27) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e45); } + } + + return s0; + } + + function peg$parseHYPHEN() { + var s0; + + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c9; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + + return s0; + } + + function peg$parseLBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 91) { + s0 = peg$c28; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e46); } + } + + return s0; + } + + function peg$parseLE() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c29) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e47); } + } + + return s0; + } + + function peg$parseLPAR() { + var s0; + + if (input.charCodeAt(peg$currPos) === 40) { + s0 = peg$c30; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e48); } + } + + return s0; + } + + function peg$parseLT() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c31) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e49); } + } + + return s0; + } + + function peg$parseMINUS() { + var s0; + + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c9; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + + return s0; + } + + function peg$parseMOD() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c32) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e50); } + } + + return s0; + } + + function peg$parseNOTEQUAL() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c33) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e51); } + } + + return s0; + } + + function peg$parseNOT() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c34) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e52); } + } + + return s0; + } + + function peg$parseOROR() { + var s0; + + s0 = input.substr(peg$currPos, 2); + if (s0.toLowerCase() === peg$c35) { + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e53); } + } + + return s0; + } + + function peg$parsePLUS() { + var s0; + + if (input.charCodeAt(peg$currPos) === 43) { + s0 = peg$c36; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e54); } + } + + return s0; + } + + function peg$parseRBRK() { + var s0; + + if (input.charCodeAt(peg$currPos) === 93) { + s0 = peg$c37; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e55); } + } + + return s0; + } + + function peg$parseRPAR() { + var s0; + + if (input.charCodeAt(peg$currPos) === 41) { + s0 = peg$c38; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e56); } + } + + return s0; + } + + function peg$parseSUB() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c39) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e57); } + } + + return s0; + } + + function peg$parseMUL() { + var s0; + + s0 = input.substr(peg$currPos, 3); + if (s0.toLowerCase() === peg$c40) { + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e58); } + } + + return s0; + } + + + function buildList(first, rest, index) { + var result = new Array(rest.length), i; + + for (i = 0; i < rest.length; i++) { + result[i] = rest[i][index]; + } + + return [first].concat(result); + } + + function buildTree(first, rest, builder) { + var result = first, i; + + for (i = 0; i < rest.length; i++) { + result = builder(result, rest[i]); + } + + return result; + } + + function flattenArray(value) { + return Array.isArray(value) ? [].concat.apply([], value.map(function(v) { return flattenArray(v) })) : value + } + + peg$result = peg$startRuleFunction(); + + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos + }); + } + 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) + ); + } +} + +const peg$allowedStartRules = [ + "Start" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse }; diff --git a/src/linq/peg/parser/parser.ts b/src/linq/peg/parser/parser.ts index 9418f08..8b7f9aa 100644 --- a/src/linq/peg/parser/parser.ts +++ b/src/linq/peg/parser/parser.ts @@ -14,10 +14,8 @@ import { ITemplateLiteralExpression, TemplateLiteralExpression } from '../expres import { IObjectExpression, ObjectExpression, IObjectProperty } from '../expression/objectexpression' import { ILambdaExpression, LambdaExpression } from '../expression/lambdaexpression' -// eslint-disable-next-line @typescript-eslint/no-var-requires -const ODataParser = require('./odata-parser') -// eslint-disable-next-line @typescript-eslint/no-var-requires -const JavascriptParser = require('./javascript-parser') +import * as ODataParser from './odata-parser' +import * as JavascriptParser from './javascript-parser' type ReturnExpression = { type: 'odata' | 'javascript'