UNPKG

@sap/xsodata

Version:

Expose data from a HANA database as OData V2 service with help of .xsodata files.

1,351 lines (1,241 loc) 182 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function(expectation) { return "any character"; }, end: function(expectation) { return "end of input"; }, other: function(expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = function(d) { return d; }, peg$c1 = function(s, a, se) { var ret = {} ret.service = s; ret.annotations = a ? a[1] : null; ret.settings = se ? se[1] : null; return ret; }, peg$c2 = "service", peg$c3 = peg$literalExpectation("service", false), peg$c4 = function(n, b) { var ret = { }; if (n) { ret.namespace = n[1]; }; if (b.entityTypes) { ret.entityTypes = b.entityTypes Object.keys(b.entityTypes).forEach(function (key) { if (b.entityTypes[key].scopes && !b.scopes) { throw new Error("Missing scopes at service level"); } if (b.entityTypes[key].scopes && b.entityTypes[key].scopes.debug) { throw new Error("Debug scope can not be defined at entitySet level"); } }); } if (b.associations) { ret.associations = b.associations } if (b.additionalExits) { ret.additionalExits = b.additionalExits } if (b.scopes) { ret.scopes = b.scopes } // FIX4MASTER Check if service scopes are defined if one entityset // scope is defined return ret; }, peg$c5 = "namespace", peg$c6 = peg$literalExpectation("namespace", false), peg$c7 = function(q) { return q; }, peg$c8 = "{", peg$c9 = peg$literalExpectation("{", false), peg$c10 = ";", peg$c11 = peg$literalExpectation(";", false), peg$c12 = "}", peg$c13 = peg$literalExpectation("}", false), peg$c14 = function(e, m) { return e; if (m) { e.metadata = m[1]; } }, peg$c15 = function(e) { var ret = {}; ret.associations = {}; ret.entityTypes = {}; ret.additionalExits = {}; for (var i = 0; i < e.length; i++) { if (e[i][0+1].isAssociation === true) { delete e[i][0+1].isAssociation; ret.associations[e[i][0+1].name] = e[i][0+1]; } else if (e[i][0+1].isMetadataExit === true) { delete e[i][0+1].isMetadataExit; ret.additionalExits.metadata = e[i][0+1]; } else if (e[i][1] && e[i][1].type && e[i][1].type === "scope") { ret.scopes = e[i][1].value; } else { ret.entityTypes[e[i][0+1].name] = (e[i][0+1]); } } return ret; }, peg$c16 = "metadata using", peg$c17 = peg$literalExpectation("metadata using", false), peg$c18 = function(q) { return { 'isMetadataExit' : true, 'using' : q }; }, peg$c19 = function(e) { return e; }, peg$c20 = function(o, es, w, k, ct, rt, n, ge, a, p, m, scopes, ad) { var ret = {}; var atv = '.attributeview'; if (utils.endsWith(o.name,atv)){ ret.table = o.name.substring(0,o.name.length-atv.length); ret.isAttributeView = true; } else { ret.table = o.name; ret.isAttributeView = false; } if (o.isExplicitEntity) { ret.isExplicitEntity = o.isExplicitEntity; } ret.schema = o.schema; if (es) { ret.name = es[1]; } else { var i = ret.table.indexOf('::'); if (i > -1) { ret.name = ret.table.substr(i+2); } else { ret.name = ret.table; } } if (k) { if (k[1].isGenerated === true) { delete (k[1].isGenerated); ret['keys_generated'] = k[1]; } else { ret.keys = k[1]; } } else { ret.keys = null; } //properties ret.properties = {}; if (w) { if (w[1].isWithOut === true) { ret.properties.without = w[1].propertylist; } else { ret.properties.with= w[1].propertylist; } } if (ge) { ret.globalExpand = true; } ret.aggregates = a ? a[1] : null; ret.parameters = p ? p[1] : null; ret.concurrencytoken = ct ? ct[1] : null; ret.retainOrder = rt ? rt[1] : null; ret.modifications = m || null; ret.admindata = ad ? ad[1].value : null; if (n) { ret.navigates = n[1]; } else { ret.navigates = null; } if (scopes) { ret.scopes = scopes[1].value; } return ret; }, peg$c21 = "expand via global temporary table", peg$c22 = peg$literalExpectation("expand via global temporary table", false), peg$c23 = "concurrencytoken", peg$c24 = peg$literalExpectation("concurrencytoken", false), peg$c25 = function(k) { var ret = {}; if (k) { k[1].map(function(elem){ ret[elem] = true; }); } return ret; }, peg$c26 = "retain", peg$c27 = peg$literalExpectation("retain", false), peg$c28 = "order", peg$c29 = peg$literalExpectation("order", false), peg$c30 = function() { return true; }, peg$c31 = "entity", peg$c32 = peg$literalExpectation("entity", false), peg$c33 = ".", peg$c34 = peg$literalExpectation(".", false), peg$c35 = function(e, s, r) { return { 'isExplicitEntity' : (e ? true : false), 'name' : r, 'schema' : (s ? s[0] : null) } }, peg$c36 = "/", peg$c37 = peg$literalExpectation("/", false), peg$c38 = "as", peg$c39 = peg$literalExpectation("as", false), peg$c40 = function(e) { return e;}, peg$c41 = "without", peg$c42 = peg$literalExpectation("without", false), peg$c43 = "with", peg$c44 = peg$literalExpectation("with", false), peg$c45 = function(w, p) { var ret = { propertylist : p }; if (w === 'without') { ret.isWithOut = true; } return ret; }, peg$c46 = "(", peg$c47 = peg$literalExpectation("(", false), peg$c48 = ")", peg$c49 = peg$literalExpectation(")", false), peg$c50 = function(c) { return c; }, peg$c51 = ",", peg$c52 = peg$literalExpectation(",", false), peg$c53 = function(c, cl) { var ret = [c]; for (var i = 0; i < cl.length; i++) { ret.push(cl[i][2+1]); } return ret; }, peg$c54 = function(q) { return q;}, peg$c55 = "keys", peg$c56 = peg$literalExpectation("keys", false), peg$c57 = "key", peg$c58 = peg$literalExpectation("key", false), peg$c59 = function(k) { return k[1]; }, peg$c60 = "generate", peg$c61 = peg$literalExpectation("generate", false), peg$c62 = function(k) { var ret= { isGenerated : true, } if ( k) { ret.local = k[1]; } return ret; }, peg$c63 = "local", peg$c64 = peg$literalExpectation("local", false), peg$c65 = function(c) { return c; }, peg$c66 = "navigates", peg$c67 = peg$literalExpectation("navigates", false), peg$c68 = function(n) { return n; }, peg$c69 = function(n, nl) { var ret = {}; ret[n.name] = n; for (var i = 0; i < nl.length; i++) { ret[nl[i][2].name]= nl[i][2]; } return ret; }, peg$c70 = function(a, n, f) { var ret = { "name" : n, "association" : a, } if (f) { ret.from = {}; if (f[1] === 'principal') { ret.from.principal = true; } else { ret.from.dependent = true; } } return ret; }, peg$c71 = function(ss) { if (!ss.value.create) { throw new Error("Missing create scope in service"); } if (!ss.value.read) { throw new Error("Missing read scope in service"); } if (!ss.value.update) { throw new Error("Missing update scope in service"); } if (!ss.value.delete) { throw new Error("Missing delete scope in service"); } return ss; }, peg$c72 = "scopes", peg$c73 = peg$literalExpectation("scopes", false), peg$c74 = function(sd) { var ret = { scopesMap: {} }, scope, type; sd.forEach(function (elem) { scope = elem.def; type = elem.type; ret[elem.type] = [scope.scope]; if (!ret.scopesMap[scope.scope]) { ret.scopesMap[scope.scope] = { methods: {} } } ret.scopesMap[scope.scope].methods[type] = true; }) // forEach() end return { type: "scope", value: ret }; }, peg$c75 = function(m, md) { var ret = { type: m, def: md }; return ret; }, peg$c76 = function(elem) { return elem }, peg$c77 = function(s1) { var ret = { scope: s1 }; return ret; }, peg$c78 = "create", peg$c79 = peg$literalExpectation("create", false), peg$c80 = function() { return "create"; }, peg$c81 = "read", peg$c82 = peg$literalExpectation("read", false), peg$c83 = function() { return "read"; }, peg$c84 = "update", peg$c85 = peg$literalExpectation("update", false), peg$c86 = function() { return "update"; }, peg$c87 = "delete", peg$c88 = peg$literalExpectation("delete", false), peg$c89 = function() { return "delete"; }, peg$c90 = "debug", peg$c91 = peg$literalExpectation("debug", false), peg$c92 = function() { return "debug"; }, peg$c93 = "from", peg$c94 = peg$literalExpectation("from", false), peg$c95 = "principal", peg$c96 = peg$literalExpectation("principal", false), peg$c97 = "dependent", peg$c98 = peg$literalExpectation("dependent", false), peg$c99 = function(pd) { return pd; }, peg$c100 = "aggregates", peg$c101 = peg$literalExpectation("aggregates", false), peg$c102 = "always", peg$c103 = peg$literalExpectation("always", false), peg$c104 = function(a) { if (a) { return a[1]; } return {}; }, peg$c105 = function(a) { return a; }, peg$c106 = function(a, al) { var ret = [a]; for (var i = 0; i < al.length; i++) { ret.push(al[i][2]); } return ret; }, peg$c107 = "of", peg$c108 = peg$literalExpectation("of", false), peg$c109 = function(a, c) { return { "function" : a, "column" : c }; }, peg$c110 = "SUM", peg$c111 = peg$literalExpectation("SUM", false), peg$c112 = "AVG", peg$c113 = peg$literalExpectation("AVG", false), peg$c114 = "MIN", peg$c115 = peg$literalExpectation("MIN", false), peg$c116 = "MAX", peg$c117 = peg$literalExpectation("MAX", false), peg$c118 = "COUNT", peg$c119 = peg$literalExpectation("COUNT", false), peg$c120 = "parameters", peg$c121 = peg$literalExpectation("parameters", false), peg$c122 = "via", peg$c123 = peg$literalExpectation("via", false), peg$c124 = function(pk, pe, pp) { var ret = {}; if ( pk ) { ret.viaKey = true; } if ( pe ) { ret.entity = pe[1]; } if ( pp ) { ret.resultProperty = pp[1]; } return ret; }, peg$c125 = "and", peg$c126 = peg$literalExpectation("and", false), peg$c127 = "results", peg$c128 = peg$literalExpectation("results", false), peg$c129 = "property", peg$c130 = peg$literalExpectation("property", false), peg$c131 = function(q) { return q; }, peg$c132 = function(aMs) { var ret = { }; for (var i = 0; i < aMs.length; i++) { if (aMs[i].create) { ret.create = aMs[i].create; } if (aMs[i].update) { ret.update = aMs[i].update; } if (aMs[i].delete) { ret.delete = aMs[i].delete; } } return ret; }, peg$c133 = function(cud) { return cud; }, peg$c134 = function(m) { return { "create" : m }; }, peg$c135 = function(m) { return { "update" : m }; }, peg$c136 = function(m) { return { "delete" : m }; }, peg$c137 = "metadata", peg$c138 = peg$literalExpectation("metadata", false), peg$c139 = function(m) { return { "metadata" : m }; }, peg$c140 = "forbidden", peg$c141 = peg$literalExpectation("forbidden", false), peg$c142 = function(a) { return a; }, peg$c143 = function(a, em) { var ret = {}; ret.using = a; if (em) { ret.events = em[1].events; } return ret; }, peg$c144 = "using", peg$c145 = peg$literalExpectation("using", false), peg$c146 = function(a) { return a; }, peg$c147 = "events", peg$c148 = peg$literalExpectation("events", false), peg$c149 = function(e) { return { events: e}; }, peg$c150 = function(e, el) { var ret = [e]; for (var i = 0; i < el.length; i++) { ret.push(el[i][2]); } return ret; }, peg$c151 = function(e, a) { return { type: e, action:a }; }, peg$c152 = "before", peg$c153 = peg$literalExpectation("before", false), peg$c154 = "after", peg$c155 = peg$literalExpectation("after", false), peg$c156 = "precommit", peg$c157 = peg$literalExpectation("precommit", false), peg$c158 = "postcommit", peg$c159 = peg$literalExpectation("postcommit", false), peg$c160 = function(a, c, p, d, as, m) { var ret = { "isAssociation" : true, "name" : a.name, "principal" : p, "dependent" : d, "referentialConstraint" : ( c ? true : false ), "over" : null, } if ( a.viaParameters) { ret.viaParameters = a.viaParameters; } if (as) { if (as[1].over) { ret.over = as[1].over; } if (as[1].storage) { ret.storage = as[1].storage; } } ret.modification = m || null; return ret; }, peg$c161 = "with referential constraint", peg$c162 = peg$literalExpectation("with referential constraint", false), peg$c163 = "association", peg$c164 = peg$literalExpectation("association", false), peg$c165 = "via parameters", peg$c166 = peg$literalExpectation("via parameters", false), peg$c167 = function(p, a) { var ret = { name : a }; if (p) { ret.viaParameters = true; } return ret; }, peg$c168 = function(e) { return e; }, peg$c169 = function(e, m) { var ret = { "type": e.type, "joinproperties" :e.joinproperties, "multiplicity" : m, }; return ret; }, peg$c170 = function(et, jp) { return { "type" : et, "joinproperties" : jp ? jp[1]: null };}, peg$c171 = function(jp) { return jp; }, peg$c172 = function(c) { return c; }, peg$c173 = "multiplicity", peg$c174 = peg$literalExpectation("multiplicity", false), peg$c175 = function(m) { return m; }, peg$c176 = "0..1", peg$c177 = peg$literalExpectation("0..1", false), peg$c178 = "1..*", peg$c179 = peg$literalExpectation("1..*", false), peg$c180 = "1", peg$c181 = peg$literalExpectation("1", false), peg$c182 = "*", peg$c183 = peg$literalExpectation("*", false), peg$c184 = "over", peg$c185 = peg$literalExpectation("over", false), peg$c186 = function(r, p, d) { var over = { "object" : r, "principal" : p, "dependent" : d }; return { "over" : over }; }, peg$c187 = function(oe) { return oe; }, peg$c188 = function(p) { return p; }, peg$c189 = function(s) { return { storage :s }; }, peg$c190 = "no", peg$c191 = peg$literalExpectation("no", false), peg$c192 = "storage", peg$c193 = peg$literalExpectation("storage", false), peg$c194 = function() { return "none" }, peg$c195 = "on", peg$c196 = peg$literalExpectation("on", false), peg$c197 = "annotations", peg$c198 = peg$literalExpectation("annotations", false), peg$c199 = function(al) { var ret = {}; var item; for (var i = 0; i < al.length; i++) { item = al[i][1]; ret[item.name] = item.value; } return ret; }, peg$c200 = "enable", peg$c201 = peg$literalExpectation("enable", false), peg$c202 = function(s) { return { name : "enable", value : s }; }, peg$c203 = "settings", peg$c204 = peg$literalExpectation("settings", false), peg$c205 = function(s) { return s; }, peg$c206 = function(sl) { var ret = {}; var item; for (var i = 0; i < sl.length; i++) { item = sl[i][1]; ret[item.name] = item.value; } return ret; }, peg$c207 = "cache.control", peg$c208 = peg$literalExpectation("cache.control", false), peg$c209 = "cache-control", peg$c210 = peg$literalExpectation("cache-control", false), peg$c211 = function(qs) { return { "name" : "metadata", "value" : { "cache-control" : qs } }; }, peg$c212 = "content", peg$c213 = peg$literalExpectation("content", false), peg$c214 = function(qs) { return { "name" : "content", "value" : { "cache-control" : qs } }; }, peg$c215 = function() { return { name : "enable", value : s }; }, peg$c216 = "support", peg$c217 = peg$literalExpectation("support", false), peg$c218 = function(s) { return { name : "support", value : s }; }, peg$c219 = "noDimensionAnnoOnTextProperty", peg$c220 = peg$literalExpectation("noDimensionAnnoOnTextProperty", false), peg$c221 = function(s) { return { name : "noDimensionAnnoOnTextProperty", value : s }; }, peg$c222 = "hints", peg$c223 = peg$literalExpectation("hints", false), peg$c224 = "null", peg$c225 = peg$literalExpectation("null", false), peg$c226 = function(hl) { var value = hl === 'null' ? [] : hl return { name : 'hints', value : value }; }, peg$c227 = "limits", peg$c228 = peg$literalExpectation("limits", false), peg$c229 = function(qs, qsl) { var value = { [qs.name] : qs.value }; for (var i = 0; i < qsl.length; i++) { value[qsl[i][2].name] = qsl[i][2].value; } return { name : 'limits', value : value }; }, peg$c230 = "max_records", peg$c231 = peg$literalExpectation("max_records", false), peg$c232 = "max_expanded_records", peg$c233 = peg$literalExpectation("max_expanded_records", false), peg$c234 = "max_body_size", peg$c235 = peg$literalExpectation("max_body_size", false), peg$c236 = "=", peg$c237 = peg$literalExpectation("=", false), peg$c238 = function(as, a) { return { name : as, value: a }; }, peg$c239 = "admindata", peg$c240 = peg$literalExpectation("admindata", false), peg$c241 = function(qs, qsl) { var value = [qs]; for (var i = 0; i < qsl.length; i++) { value.push(qsl[i][2]); } return { name : 'admindata', value : value }; }, peg$c242 = "add", peg$c243 = peg$literalExpectation("add", false), peg$c244 = "skip", peg$c245 = peg$literalExpectation("skip", false), peg$c246 = function(as, a) { if ( as === "add") { a.value = 'add'; } else { a.value = 'skip'; } return a; }, peg$c247 = "created", peg$c248 = peg$literalExpectation("created", false), peg$c249 = "modified", peg$c250 = peg$literalExpectation("modified", false), peg$c251 = "by", peg$c252 = peg$literalExpectation("by", false), peg$c253 = "at", peg$c254 = peg$literalExpectation("at", false), peg$c255 = function(w, o) { return { operation : w === "created" ? "create" : "modify", property : o, }; }, peg$c256 = function(qs, qsl) { var items = [qs]; for (var i = 0; i < qsl.length; i++) { items.push(qsl[i][2]); } return items; }, peg$c257 = function(c) { return c.join(''); }, peg$c258 = "\\", peg$c259 = peg$literalExpectation("\\", false), peg$c260 = peg$anyExpectation(), peg$c261 = "'", peg$c262 = peg$literalExpectation("'", false), peg$c263 = "\"", peg$c264 = peg$literalExpectation("\"", false), peg$c265 = function(n) { return n.join(''); }, peg$c266 = function(a) { return a.join(''); }, peg$c267 = function(char) {return char}, peg$c268 = /^[\t\x0B\f \xA0\uFEFF]/, peg$c269 = peg$classExpectation(["\t", "\x0B", "\f", " ", "\xA0", "\uFEFF"], false, false), peg$c270 = /^[\n\r]/, peg$c271 = peg$classExpectation(["\n", "\r"], false, false), peg$c272 = "/*", peg$c273 = peg$literalExpectation("/*", false), peg$c274 = "*/", peg$c275 = peg$literalExpectation("*/", false), peg$c276 = "//", peg$c277 = peg$literalExpectation("//", false), 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$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location ); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError( peg$SyntaxError.buildMessage(expected, found), expected, found, location ); } function peg$parsestart() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseOWS(); if (s1 !== peg$FAILED) { s2 = peg$parsedefinition(); if (s2 !== peg$FAILED) { s3 = peg$parseOWS(); if (s3 !== peg$FAILED) { s4 = peg$parseEOF(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsedefinition() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parseservice(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parseOWS(); if (s3 !== peg$FAILED) { s4 = peg$parseannotations(); if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = peg$parseOWS(); if (s4 !== peg$FAILED) { s5 = peg$parsesettings(); 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 = null; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c1(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; } return s0; } function peg$parseservice() { var s0, s1, s2, s3, s4; s0 = peg$currPos; if (input.substr(peg$currPos, 7) === peg$c2) { s1 = peg$c2; peg$currPos += 7; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parseMWS(); if (s3 !== peg$FAILED) { s4 = peg$parsenamespace(); if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s3 = peg$parseOWS(); if (s3 !== peg$FAILED) { s4 = peg$parseservicebody(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c4(s2, s4); 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; } return s0; } function peg$parsenamespace() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.substr(peg$currPos, 9) === peg$c5) { s1 = peg$c5; peg$currPos += 9; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s1 !== peg$FAILED) { s2 = peg$parseMWS(); if (s2 !== peg$FAILED) { s3 = peg$parsequotedstring(); if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c7(s3); s0 = s1; } 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$parseservicebody() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c8; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s1 !== peg$FAILED) { s2 = peg$parseentrylist(); if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = peg$parseMWS(); if (s4 !== peg$FAILED) { s5 = peg$parsemetadata(); if (s5 !== peg$FAILED) { s6 = peg$parseOWS(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s7 = peg$c10; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseOWS(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s5 = peg$c12; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c13); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c14(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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseentrylist() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = []; s2 = peg$currPos; s3 = peg$parseOWS(); if (s3 !== peg$FAILED) { s4 = peg$parseentry(); if (s4 !== peg$FAILED) { s5 = peg$parseOWS(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s6 = peg$c10; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s6 !== peg$FAILED) { s3 = [s3, s4, s5, s6]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$currPos; s3 = peg$parseOWS(); if (s3 !== peg$FAILED) { s4 = peg$parseentry(); if (s4 !== peg$FAILED) { s5 = peg$parseOWS(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s6 = peg$c10; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg