UNPKG

firebase-bolt

Version:

Firebase Bolt Security and Modeling Language Compiler

1,584 lines (1,498 loc) 158 kB
module.exports = (function() { /* * Generated by PEG.js 0.8.0. * * http://pegjs.majda.cz/ */ function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function SyntaxError(message, expected, found, offset, line, column) { this.message = message; this.expected = expected; this.found = found; this.offset = offset; this.line = line; this.column = column; this.name = "SyntaxError"; } peg$subclass(SyntaxError, Error); function parse(input) { var options = arguments.length > 1 ? arguments[1] : {}, peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = peg$FAILED, peg$c1 = function() { if (logger.hasErrors()) { throw(new Error(logger.errorSummary())); } return symbols; }, peg$c2 = [], peg$c3 = { type: "other", description: "function definition" }, peg$c4 = null, peg$c5 = function(func, body) { if (func.name === null) { error("Missing function name."); return; } if (func.params === null) { error("Function " + func.name + " missing parameters."); return; } if (body === null) { error("Function " + func.name + " missing or invalid function body."); return; } symbols.registerFunction(ensureLowerCase(func.name, "Function names"), func.params, body); }, peg$c6 = "function", peg$c7 = { type: "literal", value: "function", description: "\"function\"" }, peg$c8 = function(name, params) { return {name: name, params: params}; }, peg$c9 = function(name, params) {return {name: name, params: params}; }, peg$c10 = { type: "other", description: "path statement" }, peg$c11 = "is", peg$c12 = { type: "literal", value: "is", description: "\"is\"" }, peg$c13 = function(id) { return id; }, peg$c14 = "{", peg$c15 = { type: "literal", value: "{", description: "\"{\"" }, peg$c16 = "}", peg$c17 = { type: "literal", value: "}", description: "\"}\"" }, peg$c18 = function(all) { return all; }, peg$c19 = ";", peg$c20 = { type: "literal", value: ";", description: "\";\"" }, peg$c21 = function() { return {}; }, peg$c22 = function(path, isType, methods) { if (path === null) { return; } if (methods === null) { error("Missing body of path statement."); return; } symbols.registerPath(currentPath, isType, methods); currentPath.pop(path); }, peg$c23 = "path", peg$c24 = { type: "literal", value: "path", description: "\"path\"" }, peg$c25 = function(path) { if (path === null) { error("Missing Path Template in path statement."); return path; } currentPath.push(path); return path; }, peg$c26 = function(path) { currentPath.push(path); return path; }, peg$c27 = { type: "other", description: "path template" }, peg$c28 = "/", peg$c29 = { type: "literal", value: "/", description: "\"/\"" }, peg$c30 = function(part) { return part; }, peg$c31 = function(parts) { var hasError = false; if (parts.length === 1 && parts[0] === null) { parts = []; } parts = parts.map(function(part) { if (part === null) { hasError = true; return ''; } return part; }); if (hasError) { error((parts[parts.length - 1] === '' ? "Paths may not end in a slash (/) character" : "Paths may not contain an empty part") + ": /" + parts.map(function(part) { return part.label; }).join('/')); } return new ast.PathTemplate(parts); }, peg$c32 = "=", peg$c33 = { type: "literal", value: "=", description: "\"=\"" }, peg$c34 = "*", peg$c35 = { type: "literal", value: "*", description: "\"*\"" }, peg$c36 = function(id) { return new ast.PathPart(id, id); }, peg$c37 = /^[^ \/;]/, peg$c38 = { type: "class", value: "[^ \\/;]", description: "[^ \\/;]" }, peg$c39 = function(chars) { var result = chars.join(''); if (chars[0] === '$') { warn("Use of " + result + " to capture a path segment is deprecated; " + "use {" + result + "} or {" + result.slice(1) + "}, instead."); } return new ast.PathPart(result); }, peg$c40 = function(all) { var result = {}; for (var i = 0; i < all.length; i++) { var method = all[i]; // Skip embedded path statements. if (method === undefined) { continue; } if (typeof method == 'string') { error("Invalid path or method: '" + method + "'."); continue; } if (method.name in result) { error("Duplicate method name: " + method.name); } result[method.name] = ast.method(method.params, method.body); } return result; }, peg$c41 = { type: "other", description: "type statement" }, peg$c42 = "type", peg$c43 = { type: "literal", value: "type", description: "\"type\"" }, peg$c44 = "<", peg$c45 = { type: "literal", value: "<", description: "\"<\"" }, peg$c46 = ">", peg$c47 = { type: "literal", value: ">", description: "\">\"" }, peg$c48 = function(list) { return ensureUpperCase(list, "Type names"); }, peg$c49 = "extends", peg$c50 = { type: "literal", value: "extends", description: "\"extends\"" }, peg$c51 = function(type) { return type; }, peg$c52 = function() { return {properties: {}, methods: {}}; }, peg$c53 = function(type, params, ext, body) { if (params === null) { params = []; } if (type === null) { error("Missing type name."); return; } if (body === null) { error("Missing or invalid type statement body."); return; } symbols.registerSchema(ensureUpperCase(type, "Type names"), ext, body.properties, body.methods, params); }, peg$c54 = function(all) { var result = { properties: {}, methods: {} }; function addPart(part) { // TODO: Make sure methods and properties don't shadow each other. if (typeof part === 'string') { error("Invalid property or method: '" + part + "'."); return; } if ('type' in part) { if (result.properties[part.name]) { error("Duplicate property name: " + part.name); } result.properties[part.name] = part.type; } else { if (result.methods[part.name]) { error("Duplicate method name: " + part.name); } result.methods[part.name] = ast.method(part.params, part.body); } } for (var i = 0; i < all.length; i++) { addPart(all[i]); } return result; }, peg$c55 = ":", peg$c56 = { type: "literal", value: ":", description: "\":\"" }, peg$c57 = function(name, type) { return { name: name, type: type }; }, peg$c58 = ",", peg$c59 = { type: "literal", value: ",", description: "\",\"" }, peg$c60 = function(sep) { return sep; }, peg$c61 = { type: "other", description: "method" }, peg$c62 = function(name, params, body, sep) { if (sep !== null) { warn("Extra separator (" + sep + ") not needed."); } return { name: ensureLowerCase(name, "Method names"), params: params, body: body }; }, peg$c63 = "return", peg$c64 = { type: "literal", value: "return", description: "\"return\"" }, peg$c65 = function(exp) { return exp; }, peg$c66 = function(exp) { warn("Use of fn(x) = exp; format is deprecated; use fn(x) { exp }, instead.") return exp; }, peg$c67 = "(", peg$c68 = { type: "literal", value: "(", description: "\"(\"" }, peg$c69 = ")", peg$c70 = { type: "literal", value: ")", description: "\")\"" }, peg$c71 = function(list) { return ensureLowerCase(list, "Function arguments"); }, peg$c72 = function(head, tail) { if (!head) { return []; } tail.unshift(head); return tail; }, peg$c73 = "|", peg$c74 = { type: "literal", value: "|", description: "\"|\"" }, peg$c75 = function(head, tail) { if (tail.length == 0) { return head; } tail.unshift(head); return ast.unionType(tail); }, peg$c76 = "[]", peg$c77 = { type: "literal", value: "[]", description: "\"[]\"" }, peg$c78 = function() {return {isMap: true}; }, peg$c79 = function(types) {return {types: types};}, peg$c80 = function(type, opt) { type = ensureUpperCase(type, "Type names"); if (!opt) { return ast.typeType(type); } if (opt.isMap) { return ast.genericType('Map', [ast.typeType('String'), ast.typeType(type)]); } return ast.genericType(type, opt.types); }, peg$c81 = function(head, tail) { var result = [head]; util.extendArray(result, tail); return result; }, peg$c82 = void 0, peg$c83 = function(name) { return ast.variable(name); }, peg$c84 = function(expression) { return expression; }, peg$c85 = "[", peg$c86 = { type: "literal", value: "[", description: "\"[\"" }, peg$c87 = "]", peg$c88 = { type: "literal", value: "]", description: "\"]\"" }, peg$c89 = function(name) { return name; }, peg$c90 = ".", peg$c91 = { type: "literal", value: ".", description: "\".\"" }, peg$c92 = function(base, accessors) { var result = base; for (var i = 0; i < accessors.length; i++) { var exp = typeof accessors[i] == 'string' ? ast.string(accessors[i]) : accessors[i]; result = ast.reference(result, exp); } return result; }, peg$c93 = function(ref, args) { return ast.call(ref, args); }, peg$c94 = function(args) { return args }, peg$c95 = function(name) { return name }, peg$c96 = function(base, argumentsOrAccessors) { var result = base; for (var i = 0; i < argumentsOrAccessors.length; i++) { var part = argumentsOrAccessors[i]; if (typeof part == 'string') { result = ast.reference(result, ast.string(part)); } else if (util.isType(part, 'array')) { result = ast.call(result, part); } else { result = ast.reference(result, part); } } return result; }, peg$c97 = function(args) { return args !== null ? args : []; }, peg$c98 = function(head, tail) { tail.unshift(head); return tail; }, peg$c99 = function(op, expression) { if (op == "noop") { return expression; } return ast.op(op, [expression]); }, peg$c100 = "+", peg$c101 = { type: "literal", value: "+", description: "\"+\"" }, peg$c102 = function() { return "noop"; }, peg$c103 = "-", peg$c104 = { type: "literal", value: "-", description: "\"-\"" }, peg$c105 = function() { return "neg"; }, peg$c106 = "!", peg$c107 = { type: "literal", value: "!", description: "\"!\"" }, peg$c108 = function(op, exp) { return {op: op, exp: exp}; }, peg$c109 = function(head, tail) { return leftAssociative(head, tail); }, peg$c110 = "%", peg$c111 = { type: "literal", value: "%", description: "\"%\"" }, peg$c112 = "<=", peg$c113 = { type: "literal", value: "<=", description: "\"<=\"" }, peg$c114 = ">=", peg$c115 = { type: "literal", value: ">=", description: "\">=\"" }, peg$c116 = "===", peg$c117 = { type: "literal", value: "===", description: "\"===\"" }, peg$c118 = "==", peg$c119 = { type: "literal", value: "==", description: "\"==\"" }, peg$c120 = function() { return "=="; }, peg$c121 = function() { error("Equality operator should be written as ==, not =."); return "=="; }, peg$c122 = "!==", peg$c123 = { type: "literal", value: "!==", description: "\"!==\"" }, peg$c124 = "!=", peg$c125 = { type: "literal", value: "!=", description: "\"!=\"" }, peg$c126 = function() { return "!="; }, peg$c127 = "&&", peg$c128 = { type: "literal", value: "&&", description: "\"&&\"" }, peg$c129 = "and", peg$c130 = { type: "literal", value: "and", description: "\"and\"" }, peg$c131 = function() { return "&&"; }, peg$c132 = "||", peg$c133 = { type: "literal", value: "||", description: "\"||\"" }, peg$c134 = "or", peg$c135 = { type: "literal", value: "or", description: "\"or\"" }, peg$c136 = function() { return "||"; }, peg$c137 = "?", peg$c138 = { type: "literal", value: "?", description: "\"?\"" }, peg$c139 = function(condition, trueExpression, falseExpression) { return ast.op('?:', [condition, trueExpression, falseExpression]); }, peg$c140 = "null", peg$c141 = { type: "literal", value: "null", description: "\"null\"" }, peg$c142 = function() { return ast.nullType() }, peg$c143 = function(elements) { return ast.array(elements); }, peg$c144 = "true", peg$c145 = { type: "literal", value: "true", description: "\"true\"" }, peg$c146 = function() { return ast.boolean(true); }, peg$c147 = "false", peg$c148 = { type: "literal", value: "false", description: "\"false\"" }, peg$c149 = function() { return ast.boolean(false); }, peg$c150 = { type: "other", description: "number" }, peg$c151 = /^[+\-]/, peg$c152 = { type: "class", value: "[+\\-]", description: "[+\\-]" }, peg$c153 = function(unary, literal) { if (unary == '-') { return ast.number(-literal); } return ast.number(literal); }, peg$c154 = function(parts) { return parseFloat(parts); }, peg$c155 = function(parts) { return parseFloat(parts); }, peg$c156 = "0", peg$c157 = { type: "literal", value: "0", description: "\"0\"" }, peg$c158 = /^[0-9]/, peg$c159 = { type: "class", value: "[0-9]", description: "[0-9]" }, peg$c160 = /^[1-9]/, peg$c161 = { type: "class", value: "[1-9]", description: "[1-9]" }, peg$c162 = /^[eE]/, peg$c163 = { type: "class", value: "[eE]", description: "[eE]" }, peg$c164 = /^[\-+]/, peg$c165 = { type: "class", value: "[\\-+]", description: "[\\-+]" }, peg$c166 = /^[xX]/, peg$c167 = { type: "class", value: "[xX]", description: "[xX]" }, peg$c168 = function(digits) { return parseInt(digits, 16); }, peg$c169 = /^[0-9a-fA-F]/, peg$c170 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, peg$c171 = { type: "other", description: "regexp" }, peg$c172 = /^[a-z]/, peg$c173 = { type: "class", value: "[a-z]", description: "[a-z]" }, peg$c174 = function(pattern, modifiers) { if (modifiers) { return ast.regexp(pattern, modifiers.join("")); } return ast.regexp(pattern); }, peg$c175 = /^[^\\\/]/, peg$c176 = { type: "class", value: "[^\\\\\\/]", description: "[^\\\\\\/]" }, peg$c177 = function(chars) { return chars.join(""); }, peg$c178 = "\\", peg$c179 = { type: "literal", value: "\\", description: "\"\\\\\"" }, peg$c180 = { type: "any", description: "any character" }, peg$c181 = function(char_) { return "\\" + char_; }, peg$c182 = { type: "other", description: "string" }, peg$c183 = function(s) { return ast.string(s); }, peg$c184 = "\"", peg$c185 = { type: "literal", value: "\"", description: "\"\\\"\"" }, peg$c186 = "'", peg$c187 = { type: "literal", value: "'", description: "\"'\"" }, peg$c188 = function(parts) { return parts[1]; }, peg$c189 = function(char_) { return char_; }, peg$c190 = function(sequence) { return sequence; }, peg$c191 = function(sequence) { return sequence; }, peg$c192 = function() { return "\0"; }, peg$c193 = /^['"\\bfnrt]/, peg$c194 = { type: "class", value: "['\"\\\\bfnrt]", description: "['\"\\\\bfnrt]" }, peg$c195 = function(char_) { return char_ .replace("b", "\b") .replace("f", "\f") .replace("n", "\n") .replace("r", "\r") .replace("t", "\t") }, peg$c196 = function(char_) { return char_; }, peg$c197 = "x", peg$c198 = { type: "literal", value: "x", description: "\"x\"" }, peg$c199 = "u", peg$c200 = { type: "literal", value: "u", description: "\"u\"" }, peg$c201 = function(digits) { return String.fromCharCode(parseInt(digits, 16)); }, peg$c202 = { type: "other", description: "identifier" }, peg$c203 = /^[a-zA-Z_$]/, peg$c204 = { type: "class", value: "[a-zA-Z_$]", description: "[a-zA-Z_$]" }, peg$c205 = /^[a-zA-Z_$0-9]/, peg$c206 = { type: "class", value: "[a-zA-Z_$0-9]", description: "[a-zA-Z_$0-9]" }, peg$c207 = function(start, rest) { return start + rest.join(""); }, peg$c208 = { type: "other", description: "whitespace" }, peg$c209 = /^[ \t\r\n]/, peg$c210 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" }, peg$c211 = { type: "other", description: "comment" }, peg$c212 = "/*", peg$c213 = { type: "literal", value: "/*", description: "\"/*\"" }, peg$c214 = "*/", peg$c215 = { type: "literal", value: "*/", description: "\"*/\"" }, peg$c216 = "//", peg$c217 = { type: "literal", value: "//", description: "\"//\"" }, peg$c218 = /^[;,}]/, peg$c219 = { type: "class", value: "[;,}]", description: "[;,}]" }, peg$c220 = function(chars) { return chars.join(''); }, peg$c221 = /^[\n\r]/, peg$c222 = { type: "class", value: "[\\n\\r]", description: "[\\n\\r]" }, peg$currPos = 0, peg$reportedPos = 0, peg$cachedPos = 0, peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$reportedPos, peg$currPos); } function offset() { return peg$reportedPos; } function line() { return peg$computePosDetails(peg$reportedPos).line; } function column() { return peg$computePosDetails(peg$reportedPos).column; } function expected(description) { throw peg$buildException( null, [{ type: "other", description: description }], peg$reportedPos ); } function error(message) { throw peg$buildException(message, null, peg$reportedPos); } function peg$computePosDetails(pos) { function advance(details, startPos, endPos) { var p, ch; for (p = startPos; p < endPos; p++) { ch = input.charAt(p); if (ch === "\n") { if (!details.seenCR) { details.line++; } details.column = 1; details.seenCR = false; } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { details.line++; details.column = 1; details.seenCR = true; } else { details.column++; details.seenCR = false; } } } if (peg$cachedPos !== pos) { if (peg$cachedPos > pos) { peg$cachedPos = 0; peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; } advance(peg$cachedPosDetails, peg$cachedPos, pos); peg$cachedPos = pos; } return peg$cachedPosDetails; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildException(message, expected, pos) { function cleanupExpected(expected) { var i = 1; expected.sort(function(a, b) { if (a.description < b.description) { return -1; } else if (a.description > b.description) { return 1; } else { return 0; } }); while (i < expected.length) { if (expected[i - 1] === expected[i]) { expected.splice(i, 1); } else { i++; } } } function buildMessage(expected, found) { function stringEscape(s) { function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\x08/g, '\\b') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\f/g, '\\f') .replace(/\r/g, '\\r') .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); } var expectedDescs = new Array(expected.length), expectedDesc, foundDesc, i; for (i = 0; i < expected.length; i++) { expectedDescs[i] = expected[i].description; } expectedDesc = expected.length > 1 ? expectedDescs.slice(0, -1).join(", ") + " or " + expectedDescs[expected.length - 1] : expectedDescs[0]; foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; return "Expected " + expectedDesc + " but " + foundDesc + " found."; } var posDetails = peg$computePosDetails(pos), found = pos < input.length ? input.charAt(pos) : null; if (expected !== null) { cleanupExpected(expected); } return new SyntaxError( message !== null ? message : buildMessage(expected, found), expected, found, pos, posDetails.line, posDetails.column ); } function peg$parsestart() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parseStatements(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c1(); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } return s0; } function peg$parseStatements() { var s0, s1, s2, s3; s0 = []; s1 = peg$currPos; s2 = peg$parseStatement(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$c0; } } else { peg$currPos = s1; s1 = peg$c0; } while (s1 !== peg$FAILED) { s0.push(s1); s1 = peg$currPos; s2 = peg$parseStatement(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$c0; } } else { peg$currPos = s1; s1 = peg$c0; } } return s0; } function peg$parseStatement() { var s0; s0 = peg$parseFunction(); if (s0 === peg$FAILED) { s0 = peg$parsePath(); if (s0 === peg$FAILED) { s0 = peg$parseSchema(); } } return s0; } function peg$parseFunction() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; s1 = peg$parseFunctionStart(); if (s1 !== peg$FAILED) { s2 = peg$parseFunctionBody(); if (s2 === peg$FAILED) { s2 = peg$c4; } if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c5(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } return s0; } function peg$parseFunctionStart() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; if (input.substr(peg$currPos, 8) === peg$c6) { s1 = peg$c6; peg$currPos += 8; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseIdentifier(); if (s3 === peg$FAILED) { s3 = peg$c4; } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parseParameterList(); if (s5 === peg$FAILED) { s5 = peg$c4; } if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c8(s3, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseIdentifier(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = peg$parseParameterList(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c9(s1, s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } return s0; } function peg$parsePath() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; peg$silentFails++; s0 = peg$currPos; s1 = peg$parsePathStart(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parse__(); if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c11) { s4 = peg$c11; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c12); } } if (s4 !== peg$FAILED) { s5 = peg$parse__(); if (s5 !== peg$FAILED) { s6 = peg$parseTypeExpression(); if (s6 !== peg$FAILED) { peg$reportedPos = s2; s3 = peg$c13(s6); s2 = s3; } else { peg$currPos = s2; s2 = peg$c0; } } else { peg$currPos = s2; s2 = peg$c0; } } else { peg$currPos = s2; s2 = peg$c0; } } else { peg$currPos = s2; s2 = peg$c0; } if (s2 === peg$FAILED) { s2 = peg$c4; } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s5 = peg$c14; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) { s7 = peg$parsePathsAndMethods(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s8 = peg$c16; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s8 !== peg$FAILED) { peg$reportedPos = s4; s5 = peg$c18(s7); s4 = s5; } else { peg$currPos = s4; s4 = peg$c0; } } else { peg$currPos = s4; s4 = peg$c0; } } else { peg$currPos = s4; s4 = peg$c0; } } else { peg$currPos = s4; s4 = peg$c0; } if (s4 === peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 59) { s5 = peg$c19; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } if (s5 !== peg$FAILED) { peg$reportedPos = s4; s5 = peg$c21(); } s4 = s5; } if (s4 === peg$FAILED) { s4 = peg$c4; } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c22(s1, s2, s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } return s0; } function peg$parsePathStart() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.substr(peg$currPos, 4) === peg$c23) { s1 = peg$c23; peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parsePathTemplate(); if (s3 === peg$FAILED) { s3 = peg$c4; } if (s3 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c25(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsePathTemplate(); if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c26(s1); } s0 = s1; } return s0; } function peg$parsePathTemplate() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = []; s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { s3 = peg$c28; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s3 !== peg$FAILED) { s4 = peg$parsePathKey(); if (s4 === peg$FAILED) { s4 = peg$c4; } if (s4 !== peg$FAILED) { peg$reportedPos = s2; s3 = peg$c30(s4); s2 = s3; } else { peg$currPos = s2; s2 = peg$c0; } } else { peg$currPos = s2; s2 = peg$c0; } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { s3 = peg$c28; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s3 !== peg$FAILED) { s4 = peg$parsePathKey(); if (s4 === peg$FAILED) { s4 = peg$c4; } if (s4 !== peg$FAILED) { peg$reportedPos = s2; s3 = peg$c30(s4); s2 = s3; } else { peg$currPos = s2; s2 = peg$c0; } } else { peg$currPos = s2; s2 = peg$c0; } } } else { s1 = peg$c0; } if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c31(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } return s0; } function peg$parsePathKey() { var s0; s0 = peg$parseCaptureKey(); if (s0 === peg$FAILED) { s0 = peg$parseLiteralPathKey(); } return s0; } function peg$parseCaptureKey() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c14; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = peg$parseIdentifier(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 61) { s6 = peg$c32; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 42) { s8 = peg$c34; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s8 !== peg$FAILED) { s9 = peg$parse_(); if (s9 !== peg$FAILED) { s6 = [s6, s7, s8, s9]; s5 = s6; } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } if (s5 === peg$FAILED) { s5 = peg$c4; } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s6 = peg$c16; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s6 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c36(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } return s0; } function peg$parseLiteralPathKey() { var s0, s1, s2; s0 = peg$currPos; s1 = []; if (peg$c37.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c37.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } } } else { s1 = peg$c0; } if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c39(s1); } s0 = s1; return s0; } function peg$parsePathsAndMethods() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsePath(); if (s2 === peg$FAILED) { s2 = peg$parseMethod(); if (s2 === peg$FAILED) { s2 = peg$parseAnyBlock(); } } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsePath(); if (s2 === peg$FAILED) { s2 = peg$parseMethod(); if (s2 === peg$FAILED) { s2 = peg$parseAnyBlock(); } } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c40(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } return s0; } function peg$parseSchema() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; peg$silentFails++; s0 = peg$currPos; if (input.substr(peg$currPos, 4) === peg$c42) { s1 = peg$c42; peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseIdentifier(); if (s3 === peg$FAILED) { s3 = peg$c4; } if (s3 !== peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { s5 = peg$c44; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c45); } } if (s5 !== peg$FAILED) { s6 = peg$parseIdentifierList(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 62) { s7 = peg$c46; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s7 !== peg$FAILED) { peg$reportedPos = s4; s5 = peg$c48(s6); s4 = s5; } else { peg$currPos = s4; s4 = peg$c0; } } else { peg$currPos = s4; s4 = peg$c0; } } else { peg$currPos = s4; s4 = peg$c0; } if (s4 === peg$FAILED) { s4 = peg$c4; } if (s4 !== peg$FAILED) { s5 = peg$currPos; s6 = peg$parse__(); if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 7) === peg$c49) { s7 = peg$c49; peg$currPos += 7; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s7 !== peg$FAILED) { s8 = peg$parse__(); if (s8 !== peg$FAILED) { s9 = peg$parseTypeExpression(); if (s9 !== peg$FAILED) { s10 = peg$parse_(); if (s10 !== peg$FAILED) { peg$reportedPos = s5; s6 = peg$c51(s9); s5 = s6; } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } } else { peg$currPos = s5; s5 = peg$c0; } if (s5 === peg$FAILED) { s5 = peg$c4; } if (s5 !== peg$FAILED) { s6 = peg$currPos; s7 = peg$parse_(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s8 = peg$c14; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s8 !== peg$FAILED) { s9 = peg$parse_(); if (s9 !== peg$FAILED) { s10 = peg$parsePropertiesAndMethods(); if (s10 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s11 = peg$c16; peg$currPos++; } else { s11 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s11 !== peg$FAILED) { peg$reportedPos = s6; s7 = peg$c18(s10); s6 = s7; } else { peg$currPos = s6; s6 = peg$c0; } } else { peg$currPos = s6; s6 = peg$c0; } } else { peg$currPos = s6; s6 = peg$c0; } } else { peg$currPos = s6; s6 = peg$c0; } } else { peg$currPos = s6; s6 = peg$c0; } if (s6 === peg$FAILED) { s6 = peg$currPos; s7 = peg$parse_(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s8 = peg$c19; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } if (s8 !== peg$FAILED) { peg$reportedPos = s6; s7 = peg$c52(); s6 = s7; } else { peg$currPos = s6; s6 = peg$c0; } } else { peg$currPos = s6; s6 = peg$c0; } } if (s6 === peg$FAILED) { s6 = peg$c4; } if (s6 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c53(s3, s4, s5, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } return s0; } function peg$parsePropertiesAndMethods() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parseProperty(); if (s2 === peg$FAILED) { s2 = peg$parseMethod(); if (s2 === peg$FAILED) { s2 = peg$parseAnyBlock(); } } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseProperty(); if (s2 === peg$FAILED) { s2 = peg$parseMethod(); if (s2 === peg$FAILED) { s2 = peg$parseAnyBlock(); } } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c54(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$c0; } } else { peg$currPos = s0; s0 = peg$c0; } return s0; } function peg$parseProperty() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parseIdentifier(); if (s1 === peg$FAILED) { s1 = peg$parseString(); } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s3 = peg$c55; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c56); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) {