1 | module.exports = (function() {
|
2 | "use strict";
|
3 |
|
4 | |
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function peg$subclass(child, parent) {
|
11 | function ctor() { this.constructor = child; }
|
12 | ctor.prototype = parent.prototype;
|
13 | child.prototype = new ctor();
|
14 | }
|
15 |
|
16 | function peg$SyntaxError(message, expected, found, location) {
|
17 | this.message = message;
|
18 | this.expected = expected;
|
19 | this.found = found;
|
20 | this.location = location;
|
21 | this.name = "SyntaxError";
|
22 |
|
23 | if (typeof Error.captureStackTrace === "function") {
|
24 | Error.captureStackTrace(this, peg$SyntaxError);
|
25 | }
|
26 | }
|
27 |
|
28 | peg$subclass(peg$SyntaxError, Error);
|
29 |
|
30 | function peg$parse(input) {
|
31 | var options = arguments.length > 1 ? arguments[1] : {},
|
32 | parser = this,
|
33 |
|
34 | peg$FAILED = {},
|
35 |
|
36 | peg$startRuleFunctions = { start: peg$parsestart },
|
37 | peg$startRuleFunction = peg$parsestart,
|
38 |
|
39 | peg$c0 = function() { return parser.getResult(); },
|
40 | peg$c1 = "INPORT=",
|
41 | peg$c2 = { type: "literal", value: "INPORT=", description: "\"INPORT=\"" },
|
42 | peg$c3 = ".",
|
43 | peg$c4 = { type: "literal", value: ".", description: "\".\"" },
|
44 | peg$c5 = ":",
|
45 | peg$c6 = { type: "literal", value: ":", description: "\":\"" },
|
46 | peg$c7 = function(node, port, pub) {return parser.registerInports(node,port,pub)},
|
47 | peg$c8 = "OUTPORT=",
|
48 | peg$c9 = { type: "literal", value: "OUTPORT=", description: "\"OUTPORT=\"" },
|
49 | peg$c10 = function(node, port, pub) {return parser.registerOutports(node,port,pub)},
|
50 | peg$c11 = "DEFAULT_INPORT=",
|
51 | peg$c12 = { type: "literal", value: "DEFAULT_INPORT=", description: "\"DEFAULT_INPORT=\"" },
|
52 | peg$c13 = function(name) { defaultInPort = name},
|
53 | peg$c14 = "DEFAULT_OUTPORT=",
|
54 | peg$c15 = { type: "literal", value: "DEFAULT_OUTPORT=", description: "\"DEFAULT_OUTPORT=\"" },
|
55 | peg$c16 = function(name) { defaultOutPort = name},
|
56 | peg$c17 = function(annotation) { return parser.registerAnnotation(annotation[0], annotation[1]); },
|
57 | peg$c18 = function(edges) {return parser.registerEdges(edges);},
|
58 | peg$c19 = ",",
|
59 | peg$c20 = { type: "literal", value: ",", description: "\",\"" },
|
60 | peg$c21 = /^[\n\r\u2028\u2029]/,
|
61 | peg$c22 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" },
|
62 | peg$c23 = "#",
|
63 | peg$c24 = { type: "literal", value: "#", description: "\"#\"" },
|
64 | peg$c25 = "->",
|
65 | peg$c26 = { type: "literal", value: "->", description: "\"->\"" },
|
66 | peg$c27 = function(x, y) { return [x,y]; },
|
67 | peg$c28 = function(x, proc, y) { return [{"tgt":makeInPort(proc, x)},{"src":makeOutPort(proc, y)}]; },
|
68 | peg$c29 = function(proc, port) { return {"src":makeOutPort(proc, port)} },
|
69 | peg$c30 = function(port, proc) { return {"tgt":makeInPort(proc, port)} },
|
70 | peg$c31 = "'",
|
71 | peg$c32 = { type: "literal", value: "'", description: "\"'\"" },
|
72 | peg$c33 = function(iip) { return {"data":iip.join("")} },
|
73 | peg$c34 = function(iip) { return {"data":iip} },
|
74 | peg$c35 = function(name) { return name},
|
75 | peg$c36 = /^[a-zA-Z_]/,
|
76 | peg$c37 = { type: "class", value: "[a-zA-Z_]", description: "[a-zA-Z_]" },
|
77 | peg$c38 = /^[a-zA-Z0-9_\-]/,
|
78 | peg$c39 = { type: "class", value: "[a-zA-Z0-9_\\-]", description: "[a-zA-Z0-9_\\-]" },
|
79 | peg$c40 = function(name) { return makeName(name)},
|
80 | peg$c41 = function(name, comp) { parser.addNode(name,comp); return name},
|
81 | peg$c42 = function(comp) { return parser.addAnonymousNode(comp, location().start.offset) },
|
82 | peg$c43 = "(",
|
83 | peg$c44 = { type: "literal", value: "(", description: "\"(\"" },
|
84 | peg$c45 = /^[a-zA-Z\/\-0-9_]/,
|
85 | peg$c46 = { type: "class", value: "[a-zA-Z/\\-0-9_]", description: "[a-zA-Z/\\-0-9_]" },
|
86 | peg$c47 = ")",
|
87 | peg$c48 = { type: "literal", value: ")", description: "\")\"" },
|
88 | peg$c49 = function(comp, meta) { var o = {}; comp ? o.comp = comp.join("") : o.comp = ''; meta ? o.meta = meta.join("").split(',') : null; return o; },
|
89 | peg$c50 = /^[a-zA-Z\/=_,0-9]/,
|
90 | peg$c51 = { type: "class", value: "[a-zA-Z/=_,0-9]", description: "[a-zA-Z/=_,0-9]" },
|
91 | peg$c52 = function(meta) {return meta},
|
92 | peg$c53 = "@",
|
93 | peg$c54 = { type: "literal", value: "@", description: "\"@\"" },
|
94 | peg$c55 = /^[a-zA-Z0-9\-_]/,
|
95 | peg$c56 = { type: "class", value: "[a-zA-Z0-9\\-_]", description: "[a-zA-Z0-9\\-_]" },
|
96 | peg$c57 = /^[a-zA-Z0-9\-_ .]/,
|
97 | peg$c58 = { type: "class", value: "[a-zA-Z0-9\\-_ \\.]", description: "[a-zA-Z0-9\\-_ \\.]" },
|
98 | peg$c59 = function(key, value) { return [key.join(''), value.join('')]; },
|
99 | peg$c60 = function(portname, portindex) {return { port: options.caseSensitive? portname : portname.toLowerCase(), index: portindex != null ? portindex : undefined }},
|
100 | peg$c61 = function(port) { return port; },
|
101 | peg$c62 = /^[a-zA-Z.0-9_]/,
|
102 | peg$c63 = { type: "class", value: "[a-zA-Z.0-9_]", description: "[a-zA-Z.0-9_]" },
|
103 | peg$c64 = function(portname) {return makeName(portname)},
|
104 | peg$c65 = "[",
|
105 | peg$c66 = { type: "literal", value: "[", description: "\"[\"" },
|
106 | peg$c67 = /^[0-9]/,
|
107 | peg$c68 = { type: "class", value: "[0-9]", description: "[0-9]" },
|
108 | peg$c69 = "]",
|
109 | peg$c70 = { type: "literal", value: "]", description: "\"]\"" },
|
110 | peg$c71 = function(portindex) {return parseInt(portindex.join(''))},
|
111 | peg$c72 = /^[^\n\r\u2028\u2029]/,
|
112 | peg$c73 = { type: "class", value: "[^\\n\\r\\u2028\\u2029]", description: "[^\\n\\r\\u2028\\u2029]" },
|
113 | peg$c74 = /^[\\]/,
|
114 | peg$c75 = { type: "class", value: "[\\\\]", description: "[\\\\]" },
|
115 | peg$c76 = /^[']/,
|
116 | peg$c77 = { type: "class", value: "[']", description: "[']" },
|
117 | peg$c78 = function() { return "'"; },
|
118 | peg$c79 = /^[^']/,
|
119 | peg$c80 = { type: "class", value: "[^']", description: "[^']" },
|
120 | peg$c81 = " ",
|
121 | peg$c82 = { type: "literal", value: " ", description: "\" \"" },
|
122 | peg$c83 = function(value) { return value; },
|
123 | peg$c84 = "{",
|
124 | peg$c85 = { type: "literal", value: "{", description: "\"{\"" },
|
125 | peg$c86 = "}",
|
126 | peg$c87 = { type: "literal", value: "}", description: "\"}\"" },
|
127 | peg$c88 = { type: "other", description: "whitespace" },
|
128 | peg$c89 = /^[ \t\n\r]/,
|
129 | peg$c90 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
|
130 | peg$c91 = "false",
|
131 | peg$c92 = { type: "literal", value: "false", description: "\"false\"" },
|
132 | peg$c93 = function() { return false; },
|
133 | peg$c94 = "null",
|
134 | peg$c95 = { type: "literal", value: "null", description: "\"null\"" },
|
135 | peg$c96 = function() { return null; },
|
136 | peg$c97 = "true",
|
137 | peg$c98 = { type: "literal", value: "true", description: "\"true\"" },
|
138 | peg$c99 = function() { return true; },
|
139 | peg$c100 = function(head, m) { return m; },
|
140 | peg$c101 = function(head, tail) {
|
141 | var result = {}, i;
|
142 |
|
143 | result[head.name] = head.value;
|
144 |
|
145 | for (i = 0; i < tail.length; i++) {
|
146 | result[tail[i].name] = tail[i].value;
|
147 | }
|
148 |
|
149 | return result;
|
150 | },
|
151 | peg$c102 = function(members) { return members !== null ? members: {}; },
|
152 | peg$c103 = function(name, value) {
|
153 | return { name: name, value: value };
|
154 | },
|
155 | peg$c104 = function(head, v) { return v; },
|
156 | peg$c105 = function(head, tail) { return [head].concat(tail); },
|
157 | peg$c106 = function(values) { return values !== null ? values : []; },
|
158 | peg$c107 = { type: "other", description: "number" },
|
159 | peg$c108 = function() { return parseFloat(text()); },
|
160 | peg$c109 = /^[1-9]/,
|
161 | peg$c110 = { type: "class", value: "[1-9]", description: "[1-9]" },
|
162 | peg$c111 = /^[eE]/,
|
163 | peg$c112 = { type: "class", value: "[eE]", description: "[eE]" },
|
164 | peg$c113 = "-",
|
165 | peg$c114 = { type: "literal", value: "-", description: "\"-\"" },
|
166 | peg$c115 = "+",
|
167 | peg$c116 = { type: "literal", value: "+", description: "\"+\"" },
|
168 | peg$c117 = "0",
|
169 | peg$c118 = { type: "literal", value: "0", description: "\"0\"" },
|
170 | peg$c119 = { type: "other", description: "string" },
|
171 | peg$c120 = function(chars) { return chars.join(""); },
|
172 | peg$c121 = "\"",
|
173 | peg$c122 = { type: "literal", value: "\"", description: "\"\\\"\"" },
|
174 | peg$c123 = "\\",
|
175 | peg$c124 = { type: "literal", value: "\\", description: "\"\\\\\"" },
|
176 | peg$c125 = "/",
|
177 | peg$c126 = { type: "literal", value: "/", description: "\"/\"" },
|
178 | peg$c127 = "b",
|
179 | peg$c128 = { type: "literal", value: "b", description: "\"b\"" },
|
180 | peg$c129 = function() { return "\b"; },
|
181 | peg$c130 = "f",
|
182 | peg$c131 = { type: "literal", value: "f", description: "\"f\"" },
|
183 | peg$c132 = function() { return "\f"; },
|
184 | peg$c133 = "n",
|
185 | peg$c134 = { type: "literal", value: "n", description: "\"n\"" },
|
186 | peg$c135 = function() { return "\n"; },
|
187 | peg$c136 = "r",
|
188 | peg$c137 = { type: "literal", value: "r", description: "\"r\"" },
|
189 | peg$c138 = function() { return "\r"; },
|
190 | peg$c139 = "t",
|
191 | peg$c140 = { type: "literal", value: "t", description: "\"t\"" },
|
192 | peg$c141 = function() { return "\t"; },
|
193 | peg$c142 = "u",
|
194 | peg$c143 = { type: "literal", value: "u", description: "\"u\"" },
|
195 | peg$c144 = function(digits) {
|
196 | return String.fromCharCode(parseInt(digits, 16));
|
197 | },
|
198 | peg$c145 = function(sequence) { return sequence; },
|
199 | peg$c146 = /^[^\0-\x1F"\\]/,
|
200 | peg$c147 = { type: "class", value: "[^\\0-\\x1F\\x22\\x5C]", description: "[^\\0-\\x1F\\x22\\x5C]" },
|
201 | peg$c148 = /^[0-9a-f]/i,
|
202 | peg$c149 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
|
203 |
|
204 | peg$currPos = 0,
|
205 | peg$savedPos = 0,
|
206 | peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }],
|
207 | peg$maxFailPos = 0,
|
208 | peg$maxFailExpected = [],
|
209 | peg$silentFails = 0,
|
210 |
|
211 | peg$result;
|
212 |
|
213 | if ("startRule" in options) {
|
214 | if (!(options.startRule in peg$startRuleFunctions)) {
|
215 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
216 | }
|
217 |
|
218 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
219 | }
|
220 |
|
221 | function text() {
|
222 | return input.substring(peg$savedPos, peg$currPos);
|
223 | }
|
224 |
|
225 | function location() {
|
226 | return peg$computeLocation(peg$savedPos, peg$currPos);
|
227 | }
|
228 |
|
229 | function expected(description) {
|
230 | throw peg$buildException(
|
231 | null,
|
232 | [{ type: "other", description: description }],
|
233 | input.substring(peg$savedPos, peg$currPos),
|
234 | peg$computeLocation(peg$savedPos, peg$currPos)
|
235 | );
|
236 | }
|
237 |
|
238 | function error(message) {
|
239 | throw peg$buildException(
|
240 | message,
|
241 | null,
|
242 | input.substring(peg$savedPos, peg$currPos),
|
243 | peg$computeLocation(peg$savedPos, peg$currPos)
|
244 | );
|
245 | }
|
246 |
|
247 | function peg$computePosDetails(pos) {
|
248 | var details = peg$posDetailsCache[pos],
|
249 | p, ch;
|
250 |
|
251 | if (details) {
|
252 | return details;
|
253 | } else {
|
254 | p = pos - 1;
|
255 | while (!peg$posDetailsCache[p]) {
|
256 | p--;
|
257 | }
|
258 |
|
259 | details = peg$posDetailsCache[p];
|
260 | details = {
|
261 | line: details.line,
|
262 | column: details.column,
|
263 | seenCR: details.seenCR
|
264 | };
|
265 |
|
266 | while (p < pos) {
|
267 | ch = input.charAt(p);
|
268 | if (ch === "\n") {
|
269 | if (!details.seenCR) { details.line++; }
|
270 | details.column = 1;
|
271 | details.seenCR = false;
|
272 | } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
|
273 | details.line++;
|
274 | details.column = 1;
|
275 | details.seenCR = true;
|
276 | } else {
|
277 | details.column++;
|
278 | details.seenCR = false;
|
279 | }
|
280 |
|
281 | p++;
|
282 | }
|
283 |
|
284 | peg$posDetailsCache[pos] = details;
|
285 | return details;
|
286 | }
|
287 | }
|
288 |
|
289 | function peg$computeLocation(startPos, endPos) {
|
290 | var startPosDetails = peg$computePosDetails(startPos),
|
291 | endPosDetails = peg$computePosDetails(endPos);
|
292 |
|
293 | return {
|
294 | start: {
|
295 | offset: startPos,
|
296 | line: startPosDetails.line,
|
297 | column: startPosDetails.column
|
298 | },
|
299 | end: {
|
300 | offset: endPos,
|
301 | line: endPosDetails.line,
|
302 | column: endPosDetails.column
|
303 | }
|
304 | };
|
305 | }
|
306 |
|
307 | function peg$fail(expected) {
|
308 | if (peg$currPos < peg$maxFailPos) { return; }
|
309 |
|
310 | if (peg$currPos > peg$maxFailPos) {
|
311 | peg$maxFailPos = peg$currPos;
|
312 | peg$maxFailExpected = [];
|
313 | }
|
314 |
|
315 | peg$maxFailExpected.push(expected);
|
316 | }
|
317 |
|
318 | function peg$buildException(message, expected, found, location) {
|
319 | function cleanupExpected(expected) {
|
320 | var i = 1;
|
321 |
|
322 | expected.sort(function(a, b) {
|
323 | if (a.description < b.description) {
|
324 | return -1;
|
325 | } else if (a.description > b.description) {
|
326 | return 1;
|
327 | } else {
|
328 | return 0;
|
329 | }
|
330 | });
|
331 |
|
332 | while (i < expected.length) {
|
333 | if (expected[i - 1] === expected[i]) {
|
334 | expected.splice(i, 1);
|
335 | } else {
|
336 | i++;
|
337 | }
|
338 | }
|
339 | }
|
340 |
|
341 | function buildMessage(expected, found) {
|
342 | function stringEscape(s) {
|
343 | function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
|
344 |
|
345 | return s
|
346 | .replace(/\\/g, '\\\\')
|
347 | .replace(/"/g, '\\"')
|
348 | .replace(/\x08/g, '\\b')
|
349 | .replace(/\t/g, '\\t')
|
350 | .replace(/\n/g, '\\n')
|
351 | .replace(/\f/g, '\\f')
|
352 | .replace(/\r/g, '\\r')
|
353 | .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
354 | .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
|
355 | .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
356 | .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
|
357 | }
|
358 |
|
359 | var expectedDescs = new Array(expected.length),
|
360 | expectedDesc, foundDesc, i;
|
361 |
|
362 | for (i = 0; i < expected.length; i++) {
|
363 | expectedDescs[i] = expected[i].description;
|
364 | }
|
365 |
|
366 | expectedDesc = expected.length > 1
|
367 | ? expectedDescs.slice(0, -1).join(", ")
|
368 | + " or "
|
369 | + expectedDescs[expected.length - 1]
|
370 | : expectedDescs[0];
|
371 |
|
372 | foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
|
373 |
|
374 | return "Expected " + expectedDesc + " but " + foundDesc + " found.";
|
375 | }
|
376 |
|
377 | if (expected !== null) {
|
378 | cleanupExpected(expected);
|
379 | }
|
380 |
|
381 | return new peg$SyntaxError(
|
382 | message !== null ? message : buildMessage(expected, found),
|
383 | expected,
|
384 | found,
|
385 | location
|
386 | );
|
387 | }
|
388 |
|
389 | function peg$parsestart() {
|
390 | var s0, s1, s2;
|
391 |
|
392 | s0 = peg$currPos;
|
393 | s1 = [];
|
394 | s2 = peg$parseline();
|
395 | while (s2 !== peg$FAILED) {
|
396 | s1.push(s2);
|
397 | s2 = peg$parseline();
|
398 | }
|
399 | if (s1 !== peg$FAILED) {
|
400 | peg$savedPos = s0;
|
401 | s1 = peg$c0();
|
402 | }
|
403 | s0 = s1;
|
404 |
|
405 | return s0;
|
406 | }
|
407 |
|
408 | function peg$parseline() {
|
409 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
410 |
|
411 | s0 = peg$currPos;
|
412 | s1 = peg$parse_();
|
413 | if (s1 !== peg$FAILED) {
|
414 | if (input.substr(peg$currPos, 7) === peg$c1) {
|
415 | s2 = peg$c1;
|
416 | peg$currPos += 7;
|
417 | } else {
|
418 | s2 = peg$FAILED;
|
419 | if (peg$silentFails === 0) { peg$fail(peg$c2); }
|
420 | }
|
421 | if (s2 !== peg$FAILED) {
|
422 | s3 = peg$parsenode();
|
423 | if (s3 !== peg$FAILED) {
|
424 | if (input.charCodeAt(peg$currPos) === 46) {
|
425 | s4 = peg$c3;
|
426 | peg$currPos++;
|
427 | } else {
|
428 | s4 = peg$FAILED;
|
429 | if (peg$silentFails === 0) { peg$fail(peg$c4); }
|
430 | }
|
431 | if (s4 !== peg$FAILED) {
|
432 | s5 = peg$parseportName();
|
433 | if (s5 !== peg$FAILED) {
|
434 | if (input.charCodeAt(peg$currPos) === 58) {
|
435 | s6 = peg$c5;
|
436 | peg$currPos++;
|
437 | } else {
|
438 | s6 = peg$FAILED;
|
439 | if (peg$silentFails === 0) { peg$fail(peg$c6); }
|
440 | }
|
441 | if (s6 !== peg$FAILED) {
|
442 | s7 = peg$parseportName();
|
443 | if (s7 !== peg$FAILED) {
|
444 | s8 = peg$parse_();
|
445 | if (s8 !== peg$FAILED) {
|
446 | s9 = peg$parseLineTerminator();
|
447 | if (s9 === peg$FAILED) {
|
448 | s9 = null;
|
449 | }
|
450 | if (s9 !== peg$FAILED) {
|
451 | peg$savedPos = s0;
|
452 | s1 = peg$c7(s3, s5, s7);
|
453 | s0 = s1;
|
454 | } else {
|
455 | peg$currPos = s0;
|
456 | s0 = peg$FAILED;
|
457 | }
|
458 | } else {
|
459 | peg$currPos = s0;
|
460 | s0 = peg$FAILED;
|
461 | }
|
462 | } else {
|
463 | peg$currPos = s0;
|
464 | s0 = peg$FAILED;
|
465 | }
|
466 | } else {
|
467 | peg$currPos = s0;
|
468 | s0 = peg$FAILED;
|
469 | }
|
470 | } else {
|
471 | peg$currPos = s0;
|
472 | s0 = peg$FAILED;
|
473 | }
|
474 | } else {
|
475 | peg$currPos = s0;
|
476 | s0 = peg$FAILED;
|
477 | }
|
478 | } else {
|
479 | peg$currPos = s0;
|
480 | s0 = peg$FAILED;
|
481 | }
|
482 | } else {
|
483 | peg$currPos = s0;
|
484 | s0 = peg$FAILED;
|
485 | }
|
486 | } else {
|
487 | peg$currPos = s0;
|
488 | s0 = peg$FAILED;
|
489 | }
|
490 | if (s0 === peg$FAILED) {
|
491 | s0 = peg$currPos;
|
492 | s1 = peg$parse_();
|
493 | if (s1 !== peg$FAILED) {
|
494 | if (input.substr(peg$currPos, 8) === peg$c8) {
|
495 | s2 = peg$c8;
|
496 | peg$currPos += 8;
|
497 | } else {
|
498 | s2 = peg$FAILED;
|
499 | if (peg$silentFails === 0) { peg$fail(peg$c9); }
|
500 | }
|
501 | if (s2 !== peg$FAILED) {
|
502 | s3 = peg$parsenode();
|
503 | if (s3 !== peg$FAILED) {
|
504 | if (input.charCodeAt(peg$currPos) === 46) {
|
505 | s4 = peg$c3;
|
506 | peg$currPos++;
|
507 | } else {
|
508 | s4 = peg$FAILED;
|
509 | if (peg$silentFails === 0) { peg$fail(peg$c4); }
|
510 | }
|
511 | if (s4 !== peg$FAILED) {
|
512 | s5 = peg$parseportName();
|
513 | if (s5 !== peg$FAILED) {
|
514 | if (input.charCodeAt(peg$currPos) === 58) {
|
515 | s6 = peg$c5;
|
516 | peg$currPos++;
|
517 | } else {
|
518 | s6 = peg$FAILED;
|
519 | if (peg$silentFails === 0) { peg$fail(peg$c6); }
|
520 | }
|
521 | if (s6 !== peg$FAILED) {
|
522 | s7 = peg$parseportName();
|
523 | if (s7 !== peg$FAILED) {
|
524 | s8 = peg$parse_();
|
525 | if (s8 !== peg$FAILED) {
|
526 | s9 = peg$parseLineTerminator();
|
527 | if (s9 === peg$FAILED) {
|
528 | s9 = null;
|
529 | }
|
530 | if (s9 !== peg$FAILED) {
|
531 | peg$savedPos = s0;
|
532 | s1 = peg$c10(s3, s5, s7);
|
533 | s0 = s1;
|
534 | } else {
|
535 | peg$currPos = s0;
|
536 | s0 = peg$FAILED;
|
537 | }
|
538 | } else {
|
539 | peg$currPos = s0;
|
540 | s0 = peg$FAILED;
|
541 | }
|
542 | } else {
|
543 | peg$currPos = s0;
|
544 | s0 = peg$FAILED;
|
545 | }
|
546 | } else {
|
547 | peg$currPos = s0;
|
548 | s0 = peg$FAILED;
|
549 | }
|
550 | } else {
|
551 | peg$currPos = s0;
|
552 | s0 = peg$FAILED;
|
553 | }
|
554 | } else {
|
555 | peg$currPos = s0;
|
556 | s0 = peg$FAILED;
|
557 | }
|
558 | } else {
|
559 | peg$currPos = s0;
|
560 | s0 = peg$FAILED;
|
561 | }
|
562 | } else {
|
563 | peg$currPos = s0;
|
564 | s0 = peg$FAILED;
|
565 | }
|
566 | } else {
|
567 | peg$currPos = s0;
|
568 | s0 = peg$FAILED;
|
569 | }
|
570 | if (s0 === peg$FAILED) {
|
571 | s0 = peg$currPos;
|
572 | s1 = peg$parse_();
|
573 | if (s1 !== peg$FAILED) {
|
574 | if (input.substr(peg$currPos, 15) === peg$c11) {
|
575 | s2 = peg$c11;
|
576 | peg$currPos += 15;
|
577 | } else {
|
578 | s2 = peg$FAILED;
|
579 | if (peg$silentFails === 0) { peg$fail(peg$c12); }
|
580 | }
|
581 | if (s2 !== peg$FAILED) {
|
582 | s3 = peg$parseportName();
|
583 | if (s3 !== peg$FAILED) {
|
584 | s4 = peg$parse_();
|
585 | if (s4 !== peg$FAILED) {
|
586 | s5 = peg$parseLineTerminator();
|
587 | if (s5 === peg$FAILED) {
|
588 | s5 = null;
|
589 | }
|
590 | if (s5 !== peg$FAILED) {
|
591 | peg$savedPos = s0;
|
592 | s1 = peg$c13(s3);
|
593 | s0 = s1;
|
594 | } else {
|
595 | peg$currPos = s0;
|
596 | s0 = peg$FAILED;
|
597 | }
|
598 | } else {
|
599 | peg$currPos = s0;
|
600 | s0 = peg$FAILED;
|
601 | }
|
602 | } else {
|
603 | peg$currPos = s0;
|
604 | s0 = peg$FAILED;
|
605 | }
|
606 | } else {
|
607 | peg$currPos = s0;
|
608 | s0 = peg$FAILED;
|
609 | }
|
610 | } else {
|
611 | peg$currPos = s0;
|
612 | s0 = peg$FAILED;
|
613 | }
|
614 | if (s0 === peg$FAILED) {
|
615 | s0 = peg$currPos;
|
616 | s1 = peg$parse_();
|
617 | if (s1 !== peg$FAILED) {
|
618 | if (input.substr(peg$currPos, 16) === peg$c14) {
|
619 | s2 = peg$c14;
|
620 | peg$currPos += 16;
|
621 | } else {
|
622 | s2 = peg$FAILED;
|
623 | if (peg$silentFails === 0) { peg$fail(peg$c15); }
|
624 | }
|
625 | if (s2 !== peg$FAILED) {
|
626 | s3 = peg$parseportName();
|
627 | if (s3 !== peg$FAILED) {
|
628 | s4 = peg$parse_();
|
629 | if (s4 !== peg$FAILED) {
|
630 | s5 = peg$parseLineTerminator();
|
631 | if (s5 === peg$FAILED) {
|
632 | s5 = null;
|
633 | }
|
634 | if (s5 !== peg$FAILED) {
|
635 | peg$savedPos = s0;
|
636 | s1 = peg$c16(s3);
|
637 | s0 = s1;
|
638 | } else {
|
639 | peg$currPos = s0;
|
640 | s0 = peg$FAILED;
|
641 | }
|
642 | } else {
|
643 | peg$currPos = s0;
|
644 | s0 = peg$FAILED;
|
645 | }
|
646 | } else {
|
647 | peg$currPos = s0;
|
648 | s0 = peg$FAILED;
|
649 | }
|
650 | } else {
|
651 | peg$currPos = s0;
|
652 | s0 = peg$FAILED;
|
653 | }
|
654 | } else {
|
655 | peg$currPos = s0;
|
656 | s0 = peg$FAILED;
|
657 | }
|
658 | if (s0 === peg$FAILED) {
|
659 | s0 = peg$currPos;
|
660 | s1 = peg$parseannotation();
|
661 | if (s1 !== peg$FAILED) {
|
662 | s2 = peg$parsenewline();
|
663 | if (s2 !== peg$FAILED) {
|
664 | peg$savedPos = s0;
|
665 | s1 = peg$c17(s1);
|
666 | s0 = s1;
|
667 | } else {
|
668 | peg$currPos = s0;
|
669 | s0 = peg$FAILED;
|
670 | }
|
671 | } else {
|
672 | peg$currPos = s0;
|
673 | s0 = peg$FAILED;
|
674 | }
|
675 | if (s0 === peg$FAILED) {
|
676 | s0 = peg$currPos;
|
677 | s1 = peg$parsecomment();
|
678 | if (s1 !== peg$FAILED) {
|
679 | s2 = peg$parsenewline();
|
680 | if (s2 === peg$FAILED) {
|
681 | s2 = null;
|
682 | }
|
683 | if (s2 !== peg$FAILED) {
|
684 | s1 = [s1, s2];
|
685 | s0 = s1;
|
686 | } else {
|
687 | peg$currPos = s0;
|
688 | s0 = peg$FAILED;
|
689 | }
|
690 | } else {
|
691 | peg$currPos = s0;
|
692 | s0 = peg$FAILED;
|
693 | }
|
694 | if (s0 === peg$FAILED) {
|
695 | s0 = peg$currPos;
|
696 | s1 = peg$parse_();
|
697 | if (s1 !== peg$FAILED) {
|
698 | s2 = peg$parsenewline();
|
699 | if (s2 !== peg$FAILED) {
|
700 | s1 = [s1, s2];
|
701 | s0 = s1;
|
702 | } else {
|
703 | peg$currPos = s0;
|
704 | s0 = peg$FAILED;
|
705 | }
|
706 | } else {
|
707 | peg$currPos = s0;
|
708 | s0 = peg$FAILED;
|
709 | }
|
710 | if (s0 === peg$FAILED) {
|
711 | s0 = peg$currPos;
|
712 | s1 = peg$parse_();
|
713 | if (s1 !== peg$FAILED) {
|
714 | s2 = peg$parseconnection();
|
715 | if (s2 !== peg$FAILED) {
|
716 | s3 = peg$parse_();
|
717 | if (s3 !== peg$FAILED) {
|
718 | s4 = peg$parseLineTerminator();
|
719 | if (s4 === peg$FAILED) {
|
720 | s4 = null;
|
721 | }
|
722 | if (s4 !== peg$FAILED) {
|
723 | peg$savedPos = s0;
|
724 | s1 = peg$c18(s2);
|
725 | s0 = s1;
|
726 | } else {
|
727 | peg$currPos = s0;
|
728 | s0 = peg$FAILED;
|
729 | }
|
730 | } else {
|
731 | peg$currPos = s0;
|
732 | s0 = peg$FAILED;
|
733 | }
|
734 | } else {
|
735 | peg$currPos = s0;
|
736 | s0 = peg$FAILED;
|
737 | }
|
738 | } else {
|
739 | peg$currPos = s0;
|
740 | s0 = peg$FAILED;
|
741 | }
|
742 | }
|
743 | }
|
744 | }
|
745 | }
|
746 | }
|
747 | }
|
748 | }
|
749 |
|
750 | return s0;
|
751 | }
|
752 |
|
753 | function peg$parseLineTerminator() {
|
754 | var s0, s1, s2, s3, s4;
|
755 |
|
756 | s0 = peg$currPos;
|
757 | s1 = peg$parse_();
|
758 | if (s1 !== peg$FAILED) {
|
759 | if (input.charCodeAt(peg$currPos) === 44) {
|
760 | s2 = peg$c19;
|
761 | peg$currPos++;
|
762 | } else {
|
763 | s2 = peg$FAILED;
|
764 | if (peg$silentFails === 0) { peg$fail(peg$c20); }
|
765 | }
|
766 | if (s2 === peg$FAILED) {
|
767 | s2 = null;
|
768 | }
|
769 | if (s2 !== peg$FAILED) {
|
770 | s3 = peg$parsecomment();
|
771 | if (s3 === peg$FAILED) {
|
772 | s3 = null;
|
773 | }
|
774 | if (s3 !== peg$FAILED) {
|
775 | s4 = peg$parsenewline();
|
776 | if (s4 === peg$FAILED) {
|
777 | s4 = null;
|
778 | }
|
779 | if (s4 !== peg$FAILED) {
|
780 | s1 = [s1, s2, s3, s4];
|
781 | s0 = s1;
|
782 | } else {
|
783 | peg$currPos = s0;
|
784 | s0 = peg$FAILED;
|
785 | }
|
786 | } else {
|
787 | peg$currPos = s0;
|
788 | s0 = peg$FAILED;
|
789 | }
|
790 | } else {
|
791 | peg$currPos = s0;
|
792 | s0 = peg$FAILED;
|
793 | }
|
794 | } else {
|
795 | peg$currPos = s0;
|
796 | s0 = peg$FAILED;
|
797 | }
|
798 |
|
799 | return s0;
|
800 | }
|
801 |
|
802 | function peg$parsenewline() {
|
803 | var s0;
|
804 |
|
805 | if (peg$c21.test(input.charAt(peg$currPos))) {
|
806 | s0 = input.charAt(peg$currPos);
|
807 | peg$currPos++;
|
808 | } else {
|
809 | s0 = peg$FAILED;
|
810 | if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
811 | }
|
812 |
|
813 | return s0;
|
814 | }
|
815 |
|
816 | function peg$parsecomment() {
|
817 | var s0, s1, s2, s3, s4;
|
818 |
|
819 | s0 = peg$currPos;
|
820 | s1 = peg$parse_();
|
821 | if (s1 !== peg$FAILED) {
|
822 | if (input.charCodeAt(peg$currPos) === 35) {
|
823 | s2 = peg$c23;
|
824 | peg$currPos++;
|
825 | } else {
|
826 | s2 = peg$FAILED;
|
827 | if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
828 | }
|
829 | if (s2 !== peg$FAILED) {
|
830 | s3 = [];
|
831 | s4 = peg$parseanychar();
|
832 | while (s4 !== peg$FAILED) {
|
833 | s3.push(s4);
|
834 | s4 = peg$parseanychar();
|
835 | }
|
836 | if (s3 !== peg$FAILED) {
|
837 | s1 = [s1, s2, s3];
|
838 | s0 = s1;
|
839 | } else {
|
840 | peg$currPos = s0;
|
841 | s0 = peg$FAILED;
|
842 | }
|
843 | } else {
|
844 | peg$currPos = s0;
|
845 | s0 = peg$FAILED;
|
846 | }
|
847 | } else {
|
848 | peg$currPos = s0;
|
849 | s0 = peg$FAILED;
|
850 | }
|
851 |
|
852 | return s0;
|
853 | }
|
854 |
|
855 | function peg$parseconnection() {
|
856 | var s0, s1, s2, s3, s4, s5;
|
857 |
|
858 | s0 = peg$currPos;
|
859 | s1 = peg$parsesource();
|
860 | if (s1 !== peg$FAILED) {
|
861 | s2 = peg$parse_();
|
862 | if (s2 !== peg$FAILED) {
|
863 | if (input.substr(peg$currPos, 2) === peg$c25) {
|
864 | s3 = peg$c25;
|
865 | peg$currPos += 2;
|
866 | } else {
|
867 | s3 = peg$FAILED;
|
868 | if (peg$silentFails === 0) { peg$fail(peg$c26); }
|
869 | }
|
870 | if (s3 !== peg$FAILED) {
|
871 | s4 = peg$parse_();
|
872 | if (s4 !== peg$FAILED) {
|
873 | s5 = peg$parseconnection();
|
874 | if (s5 !== peg$FAILED) {
|
875 | peg$savedPos = s0;
|
876 | s1 = peg$c27(s1, s5);
|
877 | s0 = s1;
|
878 | } else {
|
879 | peg$currPos = s0;
|
880 | s0 = peg$FAILED;
|
881 | }
|
882 | } else {
|
883 | peg$currPos = s0;
|
884 | s0 = peg$FAILED;
|
885 | }
|
886 | } else {
|
887 | peg$currPos = s0;
|
888 | s0 = peg$FAILED;
|
889 | }
|
890 | } else {
|
891 | peg$currPos = s0;
|
892 | s0 = peg$FAILED;
|
893 | }
|
894 | } else {
|
895 | peg$currPos = s0;
|
896 | s0 = peg$FAILED;
|
897 | }
|
898 | if (s0 === peg$FAILED) {
|
899 | s0 = peg$parsedestination();
|
900 | }
|
901 |
|
902 | return s0;
|
903 | }
|
904 |
|
905 | function peg$parsesource() {
|
906 | var s0;
|
907 |
|
908 | s0 = peg$parsebridge();
|
909 | if (s0 === peg$FAILED) {
|
910 | s0 = peg$parseoutport();
|
911 | if (s0 === peg$FAILED) {
|
912 | s0 = peg$parseiip();
|
913 | }
|
914 | }
|
915 |
|
916 | return s0;
|
917 | }
|
918 |
|
919 | function peg$parsedestination() {
|
920 | var s0;
|
921 |
|
922 | s0 = peg$parseinport();
|
923 | if (s0 === peg$FAILED) {
|
924 | s0 = peg$parsebridge();
|
925 | }
|
926 |
|
927 | return s0;
|
928 | }
|
929 |
|
930 | function peg$parsebridge() {
|
931 | var s0, s1, s2, s3;
|
932 |
|
933 | s0 = peg$currPos;
|
934 | s1 = peg$parseport__();
|
935 | if (s1 !== peg$FAILED) {
|
936 | s2 = peg$parsenode();
|
937 | if (s2 !== peg$FAILED) {
|
938 | s3 = peg$parse__port();
|
939 | if (s3 !== peg$FAILED) {
|
940 | peg$savedPos = s0;
|
941 | s1 = peg$c28(s1, s2, s3);
|
942 | s0 = s1;
|
943 | } else {
|
944 | peg$currPos = s0;
|
945 | s0 = peg$FAILED;
|
946 | }
|
947 | } else {
|
948 | peg$currPos = s0;
|
949 | s0 = peg$FAILED;
|
950 | }
|
951 | } else {
|
952 | peg$currPos = s0;
|
953 | s0 = peg$FAILED;
|
954 | }
|
955 | if (s0 === peg$FAILED) {
|
956 | s0 = peg$currPos;
|
957 | s1 = peg$parseport__();
|
958 | if (s1 === peg$FAILED) {
|
959 | s1 = null;
|
960 | }
|
961 | if (s1 !== peg$FAILED) {
|
962 | s2 = peg$parsenodeWithComponent();
|
963 | if (s2 !== peg$FAILED) {
|
964 | s3 = peg$parse__port();
|
965 | if (s3 === peg$FAILED) {
|
966 | s3 = null;
|
967 | }
|
968 | if (s3 !== peg$FAILED) {
|
969 | peg$savedPos = s0;
|
970 | s1 = peg$c28(s1, s2, s3);
|
971 | s0 = s1;
|
972 | } else {
|
973 | peg$currPos = s0;
|
974 | s0 = peg$FAILED;
|
975 | }
|
976 | } else {
|
977 | peg$currPos = s0;
|
978 | s0 = peg$FAILED;
|
979 | }
|
980 | } else {
|
981 | peg$currPos = s0;
|
982 | s0 = peg$FAILED;
|
983 | }
|
984 | }
|
985 |
|
986 | return s0;
|
987 | }
|
988 |
|
989 | function peg$parseoutport() {
|
990 | var s0, s1, s2;
|
991 |
|
992 | s0 = peg$currPos;
|
993 | s1 = peg$parsenode();
|
994 | if (s1 !== peg$FAILED) {
|
995 | s2 = peg$parse__port();
|
996 | if (s2 === peg$FAILED) {
|
997 | s2 = null;
|
998 | }
|
999 | if (s2 !== peg$FAILED) {
|
1000 | peg$savedPos = s0;
|
1001 | s1 = peg$c29(s1, s2);
|
1002 | s0 = s1;
|
1003 | } else {
|
1004 | peg$currPos = s0;
|
1005 | s0 = peg$FAILED;
|
1006 | }
|
1007 | } else {
|
1008 | peg$currPos = s0;
|
1009 | s0 = peg$FAILED;
|
1010 | }
|
1011 |
|
1012 | return s0;
|
1013 | }
|
1014 |
|
1015 | function peg$parseinport() {
|
1016 | var s0, s1, s2;
|
1017 |
|
1018 | s0 = peg$currPos;
|
1019 | s1 = peg$parseport__();
|
1020 | if (s1 === peg$FAILED) {
|
1021 | s1 = null;
|
1022 | }
|
1023 | if (s1 !== peg$FAILED) {
|
1024 | s2 = peg$parsenode();
|
1025 | if (s2 !== peg$FAILED) {
|
1026 | peg$savedPos = s0;
|
1027 | s1 = peg$c30(s1, s2);
|
1028 | s0 = s1;
|
1029 | } else {
|
1030 | peg$currPos = s0;
|
1031 | s0 = peg$FAILED;
|
1032 | }
|
1033 | } else {
|
1034 | peg$currPos = s0;
|
1035 | s0 = peg$FAILED;
|
1036 | }
|
1037 |
|
1038 | return s0;
|
1039 | }
|
1040 |
|
1041 | function peg$parseiip() {
|
1042 | var s0, s1, s2, s3;
|
1043 |
|
1044 | s0 = peg$currPos;
|
1045 | if (input.charCodeAt(peg$currPos) === 39) {
|
1046 | s1 = peg$c31;
|
1047 | peg$currPos++;
|
1048 | } else {
|
1049 | s1 = peg$FAILED;
|
1050 | if (peg$silentFails === 0) { peg$fail(peg$c32); }
|
1051 | }
|
1052 | if (s1 !== peg$FAILED) {
|
1053 | s2 = [];
|
1054 | s3 = peg$parseiipchar();
|
1055 | while (s3 !== peg$FAILED) {
|
1056 | s2.push(s3);
|
1057 | s3 = peg$parseiipchar();
|
1058 | }
|
1059 | if (s2 !== peg$FAILED) {
|
1060 | if (input.charCodeAt(peg$currPos) === 39) {
|
1061 | s3 = peg$c31;
|
1062 | peg$currPos++;
|
1063 | } else {
|
1064 | s3 = peg$FAILED;
|
1065 | if (peg$silentFails === 0) { peg$fail(peg$c32); }
|
1066 | }
|
1067 | if (s3 !== peg$FAILED) {
|
1068 | peg$savedPos = s0;
|
1069 | s1 = peg$c33(s2);
|
1070 | s0 = s1;
|
1071 | } else {
|
1072 | peg$currPos = s0;
|
1073 | s0 = peg$FAILED;
|
1074 | }
|
1075 | } else {
|
1076 | peg$currPos = s0;
|
1077 | s0 = peg$FAILED;
|
1078 | }
|
1079 | } else {
|
1080 | peg$currPos = s0;
|
1081 | s0 = peg$FAILED;
|
1082 | }
|
1083 | if (s0 === peg$FAILED) {
|
1084 | s0 = peg$currPos;
|
1085 | s1 = peg$parseJSON_text();
|
1086 | if (s1 !== peg$FAILED) {
|
1087 | peg$savedPos = s0;
|
1088 | s1 = peg$c34(s1);
|
1089 | }
|
1090 | s0 = s1;
|
1091 | }
|
1092 |
|
1093 | return s0;
|
1094 | }
|
1095 |
|
1096 | function peg$parsenode() {
|
1097 | var s0, s1;
|
1098 |
|
1099 | s0 = peg$currPos;
|
1100 | s1 = peg$parsenodeNameAndComponent();
|
1101 | if (s1 !== peg$FAILED) {
|
1102 | peg$savedPos = s0;
|
1103 | s1 = peg$c35(s1);
|
1104 | }
|
1105 | s0 = s1;
|
1106 | if (s0 === peg$FAILED) {
|
1107 | s0 = peg$currPos;
|
1108 | s1 = peg$parsenodeName();
|
1109 | if (s1 !== peg$FAILED) {
|
1110 | peg$savedPos = s0;
|
1111 | s1 = peg$c35(s1);
|
1112 | }
|
1113 | s0 = s1;
|
1114 | if (s0 === peg$FAILED) {
|
1115 | s0 = peg$currPos;
|
1116 | s1 = peg$parsenodeComponent();
|
1117 | if (s1 !== peg$FAILED) {
|
1118 | peg$savedPos = s0;
|
1119 | s1 = peg$c35(s1);
|
1120 | }
|
1121 | s0 = s1;
|
1122 | }
|
1123 | }
|
1124 |
|
1125 | return s0;
|
1126 | }
|
1127 |
|
1128 | function peg$parsenodeName() {
|
1129 | var s0, s1, s2, s3, s4;
|
1130 |
|
1131 | s0 = peg$currPos;
|
1132 | s1 = peg$currPos;
|
1133 | if (peg$c36.test(input.charAt(peg$currPos))) {
|
1134 | s2 = input.charAt(peg$currPos);
|
1135 | peg$currPos++;
|
1136 | } else {
|
1137 | s2 = peg$FAILED;
|
1138 | if (peg$silentFails === 0) { peg$fail(peg$c37); }
|
1139 | }
|
1140 | if (s2 !== peg$FAILED) {
|
1141 | s3 = [];
|
1142 | if (peg$c38.test(input.charAt(peg$currPos))) {
|
1143 | s4 = input.charAt(peg$currPos);
|
1144 | peg$currPos++;
|
1145 | } else {
|
1146 | s4 = peg$FAILED;
|
1147 | if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
1148 | }
|
1149 | while (s4 !== peg$FAILED) {
|
1150 | s3.push(s4);
|
1151 | if (peg$c38.test(input.charAt(peg$currPos))) {
|
1152 | s4 = input.charAt(peg$currPos);
|
1153 | peg$currPos++;
|
1154 | } else {
|
1155 | s4 = peg$FAILED;
|
1156 | if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
1157 | }
|
1158 | }
|
1159 | if (s3 !== peg$FAILED) {
|
1160 | s2 = [s2, s3];
|
1161 | s1 = s2;
|
1162 | } else {
|
1163 | peg$currPos = s1;
|
1164 | s1 = peg$FAILED;
|
1165 | }
|
1166 | } else {
|
1167 | peg$currPos = s1;
|
1168 | s1 = peg$FAILED;
|
1169 | }
|
1170 | if (s1 !== peg$FAILED) {
|
1171 | peg$savedPos = s0;
|
1172 | s1 = peg$c40(s1);
|
1173 | }
|
1174 | s0 = s1;
|
1175 |
|
1176 | return s0;
|
1177 | }
|
1178 |
|
1179 | function peg$parsenodeNameAndComponent() {
|
1180 | var s0, s1, s2;
|
1181 |
|
1182 | s0 = peg$currPos;
|
1183 | s1 = peg$parsenodeName();
|
1184 | if (s1 !== peg$FAILED) {
|
1185 | s2 = peg$parsecomponent();
|
1186 | if (s2 !== peg$FAILED) {
|
1187 | peg$savedPos = s0;
|
1188 | s1 = peg$c41(s1, s2);
|
1189 | s0 = s1;
|
1190 | } else {
|
1191 | peg$currPos = s0;
|
1192 | s0 = peg$FAILED;
|
1193 | }
|
1194 | } else {
|
1195 | peg$currPos = s0;
|
1196 | s0 = peg$FAILED;
|
1197 | }
|
1198 |
|
1199 | return s0;
|
1200 | }
|
1201 |
|
1202 | function peg$parsenodeComponent() {
|
1203 | var s0, s1;
|
1204 |
|
1205 | s0 = peg$currPos;
|
1206 | s1 = peg$parsecomponent();
|
1207 | if (s1 !== peg$FAILED) {
|
1208 | peg$savedPos = s0;
|
1209 | s1 = peg$c42(s1);
|
1210 | }
|
1211 | s0 = s1;
|
1212 |
|
1213 | return s0;
|
1214 | }
|
1215 |
|
1216 | function peg$parsenodeWithComponent() {
|
1217 | var s0;
|
1218 |
|
1219 | s0 = peg$parsenodeNameAndComponent();
|
1220 | if (s0 === peg$FAILED) {
|
1221 | s0 = peg$parsenodeComponent();
|
1222 | }
|
1223 |
|
1224 | return s0;
|
1225 | }
|
1226 |
|
1227 | function peg$parsecomponent() {
|
1228 | var s0, s1, s2, s3, s4;
|
1229 |
|
1230 | s0 = peg$currPos;
|
1231 | if (input.charCodeAt(peg$currPos) === 40) {
|
1232 | s1 = peg$c43;
|
1233 | peg$currPos++;
|
1234 | } else {
|
1235 | s1 = peg$FAILED;
|
1236 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1237 | }
|
1238 | if (s1 !== peg$FAILED) {
|
1239 | s2 = [];
|
1240 | if (peg$c45.test(input.charAt(peg$currPos))) {
|
1241 | s3 = input.charAt(peg$currPos);
|
1242 | peg$currPos++;
|
1243 | } else {
|
1244 | s3 = peg$FAILED;
|
1245 | if (peg$silentFails === 0) { peg$fail(peg$c46); }
|
1246 | }
|
1247 | while (s3 !== peg$FAILED) {
|
1248 | s2.push(s3);
|
1249 | if (peg$c45.test(input.charAt(peg$currPos))) {
|
1250 | s3 = input.charAt(peg$currPos);
|
1251 | peg$currPos++;
|
1252 | } else {
|
1253 | s3 = peg$FAILED;
|
1254 | if (peg$silentFails === 0) { peg$fail(peg$c46); }
|
1255 | }
|
1256 | }
|
1257 | if (s2 === peg$FAILED) {
|
1258 | s2 = null;
|
1259 | }
|
1260 | if (s2 !== peg$FAILED) {
|
1261 | s3 = peg$parsecompMeta();
|
1262 | if (s3 === peg$FAILED) {
|
1263 | s3 = null;
|
1264 | }
|
1265 | if (s3 !== peg$FAILED) {
|
1266 | if (input.charCodeAt(peg$currPos) === 41) {
|
1267 | s4 = peg$c47;
|
1268 | peg$currPos++;
|
1269 | } else {
|
1270 | s4 = peg$FAILED;
|
1271 | if (peg$silentFails === 0) { peg$fail(peg$c48); }
|
1272 | }
|
1273 | if (s4 !== peg$FAILED) {
|
1274 | peg$savedPos = s0;
|
1275 | s1 = peg$c49(s2, s3);
|
1276 | s0 = s1;
|
1277 | } else {
|
1278 | peg$currPos = s0;
|
1279 | s0 = peg$FAILED;
|
1280 | }
|
1281 | } else {
|
1282 | peg$currPos = s0;
|
1283 | s0 = peg$FAILED;
|
1284 | }
|
1285 | } else {
|
1286 | peg$currPos = s0;
|
1287 | s0 = peg$FAILED;
|
1288 | }
|
1289 | } else {
|
1290 | peg$currPos = s0;
|
1291 | s0 = peg$FAILED;
|
1292 | }
|
1293 |
|
1294 | return s0;
|
1295 | }
|
1296 |
|
1297 | function peg$parsecompMeta() {
|
1298 | var s0, s1, s2, s3;
|
1299 |
|
1300 | s0 = peg$currPos;
|
1301 | if (input.charCodeAt(peg$currPos) === 58) {
|
1302 | s1 = peg$c5;
|
1303 | peg$currPos++;
|
1304 | } else {
|
1305 | s1 = peg$FAILED;
|
1306 | if (peg$silentFails === 0) { peg$fail(peg$c6); }
|
1307 | }
|
1308 | if (s1 !== peg$FAILED) {
|
1309 | s2 = [];
|
1310 | if (peg$c50.test(input.charAt(peg$currPos))) {
|
1311 | s3 = input.charAt(peg$currPos);
|
1312 | peg$currPos++;
|
1313 | } else {
|
1314 | s3 = peg$FAILED;
|
1315 | if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
1316 | }
|
1317 | if (s3 !== peg$FAILED) {
|
1318 | while (s3 !== peg$FAILED) {
|
1319 | s2.push(s3);
|
1320 | if (peg$c50.test(input.charAt(peg$currPos))) {
|
1321 | s3 = input.charAt(peg$currPos);
|
1322 | peg$currPos++;
|
1323 | } else {
|
1324 | s3 = peg$FAILED;
|
1325 | if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
1326 | }
|
1327 | }
|
1328 | } else {
|
1329 | s2 = peg$FAILED;
|
1330 | }
|
1331 | if (s2 !== peg$FAILED) {
|
1332 | peg$savedPos = s0;
|
1333 | s1 = peg$c52(s2);
|
1334 | s0 = s1;
|
1335 | } else {
|
1336 | peg$currPos = s0;
|
1337 | s0 = peg$FAILED;
|
1338 | }
|
1339 | } else {
|
1340 | peg$currPos = s0;
|
1341 | s0 = peg$FAILED;
|
1342 | }
|
1343 |
|
1344 | return s0;
|
1345 | }
|
1346 |
|
1347 | function peg$parseannotation() {
|
1348 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
1349 |
|
1350 | s0 = peg$currPos;
|
1351 | if (input.charCodeAt(peg$currPos) === 35) {
|
1352 | s1 = peg$c23;
|
1353 | peg$currPos++;
|
1354 | } else {
|
1355 | s1 = peg$FAILED;
|
1356 | if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
1357 | }
|
1358 | if (s1 !== peg$FAILED) {
|
1359 | s2 = peg$parse__();
|
1360 | if (s2 !== peg$FAILED) {
|
1361 | if (input.charCodeAt(peg$currPos) === 64) {
|
1362 | s3 = peg$c53;
|
1363 | peg$currPos++;
|
1364 | } else {
|
1365 | s3 = peg$FAILED;
|
1366 | if (peg$silentFails === 0) { peg$fail(peg$c54); }
|
1367 | }
|
1368 | if (s3 !== peg$FAILED) {
|
1369 | s4 = [];
|
1370 | if (peg$c55.test(input.charAt(peg$currPos))) {
|
1371 | s5 = input.charAt(peg$currPos);
|
1372 | peg$currPos++;
|
1373 | } else {
|
1374 | s5 = peg$FAILED;
|
1375 | if (peg$silentFails === 0) { peg$fail(peg$c56); }
|
1376 | }
|
1377 | if (s5 !== peg$FAILED) {
|
1378 | while (s5 !== peg$FAILED) {
|
1379 | s4.push(s5);
|
1380 | if (peg$c55.test(input.charAt(peg$currPos))) {
|
1381 | s5 = input.charAt(peg$currPos);
|
1382 | peg$currPos++;
|
1383 | } else {
|
1384 | s5 = peg$FAILED;
|
1385 | if (peg$silentFails === 0) { peg$fail(peg$c56); }
|
1386 | }
|
1387 | }
|
1388 | } else {
|
1389 | s4 = peg$FAILED;
|
1390 | }
|
1391 | if (s4 !== peg$FAILED) {
|
1392 | s5 = peg$parse__();
|
1393 | if (s5 !== peg$FAILED) {
|
1394 | s6 = [];
|
1395 | if (peg$c57.test(input.charAt(peg$currPos))) {
|
1396 | s7 = input.charAt(peg$currPos);
|
1397 | peg$currPos++;
|
1398 | } else {
|
1399 | s7 = peg$FAILED;
|
1400 | if (peg$silentFails === 0) { peg$fail(peg$c58); }
|
1401 | }
|
1402 | if (s7 !== peg$FAILED) {
|
1403 | while (s7 !== peg$FAILED) {
|
1404 | s6.push(s7);
|
1405 | if (peg$c57.test(input.charAt(peg$currPos))) {
|
1406 | s7 = input.charAt(peg$currPos);
|
1407 | peg$currPos++;
|
1408 | } else {
|
1409 | s7 = peg$FAILED;
|
1410 | if (peg$silentFails === 0) { peg$fail(peg$c58); }
|
1411 | }
|
1412 | }
|
1413 | } else {
|
1414 | s6 = peg$FAILED;
|
1415 | }
|
1416 | if (s6 !== peg$FAILED) {
|
1417 | peg$savedPos = s0;
|
1418 | s1 = peg$c59(s4, s6);
|
1419 | s0 = s1;
|
1420 | } else {
|
1421 | peg$currPos = s0;
|
1422 | s0 = peg$FAILED;
|
1423 | }
|
1424 | } else {
|
1425 | peg$currPos = s0;
|
1426 | s0 = peg$FAILED;
|
1427 | }
|
1428 | } else {
|
1429 | peg$currPos = s0;
|
1430 | s0 = peg$FAILED;
|
1431 | }
|
1432 | } else {
|
1433 | peg$currPos = s0;
|
1434 | s0 = peg$FAILED;
|
1435 | }
|
1436 | } else {
|
1437 | peg$currPos = s0;
|
1438 | s0 = peg$FAILED;
|
1439 | }
|
1440 | } else {
|
1441 | peg$currPos = s0;
|
1442 | s0 = peg$FAILED;
|
1443 | }
|
1444 |
|
1445 | return s0;
|
1446 | }
|
1447 |
|
1448 | function peg$parseport() {
|
1449 | var s0, s1, s2;
|
1450 |
|
1451 | s0 = peg$currPos;
|
1452 | s1 = peg$parseportName();
|
1453 | if (s1 !== peg$FAILED) {
|
1454 | s2 = peg$parseportIndex();
|
1455 | if (s2 === peg$FAILED) {
|
1456 | s2 = null;
|
1457 | }
|
1458 | if (s2 !== peg$FAILED) {
|
1459 | peg$savedPos = s0;
|
1460 | s1 = peg$c60(s1, s2);
|
1461 | s0 = s1;
|
1462 | } else {
|
1463 | peg$currPos = s0;
|
1464 | s0 = peg$FAILED;
|
1465 | }
|
1466 | } else {
|
1467 | peg$currPos = s0;
|
1468 | s0 = peg$FAILED;
|
1469 | }
|
1470 |
|
1471 | return s0;
|
1472 | }
|
1473 |
|
1474 | function peg$parseport__() {
|
1475 | var s0, s1, s2;
|
1476 |
|
1477 | s0 = peg$currPos;
|
1478 | s1 = peg$parseport();
|
1479 | if (s1 !== peg$FAILED) {
|
1480 | s2 = peg$parse__();
|
1481 | if (s2 !== peg$FAILED) {
|
1482 | peg$savedPos = s0;
|
1483 | s1 = peg$c61(s1);
|
1484 | s0 = s1;
|
1485 | } else {
|
1486 | peg$currPos = s0;
|
1487 | s0 = peg$FAILED;
|
1488 | }
|
1489 | } else {
|
1490 | peg$currPos = s0;
|
1491 | s0 = peg$FAILED;
|
1492 | }
|
1493 |
|
1494 | return s0;
|
1495 | }
|
1496 |
|
1497 | function peg$parse__port() {
|
1498 | var s0, s1, s2;
|
1499 |
|
1500 | s0 = peg$currPos;
|
1501 | s1 = peg$parse__();
|
1502 | if (s1 !== peg$FAILED) {
|
1503 | s2 = peg$parseport();
|
1504 | if (s2 !== peg$FAILED) {
|
1505 | peg$savedPos = s0;
|
1506 | s1 = peg$c61(s2);
|
1507 | s0 = s1;
|
1508 | } else {
|
1509 | peg$currPos = s0;
|
1510 | s0 = peg$FAILED;
|
1511 | }
|
1512 | } else {
|
1513 | peg$currPos = s0;
|
1514 | s0 = peg$FAILED;
|
1515 | }
|
1516 |
|
1517 | return s0;
|
1518 | }
|
1519 |
|
1520 | function peg$parseportName() {
|
1521 | var s0, s1, s2, s3, s4;
|
1522 |
|
1523 | s0 = peg$currPos;
|
1524 | s1 = peg$currPos;
|
1525 | if (peg$c36.test(input.charAt(peg$currPos))) {
|
1526 | s2 = input.charAt(peg$currPos);
|
1527 | peg$currPos++;
|
1528 | } else {
|
1529 | s2 = peg$FAILED;
|
1530 | if (peg$silentFails === 0) { peg$fail(peg$c37); }
|
1531 | }
|
1532 | if (s2 !== peg$FAILED) {
|
1533 | s3 = [];
|
1534 | if (peg$c62.test(input.charAt(peg$currPos))) {
|
1535 | s4 = input.charAt(peg$currPos);
|
1536 | peg$currPos++;
|
1537 | } else {
|
1538 | s4 = peg$FAILED;
|
1539 | if (peg$silentFails === 0) { peg$fail(peg$c63); }
|
1540 | }
|
1541 | while (s4 !== peg$FAILED) {
|
1542 | s3.push(s4);
|
1543 | if (peg$c62.test(input.charAt(peg$currPos))) {
|
1544 | s4 = input.charAt(peg$currPos);
|
1545 | peg$currPos++;
|
1546 | } else {
|
1547 | s4 = peg$FAILED;
|
1548 | if (peg$silentFails === 0) { peg$fail(peg$c63); }
|
1549 | }
|
1550 | }
|
1551 | if (s3 !== peg$FAILED) {
|
1552 | s2 = [s2, s3];
|
1553 | s1 = s2;
|
1554 | } else {
|
1555 | peg$currPos = s1;
|
1556 | s1 = peg$FAILED;
|
1557 | }
|
1558 | } else {
|
1559 | peg$currPos = s1;
|
1560 | s1 = peg$FAILED;
|
1561 | }
|
1562 | if (s1 !== peg$FAILED) {
|
1563 | peg$savedPos = s0;
|
1564 | s1 = peg$c64(s1);
|
1565 | }
|
1566 | s0 = s1;
|
1567 |
|
1568 | return s0;
|
1569 | }
|
1570 |
|
1571 | function peg$parseportIndex() {
|
1572 | var s0, s1, s2, s3;
|
1573 |
|
1574 | s0 = peg$currPos;
|
1575 | if (input.charCodeAt(peg$currPos) === 91) {
|
1576 | s1 = peg$c65;
|
1577 | peg$currPos++;
|
1578 | } else {
|
1579 | s1 = peg$FAILED;
|
1580 | if (peg$silentFails === 0) { peg$fail(peg$c66); }
|
1581 | }
|
1582 | if (s1 !== peg$FAILED) {
|
1583 | s2 = [];
|
1584 | if (peg$c67.test(input.charAt(peg$currPos))) {
|
1585 | s3 = input.charAt(peg$currPos);
|
1586 | peg$currPos++;
|
1587 | } else {
|
1588 | s3 = peg$FAILED;
|
1589 | if (peg$silentFails === 0) { peg$fail(peg$c68); }
|
1590 | }
|
1591 | if (s3 !== peg$FAILED) {
|
1592 | while (s3 !== peg$FAILED) {
|
1593 | s2.push(s3);
|
1594 | if (peg$c67.test(input.charAt(peg$currPos))) {
|
1595 | s3 = input.charAt(peg$currPos);
|
1596 | peg$currPos++;
|
1597 | } else {
|
1598 | s3 = peg$FAILED;
|
1599 | if (peg$silentFails === 0) { peg$fail(peg$c68); }
|
1600 | }
|
1601 | }
|
1602 | } else {
|
1603 | s2 = peg$FAILED;
|
1604 | }
|
1605 | if (s2 !== peg$FAILED) {
|
1606 | if (input.charCodeAt(peg$currPos) === 93) {
|
1607 | s3 = peg$c69;
|
1608 | peg$currPos++;
|
1609 | } else {
|
1610 | s3 = peg$FAILED;
|
1611 | if (peg$silentFails === 0) { peg$fail(peg$c70); }
|
1612 | }
|
1613 | if (s3 !== peg$FAILED) {
|
1614 | peg$savedPos = s0;
|
1615 | s1 = peg$c71(s2);
|
1616 | s0 = s1;
|
1617 | } else {
|
1618 | peg$currPos = s0;
|
1619 | s0 = peg$FAILED;
|
1620 | }
|
1621 | } else {
|
1622 | peg$currPos = s0;
|
1623 | s0 = peg$FAILED;
|
1624 | }
|
1625 | } else {
|
1626 | peg$currPos = s0;
|
1627 | s0 = peg$FAILED;
|
1628 | }
|
1629 |
|
1630 | return s0;
|
1631 | }
|
1632 |
|
1633 | function peg$parseanychar() {
|
1634 | var s0;
|
1635 |
|
1636 | if (peg$c72.test(input.charAt(peg$currPos))) {
|
1637 | s0 = input.charAt(peg$currPos);
|
1638 | peg$currPos++;
|
1639 | } else {
|
1640 | s0 = peg$FAILED;
|
1641 | if (peg$silentFails === 0) { peg$fail(peg$c73); }
|
1642 | }
|
1643 |
|
1644 | return s0;
|
1645 | }
|
1646 |
|
1647 | function peg$parseiipchar() {
|
1648 | var s0, s1, s2;
|
1649 |
|
1650 | s0 = peg$currPos;
|
1651 | if (peg$c74.test(input.charAt(peg$currPos))) {
|
1652 | s1 = input.charAt(peg$currPos);
|
1653 | peg$currPos++;
|
1654 | } else {
|
1655 | s1 = peg$FAILED;
|
1656 | if (peg$silentFails === 0) { peg$fail(peg$c75); }
|
1657 | }
|
1658 | if (s1 !== peg$FAILED) {
|
1659 | if (peg$c76.test(input.charAt(peg$currPos))) {
|
1660 | s2 = input.charAt(peg$currPos);
|
1661 | peg$currPos++;
|
1662 | } else {
|
1663 | s2 = peg$FAILED;
|
1664 | if (peg$silentFails === 0) { peg$fail(peg$c77); }
|
1665 | }
|
1666 | if (s2 !== peg$FAILED) {
|
1667 | peg$savedPos = s0;
|
1668 | s1 = peg$c78();
|
1669 | s0 = s1;
|
1670 | } else {
|
1671 | peg$currPos = s0;
|
1672 | s0 = peg$FAILED;
|
1673 | }
|
1674 | } else {
|
1675 | peg$currPos = s0;
|
1676 | s0 = peg$FAILED;
|
1677 | }
|
1678 | if (s0 === peg$FAILED) {
|
1679 | if (peg$c79.test(input.charAt(peg$currPos))) {
|
1680 | s0 = input.charAt(peg$currPos);
|
1681 | peg$currPos++;
|
1682 | } else {
|
1683 | s0 = peg$FAILED;
|
1684 | if (peg$silentFails === 0) { peg$fail(peg$c80); }
|
1685 | }
|
1686 | }
|
1687 |
|
1688 | return s0;
|
1689 | }
|
1690 |
|
1691 | function peg$parse_() {
|
1692 | var s0, s1;
|
1693 |
|
1694 | s0 = [];
|
1695 | if (input.charCodeAt(peg$currPos) === 32) {
|
1696 | s1 = peg$c81;
|
1697 | peg$currPos++;
|
1698 | } else {
|
1699 | s1 = peg$FAILED;
|
1700 | if (peg$silentFails === 0) { peg$fail(peg$c82); }
|
1701 | }
|
1702 | while (s1 !== peg$FAILED) {
|
1703 | s0.push(s1);
|
1704 | if (input.charCodeAt(peg$currPos) === 32) {
|
1705 | s1 = peg$c81;
|
1706 | peg$currPos++;
|
1707 | } else {
|
1708 | s1 = peg$FAILED;
|
1709 | if (peg$silentFails === 0) { peg$fail(peg$c82); }
|
1710 | }
|
1711 | }
|
1712 | if (s0 === peg$FAILED) {
|
1713 | s0 = null;
|
1714 | }
|
1715 |
|
1716 | return s0;
|
1717 | }
|
1718 |
|
1719 | function peg$parse__() {
|
1720 | var s0, s1;
|
1721 |
|
1722 | s0 = [];
|
1723 | if (input.charCodeAt(peg$currPos) === 32) {
|
1724 | s1 = peg$c81;
|
1725 | peg$currPos++;
|
1726 | } else {
|
1727 | s1 = peg$FAILED;
|
1728 | if (peg$silentFails === 0) { peg$fail(peg$c82); }
|
1729 | }
|
1730 | if (s1 !== peg$FAILED) {
|
1731 | while (s1 !== peg$FAILED) {
|
1732 | s0.push(s1);
|
1733 | if (input.charCodeAt(peg$currPos) === 32) {
|
1734 | s1 = peg$c81;
|
1735 | peg$currPos++;
|
1736 | } else {
|
1737 | s1 = peg$FAILED;
|
1738 | if (peg$silentFails === 0) { peg$fail(peg$c82); }
|
1739 | }
|
1740 | }
|
1741 | } else {
|
1742 | s0 = peg$FAILED;
|
1743 | }
|
1744 |
|
1745 | return s0;
|
1746 | }
|
1747 |
|
1748 | function peg$parseJSON_text() {
|
1749 | var s0, s1, s2, s3;
|
1750 |
|
1751 | s0 = peg$currPos;
|
1752 | s1 = peg$parsews();
|
1753 | if (s1 !== peg$FAILED) {
|
1754 | s2 = peg$parsevalue();
|
1755 | if (s2 !== peg$FAILED) {
|
1756 | s3 = peg$parsews();
|
1757 | if (s3 !== peg$FAILED) {
|
1758 | peg$savedPos = s0;
|
1759 | s1 = peg$c83(s2);
|
1760 | s0 = s1;
|
1761 | } else {
|
1762 | peg$currPos = s0;
|
1763 | s0 = peg$FAILED;
|
1764 | }
|
1765 | } else {
|
1766 | peg$currPos = s0;
|
1767 | s0 = peg$FAILED;
|
1768 | }
|
1769 | } else {
|
1770 | peg$currPos = s0;
|
1771 | s0 = peg$FAILED;
|
1772 | }
|
1773 |
|
1774 | return s0;
|
1775 | }
|
1776 |
|
1777 | function peg$parsebegin_array() {
|
1778 | var s0, s1, s2, s3;
|
1779 |
|
1780 | s0 = peg$currPos;
|
1781 | s1 = peg$parsews();
|
1782 | if (s1 !== peg$FAILED) {
|
1783 | if (input.charCodeAt(peg$currPos) === 91) {
|
1784 | s2 = peg$c65;
|
1785 | peg$currPos++;
|
1786 | } else {
|
1787 | s2 = peg$FAILED;
|
1788 | if (peg$silentFails === 0) { peg$fail(peg$c66); }
|
1789 | }
|
1790 | if (s2 !== peg$FAILED) {
|
1791 | s3 = peg$parsews();
|
1792 | if (s3 !== peg$FAILED) {
|
1793 | s1 = [s1, s2, s3];
|
1794 | s0 = s1;
|
1795 | } else {
|
1796 | peg$currPos = s0;
|
1797 | s0 = peg$FAILED;
|
1798 | }
|
1799 | } else {
|
1800 | peg$currPos = s0;
|
1801 | s0 = peg$FAILED;
|
1802 | }
|
1803 | } else {
|
1804 | peg$currPos = s0;
|
1805 | s0 = peg$FAILED;
|
1806 | }
|
1807 |
|
1808 | return s0;
|
1809 | }
|
1810 |
|
1811 | function peg$parsebegin_object() {
|
1812 | var s0, s1, s2, s3;
|
1813 |
|
1814 | s0 = peg$currPos;
|
1815 | s1 = peg$parsews();
|
1816 | if (s1 !== peg$FAILED) {
|
1817 | if (input.charCodeAt(peg$currPos) === 123) {
|
1818 | s2 = peg$c84;
|
1819 | peg$currPos++;
|
1820 | } else {
|
1821 | s2 = peg$FAILED;
|
1822 | if (peg$silentFails === 0) { peg$fail(peg$c85); }
|
1823 | }
|
1824 | if (s2 !== peg$FAILED) {
|
1825 | s3 = peg$parsews();
|
1826 | if (s3 !== peg$FAILED) {
|
1827 | s1 = [s1, s2, s3];
|
1828 | s0 = s1;
|
1829 | } else {
|
1830 | peg$currPos = s0;
|
1831 | s0 = peg$FAILED;
|
1832 | }
|
1833 | } else {
|
1834 | peg$currPos = s0;
|
1835 | s0 = peg$FAILED;
|
1836 | }
|
1837 | } else {
|
1838 | peg$currPos = s0;
|
1839 | s0 = peg$FAILED;
|
1840 | }
|
1841 |
|
1842 | return s0;
|
1843 | }
|
1844 |
|
1845 | function peg$parseend_array() {
|
1846 | var s0, s1, s2, s3;
|
1847 |
|
1848 | s0 = peg$currPos;
|
1849 | s1 = peg$parsews();
|
1850 | if (s1 !== peg$FAILED) {
|
1851 | if (input.charCodeAt(peg$currPos) === 93) {
|
1852 | s2 = peg$c69;
|
1853 | peg$currPos++;
|
1854 | } else {
|
1855 | s2 = peg$FAILED;
|
1856 | if (peg$silentFails === 0) { peg$fail(peg$c70); }
|
1857 | }
|
1858 | if (s2 !== peg$FAILED) {
|
1859 | s3 = peg$parsews();
|
1860 | if (s3 !== peg$FAILED) {
|
1861 | s1 = [s1, s2, s3];
|
1862 | s0 = s1;
|
1863 | } else {
|
1864 | peg$currPos = s0;
|
1865 | s0 = peg$FAILED;
|
1866 | }
|
1867 | } else {
|
1868 | peg$currPos = s0;
|
1869 | s0 = peg$FAILED;
|
1870 | }
|
1871 | } else {
|
1872 | peg$currPos = s0;
|
1873 | s0 = peg$FAILED;
|
1874 | }
|
1875 |
|
1876 | return s0;
|
1877 | }
|
1878 |
|
1879 | function peg$parseend_object() {
|
1880 | var s0, s1, s2, s3;
|
1881 |
|
1882 | s0 = peg$currPos;
|
1883 | s1 = peg$parsews();
|
1884 | if (s1 !== peg$FAILED) {
|
1885 | if (input.charCodeAt(peg$currPos) === 125) {
|
1886 | s2 = peg$c86;
|
1887 | peg$currPos++;
|
1888 | } else {
|
1889 | s2 = peg$FAILED;
|
1890 | if (peg$silentFails === 0) { peg$fail(peg$c87); }
|
1891 | }
|
1892 | if (s2 !== peg$FAILED) {
|
1893 | s3 = peg$parsews();
|
1894 | if (s3 !== peg$FAILED) {
|
1895 | s1 = [s1, s2, s3];
|
1896 | s0 = s1;
|
1897 | } else {
|
1898 | peg$currPos = s0;
|
1899 | s0 = peg$FAILED;
|
1900 | }
|
1901 | } else {
|
1902 | peg$currPos = s0;
|
1903 | s0 = peg$FAILED;
|
1904 | }
|
1905 | } else {
|
1906 | peg$currPos = s0;
|
1907 | s0 = peg$FAILED;
|
1908 | }
|
1909 |
|
1910 | return s0;
|
1911 | }
|
1912 |
|
1913 | function peg$parsename_separator() {
|
1914 | var s0, s1, s2, s3;
|
1915 |
|
1916 | s0 = peg$currPos;
|
1917 | s1 = peg$parsews();
|
1918 | if (s1 !== peg$FAILED) {
|
1919 | if (input.charCodeAt(peg$currPos) === 58) {
|
1920 | s2 = peg$c5;
|
1921 | peg$currPos++;
|
1922 | } else {
|
1923 | s2 = peg$FAILED;
|
1924 | if (peg$silentFails === 0) { peg$fail(peg$c6); }
|
1925 | }
|
1926 | if (s2 !== peg$FAILED) {
|
1927 | s3 = peg$parsews();
|
1928 | if (s3 !== peg$FAILED) {
|
1929 | s1 = [s1, s2, s3];
|
1930 | s0 = s1;
|
1931 | } else {
|
1932 | peg$currPos = s0;
|
1933 | s0 = peg$FAILED;
|
1934 | }
|
1935 | } else {
|
1936 | peg$currPos = s0;
|
1937 | s0 = peg$FAILED;
|
1938 | }
|
1939 | } else {
|
1940 | peg$currPos = s0;
|
1941 | s0 = peg$FAILED;
|
1942 | }
|
1943 |
|
1944 | return s0;
|
1945 | }
|
1946 |
|
1947 | function peg$parsevalue_separator() {
|
1948 | var s0, s1, s2, s3;
|
1949 |
|
1950 | s0 = peg$currPos;
|
1951 | s1 = peg$parsews();
|
1952 | if (s1 !== peg$FAILED) {
|
1953 | if (input.charCodeAt(peg$currPos) === 44) {
|
1954 | s2 = peg$c19;
|
1955 | peg$currPos++;
|
1956 | } else {
|
1957 | s2 = peg$FAILED;
|
1958 | if (peg$silentFails === 0) { peg$fail(peg$c20); }
|
1959 | }
|
1960 | if (s2 !== peg$FAILED) {
|
1961 | s3 = peg$parsews();
|
1962 | if (s3 !== peg$FAILED) {
|
1963 | s1 = [s1, s2, s3];
|
1964 | s0 = s1;
|
1965 | } else {
|
1966 | peg$currPos = s0;
|
1967 | s0 = peg$FAILED;
|
1968 | }
|
1969 | } else {
|
1970 | peg$currPos = s0;
|
1971 | s0 = peg$FAILED;
|
1972 | }
|
1973 | } else {
|
1974 | peg$currPos = s0;
|
1975 | s0 = peg$FAILED;
|
1976 | }
|
1977 |
|
1978 | return s0;
|
1979 | }
|
1980 |
|
1981 | function peg$parsews() {
|
1982 | var s0, s1;
|
1983 |
|
1984 | peg$silentFails++;
|
1985 | s0 = [];
|
1986 | if (peg$c89.test(input.charAt(peg$currPos))) {
|
1987 | s1 = input.charAt(peg$currPos);
|
1988 | peg$currPos++;
|
1989 | } else {
|
1990 | s1 = peg$FAILED;
|
1991 | if (peg$silentFails === 0) { peg$fail(peg$c90); }
|
1992 | }
|
1993 | while (s1 !== peg$FAILED) {
|
1994 | s0.push(s1);
|
1995 | if (peg$c89.test(input.charAt(peg$currPos))) {
|
1996 | s1 = input.charAt(peg$currPos);
|
1997 | peg$currPos++;
|
1998 | } else {
|
1999 | s1 = peg$FAILED;
|
2000 | if (peg$silentFails === 0) { peg$fail(peg$c90); }
|
2001 | }
|
2002 | }
|
2003 | peg$silentFails--;
|
2004 | if (s0 === peg$FAILED) {
|
2005 | s1 = peg$FAILED;
|
2006 | if (peg$silentFails === 0) { peg$fail(peg$c88); }
|
2007 | }
|
2008 |
|
2009 | return s0;
|
2010 | }
|
2011 |
|
2012 | function peg$parsevalue() {
|
2013 | var s0;
|
2014 |
|
2015 | s0 = peg$parsefalse();
|
2016 | if (s0 === peg$FAILED) {
|
2017 | s0 = peg$parsenull();
|
2018 | if (s0 === peg$FAILED) {
|
2019 | s0 = peg$parsetrue();
|
2020 | if (s0 === peg$FAILED) {
|
2021 | s0 = peg$parseobject();
|
2022 | if (s0 === peg$FAILED) {
|
2023 | s0 = peg$parsearray();
|
2024 | if (s0 === peg$FAILED) {
|
2025 | s0 = peg$parsenumber();
|
2026 | if (s0 === peg$FAILED) {
|
2027 | s0 = peg$parsestring();
|
2028 | }
|
2029 | }
|
2030 | }
|
2031 | }
|
2032 | }
|
2033 | }
|
2034 |
|
2035 | return s0;
|
2036 | }
|
2037 |
|
2038 | function peg$parsefalse() {
|
2039 | var s0, s1;
|
2040 |
|
2041 | s0 = peg$currPos;
|
2042 | if (input.substr(peg$currPos, 5) === peg$c91) {
|
2043 | s1 = peg$c91;
|
2044 | peg$currPos += 5;
|
2045 | } else {
|
2046 | s1 = peg$FAILED;
|
2047 | if (peg$silentFails === 0) { peg$fail(peg$c92); }
|
2048 | }
|
2049 | if (s1 !== peg$FAILED) {
|
2050 | peg$savedPos = s0;
|
2051 | s1 = peg$c93();
|
2052 | }
|
2053 | s0 = s1;
|
2054 |
|
2055 | return s0;
|
2056 | }
|
2057 |
|
2058 | function peg$parsenull() {
|
2059 | var s0, s1;
|
2060 |
|
2061 | s0 = peg$currPos;
|
2062 | if (input.substr(peg$currPos, 4) === peg$c94) {
|
2063 | s1 = peg$c94;
|
2064 | peg$currPos += 4;
|
2065 | } else {
|
2066 | s1 = peg$FAILED;
|
2067 | if (peg$silentFails === 0) { peg$fail(peg$c95); }
|
2068 | }
|
2069 | if (s1 !== peg$FAILED) {
|
2070 | peg$savedPos = s0;
|
2071 | s1 = peg$c96();
|
2072 | }
|
2073 | s0 = s1;
|
2074 |
|
2075 | return s0;
|
2076 | }
|
2077 |
|
2078 | function peg$parsetrue() {
|
2079 | var s0, s1;
|
2080 |
|
2081 | s0 = peg$currPos;
|
2082 | if (input.substr(peg$currPos, 4) === peg$c97) {
|
2083 | s1 = peg$c97;
|
2084 | peg$currPos += 4;
|
2085 | } else {
|
2086 | s1 = peg$FAILED;
|
2087 | if (peg$silentFails === 0) { peg$fail(peg$c98); }
|
2088 | }
|
2089 | if (s1 !== peg$FAILED) {
|
2090 | peg$savedPos = s0;
|
2091 | s1 = peg$c99();
|
2092 | }
|
2093 | s0 = s1;
|
2094 |
|
2095 | return s0;
|
2096 | }
|
2097 |
|
2098 | function peg$parseobject() {
|
2099 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
2100 |
|
2101 | s0 = peg$currPos;
|
2102 | s1 = peg$parsebegin_object();
|
2103 | if (s1 !== peg$FAILED) {
|
2104 | s2 = peg$currPos;
|
2105 | s3 = peg$parsemember();
|
2106 | if (s3 !== peg$FAILED) {
|
2107 | s4 = [];
|
2108 | s5 = peg$currPos;
|
2109 | s6 = peg$parsevalue_separator();
|
2110 | if (s6 !== peg$FAILED) {
|
2111 | s7 = peg$parsemember();
|
2112 | if (s7 !== peg$FAILED) {
|
2113 | peg$savedPos = s5;
|
2114 | s6 = peg$c100(s3, s7);
|
2115 | s5 = s6;
|
2116 | } else {
|
2117 | peg$currPos = s5;
|
2118 | s5 = peg$FAILED;
|
2119 | }
|
2120 | } else {
|
2121 | peg$currPos = s5;
|
2122 | s5 = peg$FAILED;
|
2123 | }
|
2124 | while (s5 !== peg$FAILED) {
|
2125 | s4.push(s5);
|
2126 | s5 = peg$currPos;
|
2127 | s6 = peg$parsevalue_separator();
|
2128 | if (s6 !== peg$FAILED) {
|
2129 | s7 = peg$parsemember();
|
2130 | if (s7 !== peg$FAILED) {
|
2131 | peg$savedPos = s5;
|
2132 | s6 = peg$c100(s3, s7);
|
2133 | s5 = s6;
|
2134 | } else {
|
2135 | peg$currPos = s5;
|
2136 | s5 = peg$FAILED;
|
2137 | }
|
2138 | } else {
|
2139 | peg$currPos = s5;
|
2140 | s5 = peg$FAILED;
|
2141 | }
|
2142 | }
|
2143 | if (s4 !== peg$FAILED) {
|
2144 | peg$savedPos = s2;
|
2145 | s3 = peg$c101(s3, s4);
|
2146 | s2 = s3;
|
2147 | } else {
|
2148 | peg$currPos = s2;
|
2149 | s2 = peg$FAILED;
|
2150 | }
|
2151 | } else {
|
2152 | peg$currPos = s2;
|
2153 | s2 = peg$FAILED;
|
2154 | }
|
2155 | if (s2 === peg$FAILED) {
|
2156 | s2 = null;
|
2157 | }
|
2158 | if (s2 !== peg$FAILED) {
|
2159 | s3 = peg$parseend_object();
|
2160 | if (s3 !== peg$FAILED) {
|
2161 | peg$savedPos = s0;
|
2162 | s1 = peg$c102(s2);
|
2163 | s0 = s1;
|
2164 | } else {
|
2165 | peg$currPos = s0;
|
2166 | s0 = peg$FAILED;
|
2167 | }
|
2168 | } else {
|
2169 | peg$currPos = s0;
|
2170 | s0 = peg$FAILED;
|
2171 | }
|
2172 | } else {
|
2173 | peg$currPos = s0;
|
2174 | s0 = peg$FAILED;
|
2175 | }
|
2176 |
|
2177 | return s0;
|
2178 | }
|
2179 |
|
2180 | function peg$parsemember() {
|
2181 | var s0, s1, s2, s3;
|
2182 |
|
2183 | s0 = peg$currPos;
|
2184 | s1 = peg$parsestring();
|
2185 | if (s1 !== peg$FAILED) {
|
2186 | s2 = peg$parsename_separator();
|
2187 | if (s2 !== peg$FAILED) {
|
2188 | s3 = peg$parsevalue();
|
2189 | if (s3 !== peg$FAILED) {
|
2190 | peg$savedPos = s0;
|
2191 | s1 = peg$c103(s1, s3);
|
2192 | s0 = s1;
|
2193 | } else {
|
2194 | peg$currPos = s0;
|
2195 | s0 = peg$FAILED;
|
2196 | }
|
2197 | } else {
|
2198 | peg$currPos = s0;
|
2199 | s0 = peg$FAILED;
|
2200 | }
|
2201 | } else {
|
2202 | peg$currPos = s0;
|
2203 | s0 = peg$FAILED;
|
2204 | }
|
2205 |
|
2206 | return s0;
|
2207 | }
|
2208 |
|
2209 | function peg$parsearray() {
|
2210 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
2211 |
|
2212 | s0 = peg$currPos;
|
2213 | s1 = peg$parsebegin_array();
|
2214 | if (s1 !== peg$FAILED) {
|
2215 | s2 = peg$currPos;
|
2216 | s3 = peg$parsevalue();
|
2217 | if (s3 !== peg$FAILED) {
|
2218 | s4 = [];
|
2219 | s5 = peg$currPos;
|
2220 | s6 = peg$parsevalue_separator();
|
2221 | if (s6 !== peg$FAILED) {
|
2222 | s7 = peg$parsevalue();
|
2223 | if (s7 !== peg$FAILED) {
|
2224 | peg$savedPos = s5;
|
2225 | s6 = peg$c104(s3, s7);
|
2226 | s5 = s6;
|
2227 | } else {
|
2228 | peg$currPos = s5;
|
2229 | s5 = peg$FAILED;
|
2230 | }
|
2231 | } else {
|
2232 | peg$currPos = s5;
|
2233 | s5 = peg$FAILED;
|
2234 | }
|
2235 | while (s5 !== peg$FAILED) {
|
2236 | s4.push(s5);
|
2237 | s5 = peg$currPos;
|
2238 | s6 = peg$parsevalue_separator();
|
2239 | if (s6 !== peg$FAILED) {
|
2240 | s7 = peg$parsevalue();
|
2241 | if (s7 !== peg$FAILED) {
|
2242 | peg$savedPos = s5;
|
2243 | s6 = peg$c104(s3, s7);
|
2244 | s5 = s6;
|
2245 | } else {
|
2246 | peg$currPos = s5;
|
2247 | s5 = peg$FAILED;
|
2248 | }
|
2249 | } else {
|
2250 | peg$currPos = s5;
|
2251 | s5 = peg$FAILED;
|
2252 | }
|
2253 | }
|
2254 | if (s4 !== peg$FAILED) {
|
2255 | peg$savedPos = s2;
|
2256 | s3 = peg$c105(s3, s4);
|
2257 | s2 = s3;
|
2258 | } else {
|
2259 | peg$currPos = s2;
|
2260 | s2 = peg$FAILED;
|
2261 | }
|
2262 | } else {
|
2263 | peg$currPos = s2;
|
2264 | s2 = peg$FAILED;
|
2265 | }
|
2266 | if (s2 === peg$FAILED) {
|
2267 | s2 = null;
|
2268 | }
|
2269 | if (s2 !== peg$FAILED) {
|
2270 | s3 = peg$parseend_array();
|
2271 | if (s3 !== peg$FAILED) {
|
2272 | peg$savedPos = s0;
|
2273 | s1 = peg$c106(s2);
|
2274 | s0 = s1;
|
2275 | } else {
|
2276 | peg$currPos = s0;
|
2277 | s0 = peg$FAILED;
|
2278 | }
|
2279 | } else {
|
2280 | peg$currPos = s0;
|
2281 | s0 = peg$FAILED;
|
2282 | }
|
2283 | } else {
|
2284 | peg$currPos = s0;
|
2285 | s0 = peg$FAILED;
|
2286 | }
|
2287 |
|
2288 | return s0;
|
2289 | }
|
2290 |
|
2291 | function peg$parsenumber() {
|
2292 | var s0, s1, s2, s3, s4;
|
2293 |
|
2294 | peg$silentFails++;
|
2295 | s0 = peg$currPos;
|
2296 | s1 = peg$parseminus();
|
2297 | if (s1 === peg$FAILED) {
|
2298 | s1 = null;
|
2299 | }
|
2300 | if (s1 !== peg$FAILED) {
|
2301 | s2 = peg$parseint();
|
2302 | if (s2 !== peg$FAILED) {
|
2303 | s3 = peg$parsefrac();
|
2304 | if (s3 === peg$FAILED) {
|
2305 | s3 = null;
|
2306 | }
|
2307 | if (s3 !== peg$FAILED) {
|
2308 | s4 = peg$parseexp();
|
2309 | if (s4 === peg$FAILED) {
|
2310 | s4 = null;
|
2311 | }
|
2312 | if (s4 !== peg$FAILED) {
|
2313 | peg$savedPos = s0;
|
2314 | s1 = peg$c108();
|
2315 | s0 = s1;
|
2316 | } else {
|
2317 | peg$currPos = s0;
|
2318 | s0 = peg$FAILED;
|
2319 | }
|
2320 | } else {
|
2321 | peg$currPos = s0;
|
2322 | s0 = peg$FAILED;
|
2323 | }
|
2324 | } else {
|
2325 | peg$currPos = s0;
|
2326 | s0 = peg$FAILED;
|
2327 | }
|
2328 | } else {
|
2329 | peg$currPos = s0;
|
2330 | s0 = peg$FAILED;
|
2331 | }
|
2332 | peg$silentFails--;
|
2333 | if (s0 === peg$FAILED) {
|
2334 | s1 = peg$FAILED;
|
2335 | if (peg$silentFails === 0) { peg$fail(peg$c107); }
|
2336 | }
|
2337 |
|
2338 | return s0;
|
2339 | }
|
2340 |
|
2341 | function peg$parsedecimal_point() {
|
2342 | var s0;
|
2343 |
|
2344 | if (input.charCodeAt(peg$currPos) === 46) {
|
2345 | s0 = peg$c3;
|
2346 | peg$currPos++;
|
2347 | } else {
|
2348 | s0 = peg$FAILED;
|
2349 | if (peg$silentFails === 0) { peg$fail(peg$c4); }
|
2350 | }
|
2351 |
|
2352 | return s0;
|
2353 | }
|
2354 |
|
2355 | function peg$parsedigit1_9() {
|
2356 | var s0;
|
2357 |
|
2358 | if (peg$c109.test(input.charAt(peg$currPos))) {
|
2359 | s0 = input.charAt(peg$currPos);
|
2360 | peg$currPos++;
|
2361 | } else {
|
2362 | s0 = peg$FAILED;
|
2363 | if (peg$silentFails === 0) { peg$fail(peg$c110); }
|
2364 | }
|
2365 |
|
2366 | return s0;
|
2367 | }
|
2368 |
|
2369 | function peg$parsee() {
|
2370 | var s0;
|
2371 |
|
2372 | if (peg$c111.test(input.charAt(peg$currPos))) {
|
2373 | s0 = input.charAt(peg$currPos);
|
2374 | peg$currPos++;
|
2375 | } else {
|
2376 | s0 = peg$FAILED;
|
2377 | if (peg$silentFails === 0) { peg$fail(peg$c112); }
|
2378 | }
|
2379 |
|
2380 | return s0;
|
2381 | }
|
2382 |
|
2383 | function peg$parseexp() {
|
2384 | var s0, s1, s2, s3, s4;
|
2385 |
|
2386 | s0 = peg$currPos;
|
2387 | s1 = peg$parsee();
|
2388 | if (s1 !== peg$FAILED) {
|
2389 | s2 = peg$parseminus();
|
2390 | if (s2 === peg$FAILED) {
|
2391 | s2 = peg$parseplus();
|
2392 | }
|
2393 | if (s2 === peg$FAILED) {
|
2394 | s2 = null;
|
2395 | }
|
2396 | if (s2 !== peg$FAILED) {
|
2397 | s3 = [];
|
2398 | s4 = peg$parseDIGIT();
|
2399 | if (s4 !== peg$FAILED) {
|
2400 | while (s4 !== peg$FAILED) {
|
2401 | s3.push(s4);
|
2402 | s4 = peg$parseDIGIT();
|
2403 | }
|
2404 | } else {
|
2405 | s3 = peg$FAILED;
|
2406 | }
|
2407 | if (s3 !== peg$FAILED) {
|
2408 | s1 = [s1, s2, s3];
|
2409 | s0 = s1;
|
2410 | } else {
|
2411 | peg$currPos = s0;
|
2412 | s0 = peg$FAILED;
|
2413 | }
|
2414 | } else {
|
2415 | peg$currPos = s0;
|
2416 | s0 = peg$FAILED;
|
2417 | }
|
2418 | } else {
|
2419 | peg$currPos = s0;
|
2420 | s0 = peg$FAILED;
|
2421 | }
|
2422 |
|
2423 | return s0;
|
2424 | }
|
2425 |
|
2426 | function peg$parsefrac() {
|
2427 | var s0, s1, s2, s3;
|
2428 |
|
2429 | s0 = peg$currPos;
|
2430 | s1 = peg$parsedecimal_point();
|
2431 | if (s1 !== peg$FAILED) {
|
2432 | s2 = [];
|
2433 | s3 = peg$parseDIGIT();
|
2434 | if (s3 !== peg$FAILED) {
|
2435 | while (s3 !== peg$FAILED) {
|
2436 | s2.push(s3);
|
2437 | s3 = peg$parseDIGIT();
|
2438 | }
|
2439 | } else {
|
2440 | s2 = peg$FAILED;
|
2441 | }
|
2442 | if (s2 !== peg$FAILED) {
|
2443 | s1 = [s1, s2];
|
2444 | s0 = s1;
|
2445 | } else {
|
2446 | peg$currPos = s0;
|
2447 | s0 = peg$FAILED;
|
2448 | }
|
2449 | } else {
|
2450 | peg$currPos = s0;
|
2451 | s0 = peg$FAILED;
|
2452 | }
|
2453 |
|
2454 | return s0;
|
2455 | }
|
2456 |
|
2457 | function peg$parseint() {
|
2458 | var s0, s1, s2, s3;
|
2459 |
|
2460 | s0 = peg$parsezero();
|
2461 | if (s0 === peg$FAILED) {
|
2462 | s0 = peg$currPos;
|
2463 | s1 = peg$parsedigit1_9();
|
2464 | if (s1 !== peg$FAILED) {
|
2465 | s2 = [];
|
2466 | s3 = peg$parseDIGIT();
|
2467 | while (s3 !== peg$FAILED) {
|
2468 | s2.push(s3);
|
2469 | s3 = peg$parseDIGIT();
|
2470 | }
|
2471 | if (s2 !== peg$FAILED) {
|
2472 | s1 = [s1, s2];
|
2473 | s0 = s1;
|
2474 | } else {
|
2475 | peg$currPos = s0;
|
2476 | s0 = peg$FAILED;
|
2477 | }
|
2478 | } else {
|
2479 | peg$currPos = s0;
|
2480 | s0 = peg$FAILED;
|
2481 | }
|
2482 | }
|
2483 |
|
2484 | return s0;
|
2485 | }
|
2486 |
|
2487 | function peg$parseminus() {
|
2488 | var s0;
|
2489 |
|
2490 | if (input.charCodeAt(peg$currPos) === 45) {
|
2491 | s0 = peg$c113;
|
2492 | peg$currPos++;
|
2493 | } else {
|
2494 | s0 = peg$FAILED;
|
2495 | if (peg$silentFails === 0) { peg$fail(peg$c114); }
|
2496 | }
|
2497 |
|
2498 | return s0;
|
2499 | }
|
2500 |
|
2501 | function peg$parseplus() {
|
2502 | var s0;
|
2503 |
|
2504 | if (input.charCodeAt(peg$currPos) === 43) {
|
2505 | s0 = peg$c115;
|
2506 | peg$currPos++;
|
2507 | } else {
|
2508 | s0 = peg$FAILED;
|
2509 | if (peg$silentFails === 0) { peg$fail(peg$c116); }
|
2510 | }
|
2511 |
|
2512 | return s0;
|
2513 | }
|
2514 |
|
2515 | function peg$parsezero() {
|
2516 | var s0;
|
2517 |
|
2518 | if (input.charCodeAt(peg$currPos) === 48) {
|
2519 | s0 = peg$c117;
|
2520 | peg$currPos++;
|
2521 | } else {
|
2522 | s0 = peg$FAILED;
|
2523 | if (peg$silentFails === 0) { peg$fail(peg$c118); }
|
2524 | }
|
2525 |
|
2526 | return s0;
|
2527 | }
|
2528 |
|
2529 | function peg$parsestring() {
|
2530 | var s0, s1, s2, s3;
|
2531 |
|
2532 | peg$silentFails++;
|
2533 | s0 = peg$currPos;
|
2534 | s1 = peg$parsequotation_mark();
|
2535 | if (s1 !== peg$FAILED) {
|
2536 | s2 = [];
|
2537 | s3 = peg$parsechar();
|
2538 | while (s3 !== peg$FAILED) {
|
2539 | s2.push(s3);
|
2540 | s3 = peg$parsechar();
|
2541 | }
|
2542 | if (s2 !== peg$FAILED) {
|
2543 | s3 = peg$parsequotation_mark();
|
2544 | if (s3 !== peg$FAILED) {
|
2545 | peg$savedPos = s0;
|
2546 | s1 = peg$c120(s2);
|
2547 | s0 = s1;
|
2548 | } else {
|
2549 | peg$currPos = s0;
|
2550 | s0 = peg$FAILED;
|
2551 | }
|
2552 | } else {
|
2553 | peg$currPos = s0;
|
2554 | s0 = peg$FAILED;
|
2555 | }
|
2556 | } else {
|
2557 | peg$currPos = s0;
|
2558 | s0 = peg$FAILED;
|
2559 | }
|
2560 | peg$silentFails--;
|
2561 | if (s0 === peg$FAILED) {
|
2562 | s1 = peg$FAILED;
|
2563 | if (peg$silentFails === 0) { peg$fail(peg$c119); }
|
2564 | }
|
2565 |
|
2566 | return s0;
|
2567 | }
|
2568 |
|
2569 | function peg$parsechar() {
|
2570 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
2571 |
|
2572 | s0 = peg$parseunescaped();
|
2573 | if (s0 === peg$FAILED) {
|
2574 | s0 = peg$currPos;
|
2575 | s1 = peg$parseescape();
|
2576 | if (s1 !== peg$FAILED) {
|
2577 | if (input.charCodeAt(peg$currPos) === 34) {
|
2578 | s2 = peg$c121;
|
2579 | peg$currPos++;
|
2580 | } else {
|
2581 | s2 = peg$FAILED;
|
2582 | if (peg$silentFails === 0) { peg$fail(peg$c122); }
|
2583 | }
|
2584 | if (s2 === peg$FAILED) {
|
2585 | if (input.charCodeAt(peg$currPos) === 92) {
|
2586 | s2 = peg$c123;
|
2587 | peg$currPos++;
|
2588 | } else {
|
2589 | s2 = peg$FAILED;
|
2590 | if (peg$silentFails === 0) { peg$fail(peg$c124); }
|
2591 | }
|
2592 | if (s2 === peg$FAILED) {
|
2593 | if (input.charCodeAt(peg$currPos) === 47) {
|
2594 | s2 = peg$c125;
|
2595 | peg$currPos++;
|
2596 | } else {
|
2597 | s2 = peg$FAILED;
|
2598 | if (peg$silentFails === 0) { peg$fail(peg$c126); }
|
2599 | }
|
2600 | if (s2 === peg$FAILED) {
|
2601 | s2 = peg$currPos;
|
2602 | if (input.charCodeAt(peg$currPos) === 98) {
|
2603 | s3 = peg$c127;
|
2604 | peg$currPos++;
|
2605 | } else {
|
2606 | s3 = peg$FAILED;
|
2607 | if (peg$silentFails === 0) { peg$fail(peg$c128); }
|
2608 | }
|
2609 | if (s3 !== peg$FAILED) {
|
2610 | peg$savedPos = s2;
|
2611 | s3 = peg$c129();
|
2612 | }
|
2613 | s2 = s3;
|
2614 | if (s2 === peg$FAILED) {
|
2615 | s2 = peg$currPos;
|
2616 | if (input.charCodeAt(peg$currPos) === 102) {
|
2617 | s3 = peg$c130;
|
2618 | peg$currPos++;
|
2619 | } else {
|
2620 | s3 = peg$FAILED;
|
2621 | if (peg$silentFails === 0) { peg$fail(peg$c131); }
|
2622 | }
|
2623 | if (s3 !== peg$FAILED) {
|
2624 | peg$savedPos = s2;
|
2625 | s3 = peg$c132();
|
2626 | }
|
2627 | s2 = s3;
|
2628 | if (s2 === peg$FAILED) {
|
2629 | s2 = peg$currPos;
|
2630 | if (input.charCodeAt(peg$currPos) === 110) {
|
2631 | s3 = peg$c133;
|
2632 | peg$currPos++;
|
2633 | } else {
|
2634 | s3 = peg$FAILED;
|
2635 | if (peg$silentFails === 0) { peg$fail(peg$c134); }
|
2636 | }
|
2637 | if (s3 !== peg$FAILED) {
|
2638 | peg$savedPos = s2;
|
2639 | s3 = peg$c135();
|
2640 | }
|
2641 | s2 = s3;
|
2642 | if (s2 === peg$FAILED) {
|
2643 | s2 = peg$currPos;
|
2644 | if (input.charCodeAt(peg$currPos) === 114) {
|
2645 | s3 = peg$c136;
|
2646 | peg$currPos++;
|
2647 | } else {
|
2648 | s3 = peg$FAILED;
|
2649 | if (peg$silentFails === 0) { peg$fail(peg$c137); }
|
2650 | }
|
2651 | if (s3 !== peg$FAILED) {
|
2652 | peg$savedPos = s2;
|
2653 | s3 = peg$c138();
|
2654 | }
|
2655 | s2 = s3;
|
2656 | if (s2 === peg$FAILED) {
|
2657 | s2 = peg$currPos;
|
2658 | if (input.charCodeAt(peg$currPos) === 116) {
|
2659 | s3 = peg$c139;
|
2660 | peg$currPos++;
|
2661 | } else {
|
2662 | s3 = peg$FAILED;
|
2663 | if (peg$silentFails === 0) { peg$fail(peg$c140); }
|
2664 | }
|
2665 | if (s3 !== peg$FAILED) {
|
2666 | peg$savedPos = s2;
|
2667 | s3 = peg$c141();
|
2668 | }
|
2669 | s2 = s3;
|
2670 | if (s2 === peg$FAILED) {
|
2671 | s2 = peg$currPos;
|
2672 | if (input.charCodeAt(peg$currPos) === 117) {
|
2673 | s3 = peg$c142;
|
2674 | peg$currPos++;
|
2675 | } else {
|
2676 | s3 = peg$FAILED;
|
2677 | if (peg$silentFails === 0) { peg$fail(peg$c143); }
|
2678 | }
|
2679 | if (s3 !== peg$FAILED) {
|
2680 | s4 = peg$currPos;
|
2681 | s5 = peg$currPos;
|
2682 | s6 = peg$parseHEXDIG();
|
2683 | if (s6 !== peg$FAILED) {
|
2684 | s7 = peg$parseHEXDIG();
|
2685 | if (s7 !== peg$FAILED) {
|
2686 | s8 = peg$parseHEXDIG();
|
2687 | if (s8 !== peg$FAILED) {
|
2688 | s9 = peg$parseHEXDIG();
|
2689 | if (s9 !== peg$FAILED) {
|
2690 | s6 = [s6, s7, s8, s9];
|
2691 | s5 = s6;
|
2692 | } else {
|
2693 | peg$currPos = s5;
|
2694 | s5 = peg$FAILED;
|
2695 | }
|
2696 | } else {
|
2697 | peg$currPos = s5;
|
2698 | s5 = peg$FAILED;
|
2699 | }
|
2700 | } else {
|
2701 | peg$currPos = s5;
|
2702 | s5 = peg$FAILED;
|
2703 | }
|
2704 | } else {
|
2705 | peg$currPos = s5;
|
2706 | s5 = peg$FAILED;
|
2707 | }
|
2708 | if (s5 !== peg$FAILED) {
|
2709 | s4 = input.substring(s4, peg$currPos);
|
2710 | } else {
|
2711 | s4 = s5;
|
2712 | }
|
2713 | if (s4 !== peg$FAILED) {
|
2714 | peg$savedPos = s2;
|
2715 | s3 = peg$c144(s4);
|
2716 | s2 = s3;
|
2717 | } else {
|
2718 | peg$currPos = s2;
|
2719 | s2 = peg$FAILED;
|
2720 | }
|
2721 | } else {
|
2722 | peg$currPos = s2;
|
2723 | s2 = peg$FAILED;
|
2724 | }
|
2725 | }
|
2726 | }
|
2727 | }
|
2728 | }
|
2729 | }
|
2730 | }
|
2731 | }
|
2732 | }
|
2733 | if (s2 !== peg$FAILED) {
|
2734 | peg$savedPos = s0;
|
2735 | s1 = peg$c145(s2);
|
2736 | s0 = s1;
|
2737 | } else {
|
2738 | peg$currPos = s0;
|
2739 | s0 = peg$FAILED;
|
2740 | }
|
2741 | } else {
|
2742 | peg$currPos = s0;
|
2743 | s0 = peg$FAILED;
|
2744 | }
|
2745 | }
|
2746 |
|
2747 | return s0;
|
2748 | }
|
2749 |
|
2750 | function peg$parseescape() {
|
2751 | var s0;
|
2752 |
|
2753 | if (input.charCodeAt(peg$currPos) === 92) {
|
2754 | s0 = peg$c123;
|
2755 | peg$currPos++;
|
2756 | } else {
|
2757 | s0 = peg$FAILED;
|
2758 | if (peg$silentFails === 0) { peg$fail(peg$c124); }
|
2759 | }
|
2760 |
|
2761 | return s0;
|
2762 | }
|
2763 |
|
2764 | function peg$parsequotation_mark() {
|
2765 | var s0;
|
2766 |
|
2767 | if (input.charCodeAt(peg$currPos) === 34) {
|
2768 | s0 = peg$c121;
|
2769 | peg$currPos++;
|
2770 | } else {
|
2771 | s0 = peg$FAILED;
|
2772 | if (peg$silentFails === 0) { peg$fail(peg$c122); }
|
2773 | }
|
2774 |
|
2775 | return s0;
|
2776 | }
|
2777 |
|
2778 | function peg$parseunescaped() {
|
2779 | var s0;
|
2780 |
|
2781 | if (peg$c146.test(input.charAt(peg$currPos))) {
|
2782 | s0 = input.charAt(peg$currPos);
|
2783 | peg$currPos++;
|
2784 | } else {
|
2785 | s0 = peg$FAILED;
|
2786 | if (peg$silentFails === 0) { peg$fail(peg$c147); }
|
2787 | }
|
2788 |
|
2789 | return s0;
|
2790 | }
|
2791 |
|
2792 | function peg$parseDIGIT() {
|
2793 | var s0;
|
2794 |
|
2795 | if (peg$c67.test(input.charAt(peg$currPos))) {
|
2796 | s0 = input.charAt(peg$currPos);
|
2797 | peg$currPos++;
|
2798 | } else {
|
2799 | s0 = peg$FAILED;
|
2800 | if (peg$silentFails === 0) { peg$fail(peg$c68); }
|
2801 | }
|
2802 |
|
2803 | return s0;
|
2804 | }
|
2805 |
|
2806 | function peg$parseHEXDIG() {
|
2807 | var s0;
|
2808 |
|
2809 | if (peg$c148.test(input.charAt(peg$currPos))) {
|
2810 | s0 = input.charAt(peg$currPos);
|
2811 | peg$currPos++;
|
2812 | } else {
|
2813 | s0 = peg$FAILED;
|
2814 | if (peg$silentFails === 0) { peg$fail(peg$c149); }
|
2815 | }
|
2816 |
|
2817 | return s0;
|
2818 | }
|
2819 |
|
2820 |
|
2821 | var parser, edges, nodes;
|
2822 |
|
2823 | var defaultInPort = "IN", defaultOutPort = "OUT";
|
2824 |
|
2825 | parser = this;
|
2826 | delete parser.properties;
|
2827 | delete parser.inports;
|
2828 | delete parser.outports;
|
2829 | delete parser.groups;
|
2830 |
|
2831 | edges = parser.edges = [];
|
2832 |
|
2833 | nodes = {};
|
2834 |
|
2835 | var serialize, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
2836 |
|
2837 | parser.validateContents = function(graph, options) {
|
2838 |
|
2839 | if (graph.processes) {
|
2840 | Object.keys(graph.processes).forEach(function (node) {
|
2841 | if (!graph.processes[node].component) {
|
2842 | throw new Error('Node "' + node + '" does not have a component defined');
|
2843 | }
|
2844 | });
|
2845 | }
|
2846 |
|
2847 | if (graph.inports) {
|
2848 | Object.keys(graph.inports).forEach(function (port) {
|
2849 | var portDef = graph.inports[port];
|
2850 | if (!graph.processes[portDef.process]) {
|
2851 | throw new Error('Inport "' + port + '" is connected to an undefined target node "' + portDef.process + '"');
|
2852 | }
|
2853 | });
|
2854 | }
|
2855 |
|
2856 | if (graph.outports) {
|
2857 | Object.keys(graph.outports).forEach(function (port) {
|
2858 | var portDef = graph.outports[port];
|
2859 | if (!graph.processes[portDef.process]) {
|
2860 | throw new Error('Outport "' + port + '" is connected to an undefined source node "' + portDef.process + '"');
|
2861 | }
|
2862 | });
|
2863 | }
|
2864 |
|
2865 | if (graph.connections) {
|
2866 | graph.connections.forEach(function (edge) {
|
2867 | if (edge.tgt && !graph.processes[edge.tgt.process]) {
|
2868 | if (edge.data) {
|
2869 | throw new Error('IIP containing "' + edge.data + '" is connected to an undefined target node "' + edge.tgt.process + '"');
|
2870 | }
|
2871 | throw new Error('Edge from "' + edge.src.process + '" port "' + edge.src.port + '" is connected to an undefined target node "' + edge.tgt.process + '"');
|
2872 | }
|
2873 | if (edge.src && !graph.processes[edge.src.process]) {
|
2874 | throw new Error('Edge to "' + edge.tgt.process + '" port "' + edge.tgt.port + '" is connected to an undefined source node "' + edge.src.process + '"');
|
2875 | }
|
2876 | });
|
2877 | }
|
2878 | };
|
2879 |
|
2880 | parser.addNode = function (nodeName, comp) {
|
2881 | if (!nodes[nodeName]) {
|
2882 | nodes[nodeName] = {}
|
2883 | }
|
2884 | if (!!comp.comp) {
|
2885 | nodes[nodeName].component = comp.comp;
|
2886 | }
|
2887 | if (!!comp.meta) {
|
2888 | var metadata = {};
|
2889 | for (var i = 0; i < comp.meta.length; i++) {
|
2890 | var item = comp.meta[i].split('=');
|
2891 | if (item.length === 1) {
|
2892 | item = ['routes', item[0]];
|
2893 | }
|
2894 | var key = item[0];
|
2895 | var value = item[1];
|
2896 | if (key==='x' || key==='y') {
|
2897 | value = parseFloat(value);
|
2898 | }
|
2899 | metadata[key] = value;
|
2900 | }
|
2901 | nodes[nodeName].metadata=metadata;
|
2902 | }
|
2903 |
|
2904 | }
|
2905 |
|
2906 | var anonymousIndexes = {};
|
2907 | var anonymousNodeNames = {};
|
2908 | parser.addAnonymousNode = function(comp, offset) {
|
2909 | if (!anonymousNodeNames[offset]) {
|
2910 | var componentName = comp.comp.replace(/[^a-zA-Z0-9]+/, "_");
|
2911 | anonymousIndexes[componentName] = (anonymousIndexes[componentName] || 0) + 1;
|
2912 | anonymousNodeNames[offset] = "_" + componentName + "_" + anonymousIndexes[componentName];
|
2913 | this.addNode(anonymousNodeNames[offset], comp);
|
2914 | }
|
2915 | return anonymousNodeNames[offset];
|
2916 | }
|
2917 |
|
2918 | parser.getResult = function () {
|
2919 | var result = {
|
2920 | inports: parser.inports || {},
|
2921 | outports: parser.outports || {},
|
2922 | groups: parser.groups || [],
|
2923 | processes: nodes || {},
|
2924 | connections: parser.processEdges()
|
2925 | };
|
2926 |
|
2927 | if (parser.properties) {
|
2928 | result.properties = parser.properties;
|
2929 | }
|
2930 | result.caseSensitive = options.caseSensitive || false;
|
2931 |
|
2932 | var validateSchema = parser.validateSchema;
|
2933 | if (typeof(options.validateSchema) !== 'undefined') { validateSchema = options.validateSchema; }
|
2934 | if (validateSchema) {
|
2935 | if (typeof(tv4) === 'undefined') {
|
2936 | var tv4 = require("tv4");
|
2937 | }
|
2938 | var schema = require("../schema/graph.json");
|
2939 | var validation = tv4.validateMultiple(result, schema);
|
2940 | if (!validation.valid) {
|
2941 | throw new Error("fbp: Did not validate againt graph schema:\n" + JSON.stringify(validation.errors, null, 2));
|
2942 | }
|
2943 | }
|
2944 |
|
2945 | if (typeof options.validateContents === 'undefined' || options.validateContents) {
|
2946 | parser.validateContents(result);
|
2947 | }
|
2948 |
|
2949 | return result;
|
2950 | }
|
2951 |
|
2952 | var flatten = function (array, isShallow) {
|
2953 | var index = -1,
|
2954 | length = array ? array.length : 0,
|
2955 | result = [];
|
2956 |
|
2957 | while (++index < length) {
|
2958 | var value = array[index];
|
2959 |
|
2960 | if (value instanceof Array) {
|
2961 | Array.prototype.push.apply(result, isShallow ? value : flatten(value));
|
2962 | }
|
2963 | else {
|
2964 | result.push(value);
|
2965 | }
|
2966 | }
|
2967 | return result;
|
2968 | }
|
2969 |
|
2970 | parser.registerAnnotation = function (key, value) {
|
2971 | if (!parser.properties) {
|
2972 | parser.properties = {};
|
2973 | }
|
2974 |
|
2975 | if (key === 'runtime') {
|
2976 | parser.properties.environment = {};
|
2977 | parser.properties.environment.type = value;
|
2978 | return;
|
2979 | }
|
2980 |
|
2981 | parser.properties[key] = value;
|
2982 | };
|
2983 |
|
2984 | parser.registerInports = function (node, port, pub) {
|
2985 | if (!parser.inports) {
|
2986 | parser.inports = {};
|
2987 | }
|
2988 |
|
2989 | if (!options.caseSensitive) {
|
2990 | pub = pub.toLowerCase();
|
2991 | port = port.toLowerCase();
|
2992 | }
|
2993 |
|
2994 | parser.inports[pub] = {process:node, port:port};
|
2995 | }
|
2996 | parser.registerOutports = function (node, port, pub) {
|
2997 | if (!parser.outports) {
|
2998 | parser.outports = {};
|
2999 | }
|
3000 |
|
3001 | if (!options.caseSensitive) {
|
3002 | pub = pub.toLowerCase();
|
3003 | port = port.toLowerCase();
|
3004 | }
|
3005 |
|
3006 | parser.outports[pub] = {process:node, port:port};
|
3007 | }
|
3008 |
|
3009 | parser.registerEdges = function (edges) {
|
3010 | if (Array.isArray(edges)) {
|
3011 | edges.forEach(function (o, i) {
|
3012 | parser.edges.push(o);
|
3013 | });
|
3014 | }
|
3015 | }
|
3016 |
|
3017 | parser.processEdges = function () {
|
3018 | var flats, grouped;
|
3019 | flats = flatten(parser.edges);
|
3020 | grouped = [];
|
3021 | var current = {};
|
3022 | for (var i = 1; i < flats.length; i += 1) {
|
3023 |
|
3024 | if (("src" in flats[i - 1] || "data" in flats[i - 1]) && "tgt" in flats[i]) {
|
3025 | flats[i - 1].tgt = flats[i].tgt;
|
3026 | grouped.push(flats[i - 1]);
|
3027 | i++;
|
3028 | }
|
3029 | }
|
3030 | return grouped;
|
3031 | }
|
3032 |
|
3033 | function makeName(s) {
|
3034 | return s[0] + s[1].join("");
|
3035 | }
|
3036 |
|
3037 | function makePort(process, port, defaultPort) {
|
3038 | if (!options.caseSensitive) {
|
3039 | defaultPort = defaultPort.toLowerCase()
|
3040 | }
|
3041 | var p = {
|
3042 | process: process,
|
3043 | port: port ? port.port : defaultPort
|
3044 | };
|
3045 | if (port && port.index != null) {
|
3046 | p.index = port.index;
|
3047 | }
|
3048 | return p;
|
3049 | }
|
3050 |
|
3051 | function makeInPort(process, port) {
|
3052 | return makePort(process, port, defaultInPort);
|
3053 | }
|
3054 | function makeOutPort(process, port) {
|
3055 | return makePort(process, port, defaultOutPort);
|
3056 | }
|
3057 |
|
3058 |
|
3059 | peg$result = peg$startRuleFunction();
|
3060 |
|
3061 | if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
3062 | return peg$result;
|
3063 | } else {
|
3064 | if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
3065 | peg$fail({ type: "end", description: "end of input" });
|
3066 | }
|
3067 |
|
3068 | throw peg$buildException(
|
3069 | null,
|
3070 | peg$maxFailExpected,
|
3071 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
3072 | peg$maxFailPos < input.length
|
3073 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
3074 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
3075 | );
|
3076 | }
|
3077 | }
|
3078 |
|
3079 | return {
|
3080 | SyntaxError: peg$SyntaxError,
|
3081 | parse: peg$parse
|
3082 | };
|
3083 | })(); |
\ | No newline at end of file |